Conversation 组件规格
与 Dapr 接口的受支持的 Conversation 组件
Table headers to note:
| Header | Description | Example |
|---|
| Status | Component certification status | Alpha Beta Stable
|
| Component version | The version of the component | v1 |
| Since runtime version | The version of the Dapr runtime when the component status was set or updated | 1.11 |
Amazon Web Services (AWS)
| Component | Status | Component version | Since runtime version |
|---|
| AWS Bedrock | Alpha | v1 | 1.15 |
Generic
1 - Anthropic
Anthropic 对话组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: anthropic
spec:
type: conversation.anthropic
metadata:
- name: key
value: "mykey"
- name: model
value: claude-3-5-sonnet-20240620
- name: responseCacheTTL
value: 10m
Warning
以上示例将密钥作为纯字符串使用。建议使用密钥存储来管理密钥,如
此处所述。
规范元数据字段
| 字段 | 必填 | 详情 | 示例 |
|---|
key | Y | Anthropic 的 API 密钥。 | "mykey" |
model | N | 要使用的 Anthropic LLM。默认为 claude-3-5-sonnet-20240620 | claude-3-5-sonnet-20240620 |
responseCacheTTL | N | 内存响应缓存的生存时间。设置后,相同的请求将从缓存中提供,直到过期。 | 10m |
相关链接
2 - AWS Bedrock
关于 AWS Bedrock 会话组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: awsbedrock
spec:
type: conversation.aws.bedrock
metadata:
- name: endpoint
value: "http://localhost:4566"
- name: model
value: amazon.titan-text-express-v1
- name: responseCacheTTL
value: 10m
警告
上述示例将密钥作为纯字符串使用。建议使用密钥存储来管理密钥,如
这里所述。
规格元数据字段
| 字段 | 必填 | 详情 | 示例 |
|---|
region | N | Bedrock 服务的 AWS 区域。 | us-east-1 |
endpoint | N | 组件用于连接模拟器的 AWS 端点。不推荐用于生产 AWS 环境。 | http://localhost:4566 |
accessKey | N | 用于身份验证的 AWS 访问密钥。建议使用密钥存储来存储此值。 | "AKIAIOSFODNN7EXAMPLE" |
secretKey | N | 用于身份验证的 AWS 密钥。建议使用密钥存储来存储此值。 | "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" |
sessionToken | N | 用于临时凭证的 AWS 会话令牌。建议使用密钥存储来存储此值。 | "session-token-example" |
model | N | 要使用的 LLM。默认为 Amazon 提供的 Bedrock 默认提供商模型。 | amazon.titan-text-express-v1 |
responseCacheTTL | N | 内存响应缓存的有效期。设置后,相同的请求将从缓存中提供服务,直到它们过期。 | 10m |
assumeRoleArn | N | 用于身份验证的要承担角色的 ARN。 | arn:aws:iam::123456789012:role/MyRole |
trustAnchorArn | N | 用于身份验证的信任锚点的 ARN。 | arn:aws:rolesanywhere:us-east-1:123456789012:trust-anchor/12345678-1234-1234-1234-123456789012 |
trustProfileArn | N | 用于身份验证的信任配置文件的 ARN。 | arn:aws:rolesanywhere:us-east-1:123456789012:profile/12345678-1234-1234-1234-123456789012 |
身份验证 AWS
AWS Bedrock 不使用 key 参数,而是使用 Dapr 的标准 IAM 或静态凭证方法进行身份验证。了解更多关于 AWS 身份验证的信息。
相关链接
3 - DeepSeek
DeepSeek 对话组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: deepseek
spec:
type: conversation.deepseek
metadata:
- name: key
value: mykey
- name: maxTokens
value: 2048
Warning
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets, as described
here.
规格元数据字段
| Field | Required | Details | Example |
|---|
key | Y | DeepSeek 的 API 密钥。 | mykey |
maxTokens | N | 每次请求的最大令牌数。 | 2048 |
相关链接
4 - 本地测试
用于本地测试的 echo conversation 组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: echo
spec:
type: conversation.echo
version: v1
Information
此组件仅用于 Conversation 组件实现的本地验证和测试。它实际上不会将数据发送到任何 LLM,而是直接回显输入。相关链接
5 - GoogleAI
GoogleAI 对话组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: googleai
spec:
type: conversation.googleai
metadata:
- name: key
value: mykey
- name: model
value: gemini-1.5-flash
- name: responseCacheTTL
value: 10m
警告
以上示例将密钥以纯字符串形式使用。建议使用密钥存储来管理密钥,具体说明请参见
此处。
规格元数据字段
| 字段 | 必填 | 详情 | 示例 |
|---|
key | Y | GoogleAI 的 API 密钥。 | mykey |
model | N | 要使用的 GoogleAI 大语言模型。默认为 gemini-1.5-flash。 | gemini-2.0-flash |
responseCacheTTL | N | 内存响应缓存的有效期。设置后,相同的请求将从缓存中提供响应,直到过期。 | 10m |
相关链接
6 - Huggingface
Huggingface 会话组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: huggingface
spec:
type: conversation.huggingface
metadata:
- name: key
value: mykey
- name: model
value: meta-llama/Meta-Llama-3-8B
- name: responseCacheTTL
value: 10m
警告
上述示例使用纯文本字符串作为密钥。建议使用密钥存储来管理密钥,具体说明请参见
此处。
规范元数据字段
| 字段 | 必填 | 详情 | 示例 |
|---|
key | Y | Huggingface 的 API 密钥。 | mykey |
model | N | 要使用的 Huggingface LLM。默认为 meta-llama/Meta-Llama-3-8B。 | meta-llama/Meta-Llama-3-8B |
responseCacheTTL | N | 内存响应缓存的生存时间。设置后,相同的请求将从缓存中提供,直到过期。 | 10m |
相关链接
7 - Mistral
Mistral 对话组件的详细信息
组件格式
Dapr 的 conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: mistral
spec:
type: conversation.mistral
metadata:
- name: key
value: mykey
- name: model
value: open-mistral-7b
- name: responseCacheTTL
value: 10m
Warning
上述示例使用纯文本字符串表示密钥。建议使用密钥存储来管理密钥,具体方法请参考
此处。
规范元数据字段
| 字段 | 必需 | 说明 | 示例 |
|---|
key | Y | Mistral 的 API 密钥。 | mykey |
model | N | 要使用的 Mistral LLM。默认为 open-mistral-7b。 | open-mistral-7b |
responseCacheTTL | N | 内存响应缓存的生存时间。设置后,相同的请求将从缓存中返回,直到过期。 | 10m |
相关链接
8 - Ollama
Ollama 对话组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: ollama
spec:
type: conversation.ollama
metadata:
- name: model
value: llama3.2:latest
- name: responseCacheTTL
value: 10m
警告
上面的示例使用明文字符串作为密钥。建议按照
此处的说明使用密钥存储来管理密钥。
规格元数据字段
| Field | Required | Details | Example |
|---|
model | N | 要使用的 Ollama LLM。默认为 llama3.2:latest。 | phi4:latest |
responseCacheTTL | N | 内存响应缓存的生存时间。设置后,相同的请求将从缓存中提供,直到它们过期。 | 10m |
OpenAI 兼容性
Ollama 与 OpenAI 的 API 兼容。你可以通过以下更改使用 OpenAI 组件与 Ollama 模型配合使用:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: ollama-openai
spec:
type: conversation.openai # 使用 openai 组件类型
metadata:
- name: key
value: 'ollama' # 任何非空字符串
- name: model
value: gpt-oss:20b # 一个 ollama 模型(https://ollama.com/search),在这种情况下是 openai 开源模型。参见 https://ollama.com/library/gpt-oss
- name: endpoint
value: 'http://localhost:11434/v1' # ollama 端点
相关链接
9 - OpenAI
OpenAI 对话组件的详细信息
组件格式
Dapr conversation.yaml 组件文件具有以下结构:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: openai
spec:
type: conversation.openai
metadata:
- name: key
value: mykey
- name: model
value: gpt-4-turbo
- name: endpoint
value: 'https://api.openai.com/v1'
- name: responseCacheTTL
value: 10m
# - name: apiType # Optional
# value: 'azure'
# - name: apiVersion # Optional
# value: '2025-01-01-preview'
Warning
上述示例将密钥以纯文本字符串的形式使用。建议使用密钥存储来管理密钥,具体描述请参见
此处。
规范元数据字段
| 字段 | 必填 | 详情 | 示例 |
|---|
key | Y | OpenAI 的 API 密钥。 | mykey |
model | N | 要使用的 OpenAI 大语言模型。默认为 gpt-4-turbo。 | gpt-4-turbo |
endpoint | N | 与 OpenAI API 兼容的自定义 API 端点 URL。如果未指定,则使用默认的 OpenAI API 端点。当 apiType 设置为 azure 时必填。 | https://api.openai.com/v1、https://example.openai.azure.com/ |
responseCacheTTL | N | 内存响应缓存的生存时间。设置后,相同的请求将从缓存中提供服务,直到过期。 | 10m |
apiType | N | 指定 API 提供商类型。当使用不遵循默认 OpenAI API 端点约定的提供商时必填。 | azure |
apiVersion | N | 要使用的 API 版本。当 apiType 设置为 azure 时必填。 | 2025-04-01-preview |
Azure OpenAI 配置
要配置 OpenAI 组件以连接到 Azure OpenAI,你需要设置以下元数据字段,这些字段对于 Azure 的 API 格式是必需的。
Azure OpenAI 的必填字段
连接到 Azure OpenAI 时,以下字段是必填的:
apiType:必须设置为 azure 以启用 Azure OpenAI 兼容性endpoint:你的 Azure OpenAI 资源端点 URL(例如,https://your-resource.openai.azure.com/)apiVersion:你的 Azure OpenAI 部署的 API 版本(例如,2025-01-01-preview)key:你的 Azure OpenAI API 密钥
从以下网址获取你的配置值:https://ai.azure.com/
Azure OpenAI 组件示例
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: azure-openai
spec:
type: conversation.openai
metadata:
- name: key
value: "your-azure-openai-api-key"
- name: model
value: "gpt-4.1-nano" # Default: gpt-4.1-nano
- name: endpoint
value: "https://your-resource.openai.azure.com/"
- name: apiType
value: "azure"
- name: apiVersion
value: "2025-01-01-preview"
Note
使用 Azure OpenAI 时,endpoint 和 apiVersion 都是必填字段。当 apiType 设置为 azure 时,如果缺少任一字段,组件将返回错误。相关链接