-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.15' into feat-iam-roles-anywhere
- Loading branch information
Showing
28 changed files
with
552 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
daprdocs/content/en/developing-applications/building-blocks/conversation/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
type: docs | ||
title: "Conversation" | ||
linkTitle: "Conversation" | ||
weight: 130 | ||
description: "Utilize prompts with Large Language Models (LLMs)" | ||
--- |
43 changes: 43 additions & 0 deletions
43
...n/developing-applications/building-blocks/conversation/conversation-overview.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
type: docs | ||
title: "Conversation overview" | ||
linkTitle: "Overview" | ||
weight: 1000 | ||
description: "Overview of the conversation API building block" | ||
--- | ||
|
||
{{% alert title="Alpha" color="primary" %}} | ||
The conversation API is currently in [alpha]({{< ref "certification-lifecycle.md#certification-levels" >}}). | ||
{{% /alert %}} | ||
|
||
|
||
Using the Dapr conversation API, you can reduce the complexity of interacting with Large Language Models (LLMs) and enable critical performance and security functionality with features like prompt caching and personally identifiable information (PII) data obfuscation. | ||
|
||
## Features | ||
|
||
### Prompt caching | ||
|
||
To significantly reduce latency and cost, frequent prompts are stored in a cache to be reused, instead of reprocessing the information for every new request. Prompt caching optimizes performance by storing and reusing prompts that are often repeated across multiple API calls. | ||
|
||
### Personally identifiable information (PII) obfuscation | ||
|
||
The PII obfuscation feature identifies and removes any PII from a conversation response. This feature protects your privacy by eliminating sensitive details like names, addresses, phone numbers, or other details that could be used to identify an individual. | ||
|
||
## Try out conversation | ||
|
||
### Quickstarts and tutorials | ||
|
||
Want to put the Dapr conversation API to the test? Walk through the following quickstart and tutorials to see it in action: | ||
|
||
| Quickstart/tutorial | Description | | ||
| ------------------- | ----------- | | ||
| [Conversation quickstart](todo) | . | | ||
|
||
### Start using the conversation API directly in your app | ||
|
||
Want to skip the quickstarts? Not a problem. You can try out the conversation building block directly in your application. After [Dapr is installed]({{< ref "getting-started/_index.md" >}}), you can begin using the conversation API starting with [the how-to guide]({{< ref howto-conversation-layer.md >}}). | ||
|
||
## Next steps | ||
|
||
- [How-To: Converse with an LLM using the conversation API]({{< ref howto-conversation-layer.md >}}) | ||
- [Conversation API components]({{< ref supported-conversation >}}) |
137 changes: 137 additions & 0 deletions
137
...eveloping-applications/building-blocks/conversation/howto-conversation-layer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
--- | ||
type: docs | ||
title: "How-To: Converse with an LLM using the conversation API" | ||
linkTitle: "How-To: Converse" | ||
weight: 2000 | ||
description: "Learn how to abstract the complexities of interacting with large language models" | ||
--- | ||
|
||
{{% alert title="Alpha" color="primary" %}} | ||
The conversation API is currently in [alpha]({{< ref "certification-lifecycle.md#certification-levels" >}}). | ||
{{% /alert %}} | ||
|
||
Let's get started using the [conversation API]({{< ref conversation-overview.md >}}). In this guide, you'll learn how to: | ||
|
||
- Set up one of the available Dapr components (echo) that work with the conversation API. | ||
- Add the conversation client to your application. | ||
|
||
## Set up the conversation component | ||
|
||
Create a new configuration file called `conversation.yaml` and save to a components or config sub-folder in your application directory. | ||
|
||
Select your [preferred conversation component spec]({{< ref supported-conversation >}}) for your `conversation.yaml` file. | ||
|
||
For this scenario, we use a simple echo component. | ||
|
||
```yml | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: echo | ||
spec: | ||
type: conversation.echo | ||
version: v1 | ||
``` | ||
## Connect the conversation client | ||
{{< tabs ".NET" "Go" "Rust" >}} | ||
<!-- .NET --> | ||
{{% codetab %}} | ||
```dotnet | ||
todo | ||
``` | ||
|
||
{{% /codetab %}} | ||
|
||
<!-- Go --> | ||
{{% codetab %}} | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
dapr "github.com/dapr/go-sdk/client" | ||
"log" | ||
) | ||
|
||
func main() { | ||
client, err := dapr.NewClient() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
input := dapr.ConversationInput{ | ||
Message: "hello world", | ||
// Role: nil, // Optional | ||
// ScrubPII: nil, // Optional | ||
} | ||
|
||
fmt.Printf("conversation input: %s\n", input.Message) | ||
|
||
var conversationComponent = "echo" | ||
|
||
request := dapr.NewConversationRequest(conversationComponent, []dapr.ConversationInput{input}) | ||
|
||
resp, err := client.ConverseAlpha1(context.Background(), request) | ||
if err != nil { | ||
log.Fatalf("err: %v", err) | ||
} | ||
|
||
fmt.Printf("conversation output: %s\n", resp.Outputs[0].Result) | ||
} | ||
``` | ||
|
||
{{% /codetab %}} | ||
|
||
<!-- Rust --> | ||
{{% codetab %}} | ||
|
||
```rust | ||
use dapr::client::{ConversationInputBuilder, ConversationRequestBuilder}; | ||
use std::thread; | ||
use std::time::Duration; | ||
|
||
type DaprClient = dapr::Client<dapr::client::TonicClient>; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Sleep to allow for the server to become available | ||
thread::sleep(Duration::from_secs(5)); | ||
|
||
// Set the Dapr address | ||
let address = "https://127.0.0.1".to_string(); | ||
|
||
let mut client = DaprClient::connect(address).await?; | ||
|
||
let input = ConversationInputBuilder::new("hello world").build(); | ||
|
||
let conversation_component = "echo"; | ||
|
||
let request = | ||
ConversationRequestBuilder::new(conversation_component, vec![input.clone()]).build(); | ||
|
||
println!("conversation input: {:?}", input.message); | ||
|
||
let response = client.converse_alpha1(request).await?; | ||
|
||
println!("conversation output: {:?}", response.outputs[0].result); | ||
Ok(()) | ||
} | ||
``` | ||
|
||
{{% /codetab %}} | ||
|
||
{{< /tabs >}} | ||
|
||
|
||
## Next steps | ||
|
||
- [Conversation API reference guide]({{< ref conversation_api.md >}}) | ||
- [Available conversation components]({{< ref supported-conversation >}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.