You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: daprdocs/content/en/developing-applications/building-blocks/conversation/conversation-overview.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,12 @@ Dapr's conversation API reduces the complexity of securely and reliably interact
14
14
15
15
<imgsrc="/images/conversation-overview.png"width=800alt="Diagram showing the flow of a user's app communicating with Dapr's LLM components.">
16
16
17
-
In additon to enabling critical performance and security functionality (like [prompt caching]({{% ref "#prompt-caching" %}}) and [PII scrubbing]({{% ref "#personally-identifiable-information-pii-obfuscation" %}})), you can also pair the conversation API with Dapr functionalities, like:
17
+
In addition to enabling critical performance and security functionality (like [prompt caching]({{% ref "#prompt-caching" %}}) and [PII scrubbing]({{% ref "#personally-identifiable-information-pii-obfuscation" %}})), the conversation API also provides:
18
+
19
+
-**Tool calling capabilities** that allow LLMs to interact with external functions and APIs, enabling more sophisticated AI applications
20
+
-**OpenAI-compatible interface** for seamless integration with existing AI workflows and tools
21
+
22
+
You can also pair the conversation API with Dapr functionalities, like:
18
23
- Resiliency circuit breakers and retries to circumvent limit and token errors, or
19
24
- Middleware to authenticate requests coming to and from the LLM
20
25
@@ -45,6 +50,17 @@ The PII scrubber obfuscates the following user information:
45
50
- SHA-256 hex
46
51
- MD5 hex
47
52
53
+
### Tool calling support
54
+
55
+
The conversation API supports advanced tool calling capabilities that allow LLMs to interact with external functions and APIs. This enables you to build sophisticated AI applications that can:
56
+
57
+
- Execute custom functions based on user requests
58
+
- Integrate with external services and databases
59
+
- Provide dynamic, context-aware responses
60
+
- Create multi-step workflows and automation
61
+
62
+
Tool calling follows [OpenAI's function calling format](https://platform.openai.com/docs/guides/function-calling), making it easy to integrate with existing AI development workflows and tools.
63
+
48
64
## Demo
49
65
50
66
Watch the demo presented during [Diagrid's Dapr v1.15 celebration](https://www.diagrid.io/videos/dapr-1-15-deep-dive) to see how the conversation API works using the .NET SDK.
Copy file name to clipboardExpand all lines: daprdocs/content/en/operations/support/alpha-beta-apis.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,8 +17,7 @@ description: "List of current alpha and beta APIs"
17
17
| Cryptography |[Crypto proto](https://github.com/dapr/dapr/blob/5aba3c9aa4ea9b3f388df125f9c66495b43c5c9e/dapr/proto/runtime/v1/dapr.proto#L118)|`v1.0-alpha1/crypto`| The cryptography API enables you to perform **high level** cryptography operations for encrypting and decrypting messages. |[Cryptography API]({{% ref "cryptography-overview.md" %}}) | v1.11 |
18
18
| Jobs |[Jobs proto](https://github.com/dapr/dapr/blob/master/dapr/proto/runtime/v1/dapr.proto#L212-219)|`v1.0-alpha1/jobs`| The jobs API enables you to schedule and orchestrate jobs. |[Jobs API]({{% ref "jobs-overview.md" %}}) | v1.14 |
19
19
| Streaming Subscription |[Streaming Subscription proto](https://github.com/dapr/dapr/blob/310c83140b2f0c3cb7d2bef19624df88af3e8e0a/dapr/proto/runtime/v1/dapr.proto#L454)| N/A | Subscription is defined in the application code. Streaming subscriptions are dynamic, meaning they allow for adding or removing subscriptions at runtime. |[Streaming Subscription API]({{% ref "subscription-methods/#streaming-subscriptions" %}}) | v1.14 |
20
-
| Conversation |[Conversation proto](https://github.com/dapr/dapr/blob/master/dapr/proto/runtime/v1/dapr.proto#L221-222)|`v1.0-alpha1/conversation`| Converse between different large language models using the conversation API. |[Conversation API]({{% ref "conversation-overview.md" %}}) | v1.15 |
21
-
20
+
| Conversation |[Conversation proto](https://github.com/dapr/dapr/blob/master/dapr/proto/runtime/v1/dapr.proto#L226)|`v1.0-alpha2/conversation`| Converse between different large language models using the conversation API. |[Conversation API]({{% ref "conversation-overview.md" %}}) | v1.15 |
The conversation API is currently in [alpha]({{% ref "certification-lifecycle.md#certification-levels" %}}).
11
11
{{% /alert %}}
12
12
13
-
Dapr provides an API to interact with Large Language Models (LLMs) and enables critical performance and security functionality with features like prompt caching and PII data obfuscation.
13
+
Dapr provides an API to interact with Large Language Models (LLMs) and enables critical performance and security functionality with features like prompt caching, PII data obfuscation, and tool calling capabilities.
14
+
15
+
Tool calling follow's OpenAI's function calling format, making it easy to integrate with existing AI development workflows and tools.
14
16
15
17
## Converse
16
18
17
-
This endpoint lets you converse with LLMs.
19
+
This endpoint lets you converse with LLMs using the Alpha2 version of the API, which provides enhanced tool calling support and alignment with OpenAI's interface.
18
20
19
21
```
20
-
POST http://localhost:<daprPort>/v1.0-alpha1/conversation/<llm-name>/converse
22
+
POST http://localhost:<daprPort>/v1.0-alpha2/conversation/<llm-name>/converse
21
23
```
22
24
23
25
### URL parameters
@@ -30,34 +32,117 @@ POST http://localhost:<daprPort>/v1.0-alpha1/conversation/<llm-name>/converse
30
32
31
33
| Field | Description |
32
34
| --------- | ----------- |
35
+
|`name`| The name of the conversation component. Required |
36
+
|`contextId`| The ID of an existing chat (like in ChatGPT). Optional |
33
37
|`inputs`| Inputs for the conversation. Multiple inputs at one time are supported. Required |
34
-
|`cacheTTL`| A time-to-live value for a prompt cache to expire. Uses Golang duration format. Optional |
35
-
|`scrubPII`| A boolean value to enable obfuscation of sensitive information returning from the LLM. Set this value if all PII (across contents) in the request needs to be scrubbed. Optional |
36
-
|`temperature`| A float value to control the temperature of the model. Used to optimize for consistency and creativity. Optional |
38
+
|`parameters`| Parameters for all custom fields. Optional |
37
39
|`metadata`|[Metadata](#metadata) passed to conversation components. Optional |
40
+
|`scrubPii`| A boolean value to enable obfuscation of sensitive information returning from the LLM. Optional |
41
+
|`temperature`| A float value to control the temperature of the model. Used to optimize for consistency (0) or creativity (1). Optional |
42
+
|`tools`| Tools register the tools available to be used by the LLM during the conversation. Optional |
43
+
|`toolChoice`| Controls which (if any) tool is called by the model. Values: `auto`, `required`, or specific tool name. Defaults to `auto` if tools are present. Optional |
38
44
39
45
#### Input body
40
46
41
47
| Field | Description |
42
48
| --------- | ----------- |
43
-
|`content`| The message content to send to the LLM. Required |
44
-
|`role`| The role for the LLM to assume. Possible values: 'user', 'tool', 'assistant' |
45
-
|`scrubPII`| A boolean value to enable obfuscation of sensitive information present in the content field. Set this value if PII for this specific content needs to be scrubbed exclusively. Optional |
49
+
|`messages`| Array of conversation messages. Required |
50
+
|`scrubPii`| A boolean value to enable obfuscation of sensitive information present in the content field. Optional |
51
+
52
+
#### Message types
53
+
54
+
The API supports different message types:
55
+
56
+
-**`ofDeveloper`**: Developer role messages with optional name and content
57
+
-**`ofSystem`**: System role messages with optional name and content
58
+
-**`ofUser`**: User role messages with optional name and content
59
+
-**`ofAssistant`**: Assistant role messages with optional name, content, and tool calls
60
+
-**`ofTool`**: Tool role messages with tool ID, name, and content
61
+
62
+
#### Tool calling
63
+
64
+
Tools can be defined using the `tools` field with function definitions:
65
+
66
+
| Field | Description |
67
+
| --------- | ----------- |
68
+
|`function.name`| The name of the function to be called. Required |
69
+
|`function.description`| A description of what the function does. Optional |
70
+
|`function.parameters`| JSON Schema object describing the function parameters. Optional |
46
71
47
-
### Request content example
72
+
### Request content examples
73
+
74
+
#### Basic conversation
48
75
49
76
```json
50
77
REQUEST = {
51
-
"inputs": [
52
-
{
53
-
"content": "What is Dapr?",
54
-
"role": "user", // Optional
55
-
"scrubPII": "true", // Optional. Will obfuscate any sensitive information found in the content field
78
+
"name": "openai",
79
+
"inputs": [{
80
+
"messages": [{
81
+
"of_user": {
82
+
"content": [{
83
+
"text": "What is Dapr?"
84
+
}]
85
+
}
86
+
}]
87
+
}],
88
+
"parameters": {},
89
+
"metadata": {}
90
+
}
91
+
```
92
+
93
+
#### Conversation with tool calling
94
+
95
+
```json
96
+
{
97
+
"name": "openai",
98
+
"inputs": [{
99
+
"messages": [{
100
+
"of_user": {
101
+
"content": [{
102
+
"text": "What is the weather like in San Francisco in celsius?"
"description": "Get the current weather for a location",
128
+
"parameters": {
129
+
"type": "object",
130
+
"properties": {
131
+
"location": {
132
+
"type": "string",
133
+
"description": "The city and state, e.g. San Francisco, CA"
134
+
},
135
+
"unit": {
136
+
"type": "string",
137
+
"enum": ["celsius", "fahrenheit"],
138
+
"description": "The temperature unit to use"
139
+
}
140
+
},
141
+
"required": ["location"]
142
+
}
143
+
}
144
+
}],
145
+
"tool_choice": "auto"
61
146
}
62
147
```
63
148
@@ -71,21 +156,62 @@ Code | Description
71
156
72
157
### Response content
73
158
159
+
#### Basic conversation response
160
+
74
161
```json
75
-
RESPONSE = {
76
-
"outputs": {
77
-
{
78
-
"result": "Dapr is distribution application runtime ...",
79
-
"parameters": {},
80
-
},
81
-
{
82
-
"result": "Dapr can help developers ...",
83
-
"parameters": {},
84
-
}
85
-
},
162
+
RESPONSE = {
163
+
"outputs": [{
164
+
"choices": [{
165
+
"finish_reason": "stop",
166
+
"index": 0,
167
+
"message": {
168
+
"content": "Dapr is a distributed application runtime that makes it easy for developers to build resilient, stateless and stateful applications that run on the cloud and edge.",
The `tool_choice` is an optional parameter that controls how the model can use available tools:
202
+
203
+
-**`auto`**: The model can pick between generating a message or calling one or more tools (default when tools are present)
204
+
-**`required`**: Requires one or more functions to be called
205
+
-**`{tool_name}`**: Forces the model to call a specific tool by name
206
+
207
+
## Legacy Alpha1 API
208
+
209
+
The previous Alpha1 version of the API is still supported for backward compatibility but is deprecated. For new implementations, use the Alpha2 version described above.
210
+
211
+
```
212
+
POST http://localhost:<daprPort>/v1.0-alpha1/conversation/<llm-name>/converse
213
+
```
214
+
89
215
## Next steps
90
216
91
217
-[Conversation API overview]({{% ref conversation-overview.md %}})
0 commit comments