Skip to content

Commit 6811987

Browse files
Merge branch 'release-1.15' into jobs-python
2 parents fb56d45 + 0afc299 commit 6811987

File tree

53 files changed

+2416
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2416
-214
lines changed

.github/env/global.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
DAPR_CLI_VERSION: 1.15.0-rc.2
2-
DAPR_RUNTIME_VERSION: 1.15.0-rc.5
1+
DAPR_CLI_VERSION: 1.15.0-rc.5
2+
DAPR_RUNTIME_VERSION: 1.15.0-rc.10
33
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v${DAPR_CLI_VERSION}/install/
44
DAPR_DEFAULT_IMAGE_REGISTRY: ghcr
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dapr>=1.14.0a,<1.15.0
1+
dapr>=1.15.0rc2
22
Flask
33
typing-extensions
44
werkzeug>=3.0.3 # not directly required, pinned by Snyk to avoid a vulnerability
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
dapr>=1.14.0a,<1.15.0
1+
dapr>=1.15.0rc2
22
typing-extensions
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Dapr Conversation API (JS HTTP)
2+
3+
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.
4+
5+
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.
6+
7+
> **Note:** This example leverages HTTP `requests` only.
8+
9+
This quickstart includes one app:
10+
11+
- `index.js`, responsible for sending an input to the underlying LLM and retrieving an output.
12+
13+
## Run the app with the template file
14+
15+
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 .`.
16+
17+
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/).
18+
19+
1. Install dependencies:
20+
21+
<!-- STEP
22+
name: Install Node dependencies for conversation
23+
-->
24+
25+
```bash
26+
cd ./conversation
27+
npm install
28+
```
29+
30+
<!-- END_STEP -->
31+
32+
2. Open a new terminal window and run the multi app run template:
33+
34+
<!-- STEP
35+
name: Run multi app run template
36+
expected_stdout_lines:
37+
- '== APP - conversation == Input sent: What is dapr?'
38+
- '== APP - conversation == Output response: What is dapr?'
39+
expected_stderr_lines:
40+
output_match_mode: substring
41+
match_order: none
42+
background: true
43+
sleep: 15
44+
timeout_seconds: 30
45+
-->
46+
47+
```bash
48+
dapr run -f .
49+
```
50+
51+
The terminal console output should look similar to this, where:
52+
53+
- The app sends an input `What is dapr?` to the `echo` Component mock LLM.
54+
- The mock LLM echoes `What is dapr?`.
55+
56+
```text
57+
== APP - conversation == Input sent: What is dapr?
58+
== APP - conversation == Output response: What is dapr?
59+
```
60+
61+
<!-- END_STEP -->
62+
63+
3. Stop and clean up application processes.
64+
65+
<!-- STEP
66+
name: Stop multi-app run
67+
sleep: 5
68+
-->
69+
70+
```bash
71+
dapr stop -f .
72+
```
73+
74+
<!-- END_STEP -->
75+
76+
## Run the app individually
77+
78+
1. Open a terminal and navigate to the `conversation` app. Install the dependencies if you haven't already.
79+
80+
```bash
81+
cd ./conversation
82+
npm install
83+
```
84+
85+
2. Run the Dapr process alongside the application.
86+
87+
```bash
88+
dapr run --app-id conversation --resources-path ../../../components/ -- npm run start
89+
```
90+
91+
The terminal console output should look similar to this, where:
92+
93+
- The app sends an input `What is dapr?` to the `echo` Component mock LLM.
94+
- The mock LLM echoes `What is dapr?`.
95+
96+
```text
97+
== APP - conversation == Input sent: What is dapr?
98+
== APP - conversation == Output response: What is dapr?
99+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const conversationComponentName = "echo";
2+
3+
async function main() {
4+
const daprHost = process.env.DAPR_HOST || "http://localhost";
5+
const daprHttpPort = process.env.DAPR_HTTP_PORT || "3500";
6+
7+
const inputBody = {
8+
name: "echo",
9+
inputs: [{ message: "What is dapr?" }],
10+
parameters: {},
11+
metadata: {},
12+
};
13+
14+
const reqURL = `${daprHost}:${daprHttpPort}/v1.0-alpha1/conversation/${conversationComponentName}/converse`;
15+
16+
try {
17+
const response = await fetch(reqURL, {
18+
method: "POST",
19+
headers: {
20+
"Content-Type": "application/json",
21+
},
22+
body: JSON.stringify(inputBody),
23+
});
24+
25+
console.log("Input sent: What is dapr?");
26+
27+
const data = await response.json();
28+
const result = data.outputs[0].result;
29+
console.log("Output response:", result);
30+
} catch (error) {
31+
console.error("Error:", error.message);
32+
process.exit(1);
33+
}
34+
}
35+
36+
main().catch((error) => {
37+
console.error("Unhandled error:", error);
38+
process.exit(1);
39+
});

conversation/javascript/http/conversation/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "conversation",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"type": "module",
7+
"scripts": {
8+
"start": "node index.js",
9+
"start:dapr": "dapr run --app-id conversation --resources-path ../../../components/ -- npm start"
10+
},
11+
"keywords": [],
12+
"author": "",
13+
"license": "ISC"
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 1
2+
common:
3+
resourcesPath: ../../components/
4+
apps:
5+
- appID: conversation
6+
appDirPath: ./conversation/
7+
daprHTTPPort: 3502
8+
command: ["npm", "run", "start"]

conversation/javascript/http/makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include ../../../docker.mk
2+
include ../../../validate.mk

conversation/python/http/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Dapr Conversation API (Python HTTP)
2+
3+
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.
4+
5+
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.
6+
7+
> **Note:** This example leverages HTTP `requests` only.
8+
9+
This quickstart includes one app:
10+
11+
- `app.py`, responsible for sending an input to the underlying LLM and retrieving an output.
12+
13+
## Run the app with the template file
14+
15+
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 .`.
16+
17+
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/).
18+
19+
1. Install dependencies:
20+
21+
<!-- STEP
22+
name: Install Python dependencies
23+
-->
24+
25+
```bash
26+
cd ./conversation
27+
pip3 install -r requirements.txt
28+
cd ..
29+
```
30+
31+
2. Open a new terminal window and run the multi app run template:
32+
33+
<!-- STEP
34+
name: Run multi app run template
35+
expected_stdout_lines:
36+
- '== APP == INFO:root:Input sent: What is dapr?'
37+
- '== APP == INFO:root:Output response: What is dapr?'
38+
expected_stderr_lines:
39+
output_match_mode: substring
40+
match_order: none
41+
background: true
42+
sleep: 15
43+
timeout_seconds: 30
44+
-->
45+
46+
```bash
47+
dapr run -f .
48+
```
49+
50+
The terminal console output should look similar to this, where:
51+
52+
- The app sends an input `What is dapr?` to the `echo` Component mock LLM.
53+
- The mock LLM echoes `What is dapr?`.
54+
55+
```text
56+
== APP - conversation == Input sent: What is dapr?
57+
== APP - conversation == Output response: What is dapr?
58+
```
59+
60+
<!-- END_STEP -->
61+
62+
2. Stop and clean up application processes.
63+
64+
<!-- STEP
65+
name: Stop multi-app run
66+
sleep: 5
67+
-->
68+
69+
```bash
70+
dapr stop -f .
71+
```
72+
73+
<!-- END_STEP -->
74+
75+
## Run the app with the Dapr CLI
76+
77+
1. Install dependencies:
78+
79+
Open a terminal and run:
80+
81+
```bash
82+
cd ./conversation
83+
pip3 install -r requirements.txt
84+
```
85+
86+
2. Run the application:
87+
88+
```bash
89+
dapr run --app-id conversation --resources-path ../../../components -- python3 app.py
90+
```
91+
92+
You should see the output:
93+
94+
```bash
95+
== APP == INFO:root:Input sent: What is dapr?
96+
== APP == INFO:root:Output response: What is dapr?
97+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import logging
2+
import requests
3+
import os
4+
5+
logging.basicConfig(level=logging.INFO)
6+
7+
base_url = os.getenv('BASE_URL', 'http://localhost') + ':' + os.getenv(
8+
'DAPR_HTTP_PORT', '3500')
9+
10+
CONVERSATION_COMPONENT_NAME = 'echo'
11+
12+
input = {
13+
'name': 'echo',
14+
'inputs': [{'message':'What is dapr?'}],
15+
'parameters': {},
16+
'metadata': {}
17+
}
18+
19+
# Send input to conversation endpoint
20+
result = requests.post(
21+
url='%s/v1.0-alpha1/conversation/%s/converse' % (base_url, CONVERSATION_COMPONENT_NAME),
22+
json=input
23+
)
24+
25+
logging.info('Input sent: What is dapr?')
26+
27+
# Parse conversation output
28+
data = result.json()
29+
output = data["outputs"][0]["result"]
30+
31+
logging.info('Output response: ' + output)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests

conversation/python/http/dapr.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 1
2+
common:
3+
resourcesPath: ../../components/
4+
apps:
5+
- appID: conversation
6+
appDirPath: ./conversation/
7+
command: ["python3", "app.py"]

conversation/python/http/makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include ../../../docker.mk
2+
include ../../../validate.mk

cryptography/python/sdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ expected_stdout_lines:
6060
- '== APP == Encrypted the message, got 856 bytes'
6161
- '== APP == Decrypted the message, got 24 bytes'
6262
- '== APP == The secret is "passw0rd"'
63-
- '== APP == Wrote decrypted data to encrypted.out'
63+
- '== APP == Wrote encrypted data to encrypted.out'
6464
- '== APP == Wrote decrypted data to decrypted.out.jpg'
6565
- "Exited App successfully"
6666
expected_stderr_lines:

0 commit comments

Comments
 (0)