mirror of https://github.com/dapr/quickstarts.git
Merge branch 'release-1.15' into convo-update
This commit is contained in:
commit
ca8263cc36
|
|
@ -105,7 +105,15 @@ jobs:
|
|||
else
|
||||
pushd $building_block/python/$variant
|
||||
echo "Validating $building_block/python/$variant quickstart"
|
||||
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
|
||||
make validate
|
||||
|
||||
deactivate
|
||||
rm -rf .venv
|
||||
|
||||
popd
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# General
|
||||
.venv
|
||||
venv
|
||||
.env
|
||||
env
|
||||
*.exe
|
||||
*.suo
|
||||
*.user
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
requests
|
||||
Flask
|
||||
uvicorn
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
dapr>=1.15.0rc2
|
||||
dapr>=1.15.0rc3
|
||||
Flask
|
||||
uvicorn
|
||||
typing-extensions
|
||||
werkzeug>=3.0.3 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
requests
|
||||
flask
|
||||
Flask
|
||||
uvicorn
|
||||
urllib3>=2.2.2 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
dapr>=1.15.0rc2
|
||||
dapr>=1.15.0rc3
|
||||
typing-extensions
|
||||
|
|
@ -34,7 +34,7 @@ class Program
|
|||
var inputBody = new
|
||||
{
|
||||
name = "echo",
|
||||
inputs = new[] { new { message = "What is dapr?" } },
|
||||
inputs = new[] { new { content = "What is dapr?" } },
|
||||
parameters = new { },
|
||||
metadata = new { }
|
||||
};
|
||||
|
|
@ -49,7 +49,7 @@ class Program
|
|||
var response = await client.PostAsync(daprUrl, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
Console.WriteLine("Input sent: " + inputBody.inputs[0].message);
|
||||
Console.WriteLine("Input sent: " + inputBody.inputs[0].content);
|
||||
|
||||
var responseBody = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func main() {
|
|||
|
||||
var inputBody = `{
|
||||
"name": "echo",
|
||||
"inputs": [{"message":"What is dapr?"}],
|
||||
"inputs": [{"content":"What is dapr?"}],
|
||||
"parameters": {},
|
||||
"metadata": {}
|
||||
}`
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
module conversation
|
||||
|
||||
go 1.23.5
|
||||
go 1.23.6
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ func main() {
|
|||
}
|
||||
|
||||
input := dapr.ConversationInput{
|
||||
Message: "What is dapr?",
|
||||
Content: "What is dapr?",
|
||||
// Role: nil, // Optional
|
||||
// ScrubPII: nil, // Optional
|
||||
}
|
||||
|
||||
fmt.Println("Input sent:", input.Message)
|
||||
fmt.Println("Input sent:", input.Content)
|
||||
|
||||
var conversationComponent = "echo"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
module conversation
|
||||
|
||||
go 1.23.5
|
||||
go 1.23.6
|
||||
|
||||
require github.com/dapr/go-sdk v1.12.0-rc.1
|
||||
require github.com/dapr/go-sdk v1.12.0-rc.2
|
||||
|
||||
require (
|
||||
github.com/dapr/dapr v1.15.0-rc.1 // indirect
|
||||
github.com/dapr/dapr v1.15.0-rc.18 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
go.opentelemetry.io/otel v1.32.0 // indirect
|
||||
golang.org/x/net v0.32.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
|
||||
google.golang.org/grpc v1.68.1 // indirect
|
||||
google.golang.org/protobuf v1.35.2 // indirect
|
||||
go.opentelemetry.io/otel v1.34.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250224174004-546df14abb99 // indirect
|
||||
google.golang.org/grpc v1.70.0 // indirect
|
||||
google.golang.org/protobuf v1.36.5 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/dapr/dapr v1.15.0-rc.1 h1:7JP3zSannxQwV27A9pPR2b/DSNmgcSjJOhRDwM4eFpQ=
|
||||
github.com/dapr/dapr v1.15.0-rc.1/go.mod h1:SycZrBWgfmog+C5T4p0X6VIpnREQ3xajrYxdih+gn9w=
|
||||
github.com/dapr/dapr v1.15.0-rc.18 h1:Y4lxefmhhlm2AM+zCEdvcDBe4BpqISBIzPRcS0ak1pY=
|
||||
github.com/dapr/dapr v1.15.0-rc.18/go.mod h1:556Dd0N1wl6hWzVj9POYWa2D7dSlJ06MAbXNbvbxDIo=
|
||||
github.com/dapr/go-sdk v1.12.0-rc.1 h1:KK92BahLmwGowVRjFxsjySl25M6wwuJSjesYIIF6h0c=
|
||||
github.com/dapr/go-sdk v1.12.0-rc.1/go.mod h1:OxCF7Eh8IZvmNv6Euk+mnLrehJyLQRYb4TAU7uHq7Ow=
|
||||
github.com/dapr/go-sdk v1.12.0-rc.2 h1:fHpS9FwjEbPTZvR8PtnJM9N6hRCkqGpDbk3Xjjl28oc=
|
||||
github.com/dapr/go-sdk v1.12.0-rc.2/go.mod h1:RpZJ/pNfODlyk6x+whdtCrFI1/o0X67LCSwZeAZa64U=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
|
|
@ -24,20 +28,34 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
|||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
|
||||
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
|
||||
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
|
||||
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
|
||||
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
|
||||
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1:hgh8P4EuoxpsuKMXX/To36nOFD7vixReXgn8lPGnt+o=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250224174004-546df14abb99 h1:ZSlhAUqC4r8TPzqLXQ0m3upBNZeF+Y8jQ3c4CR3Ujms=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250224174004-546df14abb99/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
|
||||
google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0=
|
||||
google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw=
|
||||
google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ=
|
||||
google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ async function main() {
|
|||
|
||||
const inputBody = {
|
||||
name: "echo",
|
||||
inputs: [{ message: "What is dapr?" }],
|
||||
inputs: [{ content: "What is dapr?" }],
|
||||
parameters: {},
|
||||
metadata: {},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ CONVERSATION_COMPONENT_NAME = 'echo'
|
|||
|
||||
input = {
|
||||
'name': 'echo',
|
||||
'inputs': [{'message':'What is dapr?'}],
|
||||
'inputs': [{'content':'What is dapr?'}],
|
||||
'parameters': {},
|
||||
'metadata': {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
# Dapr Conversation API (Python HTTP)
|
||||
|
||||
In this quickstart, you'll send an input to a mock Large Language Model (LLM) using Dapr's Conversation API. This API is responsible for providing one consistent API entry point to talk to underlying LLM providers.
|
||||
|
||||
Visit [this](https://v1-15.docs.dapr.io/developing-applications/building-blocks/conversation/conversation-overview/) link for more information about Dapr and the Conversation API.
|
||||
|
||||
This quickstart includes one app:
|
||||
|
||||
- `app.py`, responsible for sending an input to the underlying LLM and retrieving an output.
|
||||
|
||||
## Run the app with the template file
|
||||
|
||||
This section shows how to run the application using the [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`.
|
||||
|
||||
This example uses the default LLM Component provided by Dapr which simply echoes the input provided, for testing purposes. Here are other [supported Conversation components](https://v1-15.docs.dapr.io/reference/components-reference/supported-conversation/).
|
||||
|
||||
1. Install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Python dependencies
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd ./conversation
|
||||
pip3 install -r requirements.txt
|
||||
cd ..
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Open a new terminal window and run the multi app run template:
|
||||
|
||||
<!-- STEP
|
||||
name: Run multi app run template
|
||||
expected_stdout_lines:
|
||||
- '== APP - conversation == Input sent: What is dapr?'
|
||||
- '== APP - conversation == Output response: What is dapr?'
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
match_order: none
|
||||
background: true
|
||||
sleep: 15
|
||||
timeout_seconds: 30
|
||||
-->
|
||||
|
||||
```bash
|
||||
dapr run -f .
|
||||
```
|
||||
|
||||
The terminal console output should look similar to this, where:
|
||||
|
||||
- The app sends an input `What is dapr?` to the `echo` Component mock LLM.
|
||||
- The mock LLM echoes `What is dapr?`.
|
||||
|
||||
```text
|
||||
== APP - conversation == Input sent: What is dapr?
|
||||
== APP - conversation == Output response: What is dapr?
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Stop and clean up application processes.
|
||||
|
||||
<!-- STEP
|
||||
name: Stop multi-app run
|
||||
sleep: 5
|
||||
-->
|
||||
|
||||
```bash
|
||||
dapr stop -f .
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
## Run the app with the Dapr CLI
|
||||
|
||||
1. Install dependencies:
|
||||
|
||||
Open a terminal and run:
|
||||
|
||||
```bash
|
||||
cd ./conversation
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
2. Run the application:
|
||||
|
||||
```bash
|
||||
dapr run --app-id conversation --resources-path ../../../components -- python3 app.py
|
||||
```
|
||||
|
||||
You should see the output:
|
||||
|
||||
```bash
|
||||
== APP == Input sent: What is dapr?
|
||||
== APP == Output response: What is dapr?
|
||||
```
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# ------------------------------------------------------------
|
||||
# Copyright 2025 The Dapr Authors
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ------------------------------------------------------------
|
||||
from dapr.clients import DaprClient
|
||||
from dapr.clients.grpc._request import ConversationInput
|
||||
|
||||
with DaprClient() as d:
|
||||
inputs = [
|
||||
ConversationInput(content="What is dapr?", role='user', scrub_pii=True),
|
||||
]
|
||||
|
||||
metadata = {
|
||||
'model': 'modelname',
|
||||
'key': 'authKey',
|
||||
'cacheTTL': '10m',
|
||||
}
|
||||
|
||||
print('Input sent: What is dapr?')
|
||||
|
||||
response = d.converse_alpha1(
|
||||
name='echo', inputs=inputs, temperature=0.7, context_id='chat-123', metadata=metadata
|
||||
)
|
||||
|
||||
for output in response.outputs:
|
||||
print(f'Output response: {output.result}')
|
||||
|
|
@ -0,0 +1 @@
|
|||
dapr>=1.15.0rc3
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
version: 1
|
||||
common:
|
||||
resourcesPath: ../../components/
|
||||
apps:
|
||||
- appID: conversation
|
||||
appDirPath: ./conversation/
|
||||
command: ["python3", "app.py"]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
include ../../../docker.mk
|
||||
include ../../../validate.mk
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
dapr>=1.14
|
||||
dapr>=1.15.0rc3
|
||||
typing-extensions
|
||||
|
|
@ -18,9 +18,13 @@ This quickstart includes two apps:
|
|||
|
||||
## Install dependencies
|
||||
|
||||
<!-- STEP
|
||||
name: Install python dependencies
|
||||
-->
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
<!-- END_STEP -->
|
||||
|
||||
## Run all apps with multi-app run template file
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
Flask
|
||||
dapr
|
||||
uvicorn
|
||||
dapr>=1.15.0rc3
|
||||
cloudevents
|
||||
werkzeug>=3.0.3 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
dapr>=1.15.0rc2
|
||||
dapr>=1.15.0rc3
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
fastapi
|
||||
dapr-ext-fastapi-dev
|
||||
dapr-ext-fastapi>=1.15.0rc3
|
||||
cloudevents
|
||||
uvicorn
|
||||
anyio>=4.4.0 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Flask
|
||||
dapr>=1.15.0rc2
|
||||
dapr>=1.15.0rc3
|
||||
cloudevents
|
||||
uvicorn
|
||||
typing-extensions
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
dapr>=1.15.0rc2
|
||||
dapr>=1.15.0rc3
|
||||
typing-extensions
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
Flask
|
||||
dapr>=1.15.0rc2
|
||||
uvicorn
|
||||
dapr>=1.15.0rc3
|
||||
typing-extensions
|
||||
werkzeug>=3.0.3 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
dapr>=1.15.0rc2
|
||||
dapr>=1.15.0rc3
|
||||
typing-extensions
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
dapr-ext-workflow>=0.6.0rc2
|
||||
dapr>=1.15.0rc2
|
||||
dapr-ext-workflow>=1.15.0rc1
|
||||
dapr>=1.15.0rc3
|
||||
Loading…
Reference in New Issue