fix: correct code langs (#708)

This commit is contained in:
Stephen Zhou
2026-03-16 15:28:32 +08:00
committed by GitHub
parent a958852d8d
commit 5df20ab29d
22 changed files with 70 additions and 70 deletions

View File

@@ -83,7 +83,7 @@ To implement subscription creation via manual URL pasting, you need to modify tw
<Tab title="github.yaml"> <Tab title="github.yaml">
Since GitHub webhooks use an encryption mechanism, a secret key is required to decrypt and validate incoming requests. Therefore, you need to declare `webhook_secret` in `github.yaml`. Since GitHub webhooks use an encryption mechanism, a secret key is required to decrypt and validate incoming requests. Therefore, you need to declare `webhook_secret` in `github.yaml`.
```YAML ```yaml
subscription_schema: subscription_schema:
- name: "webhook_secret" - name: "webhook_secret"
type: "secret-input" type: "secret-input"
@@ -112,7 +112,7 @@ To implement subscription creation via manual URL pasting, you need to modify tw
For the complete code sample, see [Dify's GitHub trigger plugin](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger). For the complete code sample, see [Dify's GitHub trigger plugin](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger).
</Tip> </Tip>
```Python ```python
class GithubTrigger(Trigger): class GithubTrigger(Trigger):
"""Handle GitHub webhook event dispatch.""" """Handle GitHub webhook event dispatch."""
@@ -141,7 +141,7 @@ Taking the Issue event as an example, you can define the event and its implement
<Tabs> <Tabs>
<Tab title="issues.yaml"> <Tab title="issues.yaml">
```YAML ```yaml
identity: identity:
name: issues name: issues
author: langgenius author: langgenius
@@ -167,7 +167,7 @@ Taking the Issue event as an example, you can define the event and its implement
``` ```
</Tab> </Tab>
<Tab title="issues.py"> <Tab title="issues.py">
```Python ```python
from collections.abc import Mapping from collections.abc import Mapping
from typing import Any from typing import Any
@@ -205,7 +205,7 @@ To filter out certain events—for example, to focus only on Issue events with a
<Tabs> <Tabs>
<Tab title="issues.yaml"> <Tab title="issues.yaml">
```YAML ```yaml
parameters: parameters:
- name: added_label - name: added_label
label: label:
@@ -221,7 +221,7 @@ To filter out certain events—for example, to focus only on Issue events with a
``` ```
</Tab> </Tab>
<Tab title="issues.py"> <Tab title="issues.py">
```Python ```python
def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None: def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None:
"""Check if the added label matches the allowed labels""" """Check if the added label matches the allowed labels"""
if not added_label_param: if not added_label_param:
@@ -256,7 +256,7 @@ To enable automatic subscription creation via OAuth or API key, you need to modi
<Tab title="github.yaml"> <Tab title="github.yaml">
In `github.yaml`, add the following fields. In `github.yaml`, add the following fields.
```YAML ```yaml
subscription_constructor: subscription_constructor:
parameters: parameters:
- name: "repository" - name: "repository"
@@ -307,7 +307,7 @@ To enable automatic subscription creation via OAuth or API key, you need to modi
<Tab title="github.py"> <Tab title="github.py">
In `github.py`, create a `Constructor` class to implement the automatic subscription logic. In `github.py`, create a `Constructor` class to implement the automatic subscription logic.
```Python ```python
class GithubSubscriptionConstructor(TriggerSubscriptionConstructor): class GithubSubscriptionConstructor(TriggerSubscriptionConstructor):
"""Manage GitHub trigger subscriptions.""" """Manage GitHub trigger subscriptions."""
def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: def _validate_api_key(self, credentials: Mapping[str, Any]) -> None:
@@ -394,7 +394,7 @@ The interface definitions and implementation methods of core classes in trigger
### Trigger ### Trigger
```Python ```python
class Trigger(ABC): class Trigger(ABC):
@abstractmethod @abstractmethod
def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch: def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch:
@@ -431,7 +431,7 @@ class Trigger(ABC):
### TriggerSubscriptionConstructor ### TriggerSubscriptionConstructor
```Python ```python
class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol):
# OPTIONAL # OPTIONAL
def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: def _validate_api_key(self, credentials: Mapping[str, Any]) -> None:
@@ -594,7 +594,7 @@ class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol):
### Event ### Event
```Python ```python
class Event(ABC): class Event(ABC):
@abstractmethod @abstractmethod
def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables: def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables:

View File

@@ -20,7 +20,7 @@ title: Local Source Code Start
### Clone Dify Repository ### Clone Dify Repository
Run the git command to clone the [Dify repository](https://github.com/langgenius/dify). Run the git command to clone the [Dify repository](https://github.com/langgenius/dify).
```Bash ```bash
git clone https://github.com/langgenius/dify.git git clone https://github.com/langgenius/dify.git
``` ```
@@ -28,7 +28,7 @@ git clone https://github.com/langgenius/dify.git
A series of middlewares for storage (e.g. PostgreSQL / Redis / Weaviate (if not locally available)) and extended capabilities (e.g. Dify's [sandbox](https://github.com/langgenius/dify-sandbox) and [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) services) are required by Dify backend services. Start the middlewares with Docker Compose by running these commands: A series of middlewares for storage (e.g. PostgreSQL / Redis / Weaviate (if not locally available)) and extended capabilities (e.g. Dify's [sandbox](https://github.com/langgenius/dify-sandbox) and [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) services) are required by Dify backend services. Start the middlewares with Docker Compose by running these commands:
```Bash ```bash
cd docker cd docker
cp middleware.env.example middleware.env cp middleware.env.example middleware.env

View File

@@ -6,7 +6,7 @@ When developing the backend separately, you may only need to start the backend s
#### Pull the Docker image for the frontend service from DockerHub: #### Pull the Docker image for the frontend service from DockerHub:
```Bash ```bash
docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest
``` ```

View File

@@ -131,7 +131,7 @@ Iteration nodes output arrays that often need conversion for final use:
</Tab> </Tab>
<Tab title="Using Template Node"> <Tab title="Using Template Node">
```jinja2 ```jinja
{{ articleSections | join("\n") }} {{ articleSections | join("\n") }}
``` ```

View File

@@ -112,7 +112,7 @@ The default variable selector for vision is `userinput.files` which automaticall
LLM prompts support Jinja2 templating for advanced variable handling. When you use Jinja2 mode (`edition_type: "jinja2"`), you can: LLM prompts support Jinja2 templating for advanced variable handling. When you use Jinja2 mode (`edition_type: "jinja2"`), you can:
```jinja2 ```jinja
{% for item in search_results %} {% for item in search_results %}
{{ loop.index }}. {{ item.title }}: {{ item.content }} {{ loop.index }}. {{ item.title }}: {{ item.content }}
{% endfor %} {% endfor %}

View File

@@ -18,7 +18,7 @@ Template nodes use Jinja2 templating syntax to create dynamic content that adapt
Reference workflow variables using double curly braces: `{{ variable_name }}`. You can access nested object properties and array elements using dot notation and bracket syntax. Reference workflow variables using double curly braces: `{{ variable_name }}`. You can access nested object properties and array elements using dot notation and bracket syntax.
```jinja2 ```jinja
{{ user.name }} {{ user.name }}
{{ items[0].title }} {{ items[0].title }}
{{ data.metrics.score }} {{ data.metrics.score }}
@@ -28,7 +28,7 @@ Reference workflow variables using double curly braces: `{{ variable_name }}`. Y
Show different content based on data values using if-else statements: Show different content based on data values using if-else statements:
```jinja2 ```jinja
{% if user.subscription == 'premium' %} {% if user.subscription == 'premium' %}
Welcome back, Premium Member! You have access to all features. Welcome back, Premium Member! You have access to all features.
{% else %} {% else %}
@@ -40,7 +40,7 @@ Consider upgrading to Premium for additional capabilities.
Process arrays and objects with for loops to generate repetitive content: Process arrays and objects with for loops to generate repetitive content:
```jinja2 ```jinja
{% for item in search_results %} {% for item in search_results %}
### Result {{ loop.index }} ### Result {{ loop.index }}
**Score**: {{ item.score | round(2) }} **Score**: {{ item.score | round(2) }}
@@ -59,7 +59,7 @@ Process arrays and objects with for loops to generate repetitive content:
Jinja2 filters transform data during template rendering: Jinja2 filters transform data during template rendering:
```jinja2 ```jinja
{{ name | upper }} {{ name | upper }}
{{ price | round(2) }} {{ price | round(2) }}
{{ content | replace('\n', '<br>') }} {{ content | replace('\n', '<br>') }}
@@ -71,7 +71,7 @@ Jinja2 filters transform data during template rendering:
Handle missing or invalid data gracefully using default values and conditional checks: Handle missing or invalid data gracefully using default values and conditional checks:
```jinja2 ```jinja
{{ user.email | default('No email provided') }} {{ user.email | default('No email provided') }}
{{ metrics.accuracy | round(2) if metrics.accuracy else 'Not calculated' }} {{ metrics.accuracy | round(2) if metrics.accuracy else 'Not calculated' }}
``` ```

View File

@@ -120,7 +120,7 @@ Alternatively, you can send a test request to the webhook trigger and check the
- Example: From the following request body, you can extract the `customerName` (`Alex`), the list of items, or the `isPriority` status (`true`). - Example: From the following request body, you can extract the `customerName` (`Alex`), the list of items, or the `isPriority` status (`true`).
```JSON ```json
"customerName": "Alex", "customerName": "Alex",
"items": "items":
[ [

View File

@@ -230,7 +230,7 @@ Since the Dify cloud version cannot access internal network API services, you ca
![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png) ![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png)
2. After downloading, go to the download directory, extract the archive according to the instructions below, and execute the initialization script in the instructions. 2. After downloading, go to the download directory, extract the archive according to the instructions below, and execute the initialization script in the instructions.
```Shell ```shell
unzip /path/to/ngrok.zip unzip /path/to/ngrok.zip
./ngrok config add-authtoken your-token ./ngrok config add-authtoken your-token
``` ```
@@ -240,7 +240,7 @@ Since the Dify cloud version cannot access internal network API services, you ca
And run the following command to start: And run the following command to start:
```Shell ```shell
./ngrok http port-number ./ngrok http port-number
``` ```

View File

@@ -85,7 +85,7 @@ Notion のようなプラットフォームでは、サブスクリプション
<Tab title="github.yaml"> <Tab title="github.yaml">
GitHub の webhook は暗号化メカニズムを使用しているため、受信リクエストを復号化して検証するためにシークレットキーが必要です。そのため、`github.yaml` で `webhook_secret` を宣言する必要があります。 GitHub の webhook は暗号化メカニズムを使用しているため、受信リクエストを復号化して検証するためにシークレットキーが必要です。そのため、`github.yaml` で `webhook_secret` を宣言する必要があります。
```YAML ```yaml
subscription_schema: subscription_schema:
- name: "webhook_secret" - name: "webhook_secret"
type: "secret-input" type: "secret-input"
@@ -114,7 +114,7 @@ Notion のようなプラットフォームでは、サブスクリプション
完全なコードサンプルについては、[Dify の GitHub トリガープラグイン](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger)を参照してください。 完全なコードサンプルについては、[Dify の GitHub トリガープラグイン](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger)を参照してください。
</Tip> </Tip>
```Python ```python
class GithubTrigger(Trigger): class GithubTrigger(Trigger):
"""Handle GitHub webhook event dispatch.""" """Handle GitHub webhook event dispatch."""
@@ -143,7 +143,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i
<Tabs> <Tabs>
<Tab title="issues.yaml"> <Tab title="issues.yaml">
```YAML ```yaml
identity: identity:
name: issues name: issues
author: langgenius author: langgenius
@@ -169,7 +169,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i
``` ```
</Tab> </Tab>
<Tab title="issues.py"> <Tab title="issues.py">
```Python ```python
from collections.abc import Mapping from collections.abc import Mapping
from typing import Any from typing import Any
@@ -207,7 +207,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i
<Tabs> <Tabs>
<Tab title="issues.yaml"> <Tab title="issues.yaml">
```YAML ```yaml
parameters: parameters:
- name: added_label - name: added_label
label: label:
@@ -223,7 +223,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i
``` ```
</Tab> </Tab>
<Tab title="issues.py"> <Tab title="issues.py">
```Python ```python
def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None: def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None:
"""Check if the added label matches the allowed labels""" """Check if the added label matches the allowed labels"""
if not added_label_param: if not added_label_param:
@@ -258,7 +258,7 @@ OAuth または API キーによる自動サブスクリプション作成を有
<Tab title="github.yaml"> <Tab title="github.yaml">
`github.yaml` に以下のフィールドを追加します。 `github.yaml` に以下のフィールドを追加します。
```YAML ```yaml
subscription_constructor: subscription_constructor:
parameters: parameters:
- name: "repository" - name: "repository"
@@ -309,7 +309,7 @@ OAuth または API キーによる自動サブスクリプション作成を有
<Tab title="github.py"> <Tab title="github.py">
`github.py` で、自動サブスクリプションロジックを実装する `Constructor` クラスを作成します。 `github.py` で、自動サブスクリプションロジックを実装する `Constructor` クラスを作成します。
```Python ```python
class GithubSubscriptionConstructor(TriggerSubscriptionConstructor): class GithubSubscriptionConstructor(TriggerSubscriptionConstructor):
"""Manage GitHub trigger subscriptions.""" """Manage GitHub trigger subscriptions."""
def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: def _validate_api_key(self, credentials: Mapping[str, Any]) -> None:
@@ -396,7 +396,7 @@ OAuth による自動サブスクリプション作成も同じ `Constructor`
### Trigger ### Trigger
```Python ```python
class Trigger(ABC): class Trigger(ABC):
@abstractmethod @abstractmethod
def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch: def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch:
@@ -433,7 +433,7 @@ class Trigger(ABC):
### TriggerSubscriptionConstructor ### TriggerSubscriptionConstructor
```Python ```python
class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol):
# OPTIONAL # OPTIONAL
def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: def _validate_api_key(self, credentials: Mapping[str, Any]) -> None:
@@ -596,7 +596,7 @@ class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol):
### Event ### Event
```Python ```python
class Event(ABC): class Event(ABC):
@abstractmethod @abstractmethod
def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables: def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables:

View File

@@ -25,7 +25,7 @@ title: ローカルソースコードからの起動
git コマンドを実行して [Dify リポジトリ](https://github.com/langgenius/dify) をクローンします。 git コマンドを実行して [Dify リポジトリ](https://github.com/langgenius/dify) をクローンします。
```Bash ```bash
git clone https://github.com/langgenius/dify.git git clone https://github.com/langgenius/dify.git
``` ```
@@ -33,7 +33,7 @@ git clone https://github.com/langgenius/dify.git
ストレージ用PostgreSQL / Redis / Weaviateローカルで利用できない場合や拡張機能用Dify の [sandbox](https://github.com/langgenius/dify-sandbox) や [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) サービスなど)の一連のミドルウェアが Dify バックエンドサービスで必要です。次のコマンドを実行して Docker Compose でミドルウェアを起動します: ストレージ用PostgreSQL / Redis / Weaviateローカルで利用できない場合や拡張機能用Dify の [sandbox](https://github.com/langgenius/dify-sandbox) や [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) サービスなど)の一連のミドルウェアが Dify バックエンドサービスで必要です。次のコマンドを実行して Docker Compose でミドルウェアを起動します:
```Bash ```bash
cd docker cd docker
cp middleware.env.example middleware.env cp middleware.env.example middleware.env

View File

@@ -8,7 +8,7 @@ title: フロントコンテナ起動
#### DockerHubからフロントエンドサービス用のDockerイメージをプルする #### DockerHubからフロントエンドサービス用のDockerイメージをプルする
```Bash ```bash
docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest
``` ```

View File

@@ -114,7 +114,7 @@ User: {{user_input}}
LLMプロンプトは高度な変数処理のためにJinja2テンプレートをサポートしています。Jinja2モード`edition_type: "jinja2"`)を使用すると、次のことができます: LLMプロンプトは高度な変数処理のためにJinja2テンプレートをサポートしています。Jinja2モード`edition_type: "jinja2"`)を使用すると、次のことができます:
```jinja2 ```jinja
{% for item in search_results %} {% for item in search_results %}
{{ loop.index }}. {{ item.title }}: {{ item.content }} {{ loop.index }}. {{ item.title }}: {{ item.content }}
{% endfor %} {% endfor %}

View File

@@ -21,7 +21,7 @@ icon: "note-sticky"
二重波括弧を使用してワークフロー変数を参照します:`{{ variable_name }}`。ドット記法とブラケット構文を使用して、ネストされたオブジェクトプロパティや配列要素にアクセスできます。 二重波括弧を使用してワークフロー変数を参照します:`{{ variable_name }}`。ドット記法とブラケット構文を使用して、ネストされたオブジェクトプロパティや配列要素にアクセスできます。
```jinja2 ```jinja
{{ user.name }} {{ user.name }}
{{ items[0].title }} {{ items[0].title }}
{{ data.metrics.score }} {{ data.metrics.score }}
@@ -31,7 +31,7 @@ icon: "note-sticky"
if-else文を使用してデータ値に基づいて異なるコンテンツを表示します if-else文を使用してデータ値に基づいて異なるコンテンツを表示します
```jinja2 ```jinja
{% if user.subscription == 'premium' %} {% if user.subscription == 'premium' %}
おかえりなさい、プレミアムメンバー様!すべての機能にアクセスできます。 おかえりなさい、プレミアムメンバー様!すべての機能にアクセスできます。
{% else %} {% else %}
@@ -43,7 +43,7 @@ if-else文を使用してデータ値に基づいて異なるコンテンツを
for ループを使用して配列とオブジェクトを処理し、反復的なコンテンツを生成します: for ループを使用して配列とオブジェクトを処理し、反復的なコンテンツを生成します:
```jinja2 ```jinja
{% for item in search_results %} {% for item in search_results %}
### 結果 {{ loop.index }} ### 結果 {{ loop.index }}
**スコア**: {{ item.score | round(2) }} **スコア**: {{ item.score | round(2) }}
@@ -62,7 +62,7 @@ for ループを使用して配列とオブジェクトを処理し、反復的
Jinja2フィルターはテンプレートレンダリング中にデータを変換します Jinja2フィルターはテンプレートレンダリング中にデータを変換します
```jinja2 ```jinja
{{ name | upper }} {{ name | upper }}
{{ price | round(2) }} {{ price | round(2) }}
{{ content | replace('\n', '<br>') }} {{ content | replace('\n', '<br>') }}
@@ -74,7 +74,7 @@ Jinja2フィルターはテンプレートレンダリング中にデータを
デフォルト値と条件チェックを使用して、欠損または無効なデータを適切に処理します: デフォルト値と条件チェックを使用して、欠損または無効なデータを適切に処理します:
```jinja2 ```jinja
{{ user.email | default('メールアドレスが提供されていません') }} {{ user.email | default('メールアドレスが提供されていません') }}
{{ metrics.accuracy | round(2) if metrics.accuracy else '計算されていません' }} {{ metrics.accuracy | round(2) if metrics.accuracy else '計算されていません' }}
``` ```

View File

@@ -122,7 +122,7 @@ Webhook トリガーが受信 HTTP リクエストを処理する方法を定義
- 例:次のリクエストボディから、`customerName``Alex`)、アイテムのリスト、または `isPriority` ステータス(`true`)を抽出できます。 - 例:次のリクエストボディから、`customerName``Alex`)、アイテムのリスト、または `isPriority` ステータス(`true`)を抽出できます。
```JSON ```json
"customerName": "Alex", "customerName": "Alex",
"items": "items":
[ [

View File

@@ -231,7 +231,7 @@ Dify クラウド版では内部ネットワークの API サービスにアク
![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png) ![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png)
2. ダウンロード完了後、ダウンロードディレクトリに移動し、以下の説明に従って圧縮ファイルを解凍し、説明の初期化スクリプトを実行します。 2. ダウンロード完了後、ダウンロードディレクトリに移動し、以下の説明に従って圧縮ファイルを解凍し、説明の初期化スクリプトを実行します。
```Shell ```shell
unzip /path/to/ngrok.zip unzip /path/to/ngrok.zip
./ngrok config add-authtoken あなたのToken ./ngrok config add-authtoken あなたのToken
``` ```
@@ -241,7 +241,7 @@ Dify クラウド版では内部ネットワークの API サービスにアク
そして、以下のコマンドを実行して起動します: そして、以下のコマンドを実行して起動します:
```Shell ```shell
./ngrok http ポート番号 ./ngrok http ポート番号
``` ```

View File

@@ -85,7 +85,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
<Tab title="github.yaml"> <Tab title="github.yaml">
由于 GitHub webhook 使用加密机制,需要一个密钥来解密和验证传入的请求。因此,你需要在 `github.yaml` 中声明 `webhook_secret`。 由于 GitHub webhook 使用加密机制,需要一个密钥来解密和验证传入的请求。因此,你需要在 `github.yaml` 中声明 `webhook_secret`。
```YAML ```yaml
subscription_schema: subscription_schema:
- name: "webhook_secret" - name: "webhook_secret"
type: "secret-input" type: "secret-input"
@@ -114,7 +114,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
完整代码示例,请参阅 [Dify 的 GitHub 触发器插件](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger)。 完整代码示例,请参阅 [Dify 的 GitHub 触发器插件](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger)。
</Tip> </Tip>
```Python ```python
class GithubTrigger(Trigger): class GithubTrigger(Trigger):
"""Handle GitHub webhook event dispatch.""" """Handle GitHub webhook event dispatch."""
@@ -143,7 +143,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
<Tabs> <Tabs>
<Tab title="issues.yaml"> <Tab title="issues.yaml">
```YAML ```yaml
identity: identity:
name: issues name: issues
author: langgenius author: langgenius
@@ -169,7 +169,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
``` ```
</Tab> </Tab>
<Tab title="issues.py"> <Tab title="issues.py">
```Python ```python
from collections.abc import Mapping from collections.abc import Mapping
from typing import Any from typing import Any
@@ -207,7 +207,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
<Tabs> <Tabs>
<Tab title="issues.yaml"> <Tab title="issues.yaml">
```YAML ```yaml
parameters: parameters:
- name: added_label - name: added_label
label: label:
@@ -223,7 +223,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
``` ```
</Tab> </Tab>
<Tab title="issues.py"> <Tab title="issues.py">
```Python ```python
def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None: def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None:
"""Check if the added label matches the allowed labels""" """Check if the added label matches the allowed labels"""
if not added_label_param: if not added_label_param:
@@ -258,7 +258,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
<Tab title="github.yaml"> <Tab title="github.yaml">
在 `github.yaml` 中,添加以下字段。 在 `github.yaml` 中,添加以下字段。
```YAML ```yaml
subscription_constructor: subscription_constructor:
parameters: parameters:
- name: "repository" - name: "repository"
@@ -309,7 +309,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
<Tab title="github.py"> <Tab title="github.py">
在 `github.py` 中,创建一个 `Constructor` 类来实现自动订阅逻辑。 在 `github.py` 中,创建一个 `Constructor` 类来实现自动订阅逻辑。
```Python ```python
class GithubSubscriptionConstructor(TriggerSubscriptionConstructor): class GithubSubscriptionConstructor(TriggerSubscriptionConstructor):
"""Manage GitHub trigger subscriptions.""" """Manage GitHub trigger subscriptions."""
def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: def _validate_api_key(self, credentials: Mapping[str, Any]) -> None:
@@ -396,7 +396,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了
### Trigger ### Trigger
```Python ```python
class Trigger(ABC): class Trigger(ABC):
@abstractmethod @abstractmethod
def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch: def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch:
@@ -433,7 +433,7 @@ class Trigger(ABC):
### TriggerSubscriptionConstructor ### TriggerSubscriptionConstructor
```Python ```python
class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol):
# OPTIONAL # OPTIONAL
def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: def _validate_api_key(self, credentials: Mapping[str, Any]) -> None:
@@ -596,7 +596,7 @@ class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol):
### Event ### Event
```Python ```python
class Event(ABC): class Event(ABC):
@abstractmethod @abstractmethod
def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables: def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables:

View File

@@ -24,7 +24,7 @@ title: 使用源代码本地启动
运行 git 命令克隆 [Dify 仓库](https://github.com/langgenius/dify)。 运行 git 命令克隆 [Dify 仓库](https://github.com/langgenius/dify)。
```Bash ```bash
git clone https://github.com/langgenius/dify.git git clone https://github.com/langgenius/dify.git
``` ```
@@ -32,7 +32,7 @@ git clone https://github.com/langgenius/dify.git
Dify 后端服务需要一系列用于存储(如 PostgreSQL / Redis / Weaviate如果本地不可用和扩展能力如 Dify 的 [sandbox](https://github.com/langgenius/dify-sandbox) 和 [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) 服务)的中间件。通过运行以下命令使用 Docker Compose 启动中间件: Dify 后端服务需要一系列用于存储(如 PostgreSQL / Redis / Weaviate如果本地不可用和扩展能力如 Dify 的 [sandbox](https://github.com/langgenius/dify-sandbox) 和 [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) 服务)的中间件。通过运行以下命令使用 Docker Compose 启动中间件:
```Bash ```bash
cd docker cd docker
cp middleware.env.example middleware.env cp middleware.env.example middleware.env

View File

@@ -8,7 +8,7 @@ title: 单独启动前端 Docker 容器
#### 从 DockerHub 拉取前端服务的 Docker 镜像: #### 从 DockerHub 拉取前端服务的 Docker 镜像:
```Bash ```bash
docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest
``` ```

View File

@@ -114,7 +114,7 @@ Question: {{user_question}}
大型语言模型提示词支持 Jinja2 模板以进行高级变量处理。当你使用 Jinja2 模式(`edition_type: "jinja2"`)时,你可以: 大型语言模型提示词支持 Jinja2 模板以进行高级变量处理。当你使用 Jinja2 模式(`edition_type: "jinja2"`)时,你可以:
```jinja2 ```jinja
{% for item in search_results %} {% for item in search_results %}
{{ loop.index }}. {{ item.title }}: {{ item.content }} {{ loop.index }}. {{ item.title }}: {{ item.content }}
{% endfor %} {% endfor %}

View File

@@ -20,7 +20,7 @@ icon: "note-sticky"
使用双花括号引用工作流变量:`{{ variable_name }}`。你可以使用点号和括号语法访问嵌套对象属性和数组元素。 使用双花括号引用工作流变量:`{{ variable_name }}`。你可以使用点号和括号语法访问嵌套对象属性和数组元素。
```jinja2 ```jinja
{{ user.name }} {{ user.name }}
{{ items[0].title }} {{ items[0].title }}
{{ data.metrics.score }} {{ data.metrics.score }}
@@ -30,7 +30,7 @@ icon: "note-sticky"
使用 if-else 语句根据数据值显示不同内容: 使用 if-else 语句根据数据值显示不同内容:
```jinja2 ```jinja
{% if user.subscription == 'premium' %} {% if user.subscription == 'premium' %}
欢迎回来,高级会员!你可以访问所有功能。 欢迎回来,高级会员!你可以访问所有功能。
{% else %} {% else %}
@@ -42,7 +42,7 @@ icon: "note-sticky"
使用 for 循环处理数组和对象以生成重复内容: 使用 for 循环处理数组和对象以生成重复内容:
```jinja2 ```jinja
{% for item in search_results %} {% for item in search_results %}
### 结果 {{ loop.index }} ### 结果 {{ loop.index }}
**分数**: {{ item.score | round(2) }} **分数**: {{ item.score | round(2) }}
@@ -61,7 +61,7 @@ icon: "note-sticky"
Jinja2 过滤器在模板渲染期间转换数据: Jinja2 过滤器在模板渲染期间转换数据:
```jinja2 ```jinja
{{ name | upper }} {{ name | upper }}
{{ price | round(2) }} {{ price | round(2) }}
{{ content | replace('\n', '<br>') }} {{ content | replace('\n', '<br>') }}
@@ -73,7 +73,7 @@ Jinja2 过滤器在模板渲染期间转换数据:
使用默认值和条件检查优雅地处理缺失或无效数据: 使用默认值和条件检查优雅地处理缺失或无效数据:
```jinja2 ```jinja
{{ user.email | default('未提供邮箱') }} {{ user.email | default('未提供邮箱') }}
{{ metrics.accuracy | round(2) if metrics.accuracy else '未计算' }} {{ metrics.accuracy | round(2) if metrics.accuracy else '未计算' }}
``` ```

View File

@@ -116,7 +116,7 @@ Webhook 允许一个系统自动向另一个系统发送实时数据。当某个
- 示例:从以下请求体中,可提取 `customerName``Alex`)、`items` 列表或 `isPriority` 状态(`true`)。 - 示例:从以下请求体中,可提取 `customerName``Alex`)、`items` 列表或 `isPriority` 状态(`true`)。
```JSON ```json
"customerName": "Alex", "customerName": "Alex",
"items": "items":
[ [

View File

@@ -230,7 +230,7 @@ API 返回为:
![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png) ![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png)
2. 下载完成后,进入下载目录,根据下方说明解压压缩包,并执行说明中的初始化脚本。 2. 下载完成后,进入下载目录,根据下方说明解压压缩包,并执行说明中的初始化脚本。
```Shell ```shell
unzip /path/to/ngrok.zip unzip /path/to/ngrok.zip
./ngrok config add-authtoken 你的Token ./ngrok config add-authtoken 你的Token
``` ```
@@ -240,7 +240,7 @@ API 返回为:
并运行以下命令启动: 并运行以下命令启动:
```Shell ```shell
./ngrok http 端口号 ./ngrok http 端口号
``` ```