Skip to content

Commit

Permalink
Merge branch 'release-1.15' into jobs-python
Browse files Browse the repository at this point in the history
  • Loading branch information
elena-kolevska authored Feb 13, 2025
2 parents fb56d45 + 0afc299 commit 6811987
Show file tree
Hide file tree
Showing 53 changed files with 2,416 additions and 214 deletions.
4 changes: 2 additions & 2 deletions .github/env/global.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DAPR_CLI_VERSION: 1.15.0-rc.2
DAPR_RUNTIME_VERSION: 1.15.0-rc.5
DAPR_CLI_VERSION: 1.15.0-rc.5
DAPR_RUNTIME_VERSION: 1.15.0-rc.10
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v${DAPR_CLI_VERSION}/install/
DAPR_DEFAULT_IMAGE_REGISTRY: ghcr

Expand Down
2 changes: 1 addition & 1 deletion bindings/python/sdk/batch/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dapr>=1.14.0a,<1.15.0
dapr>=1.15.0rc2
Flask
typing-extensions
werkzeug>=3.0.3 # not directly required, pinned by Snyk to avoid a vulnerability
2 changes: 1 addition & 1 deletion configuration/python/sdk/order-processor/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dapr>=1.14.0a,<1.15.0
dapr>=1.15.0rc2
typing-extensions
99 changes: 99 additions & 0 deletions conversation/javascript/http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Dapr Conversation API (JS 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.

> **Note:** This example leverages HTTP `requests` only.
This quickstart includes one app:

- `index.js`, 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 Node dependencies for conversation
-->

```bash
cd ./conversation
npm install
```

<!-- 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 -->

3. Stop and clean up application processes.

<!-- STEP
name: Stop multi-app run
sleep: 5
-->

```bash
dapr stop -f .
```

<!-- END_STEP -->

## Run the app individually

1. Open a terminal and navigate to the `conversation` app. Install the dependencies if you haven't already.

```bash
cd ./conversation
npm install
```

2. Run the Dapr process alongside the application.

```bash
dapr run --app-id conversation --resources-path ../../../components/ -- npm run start
```

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?
```
39 changes: 39 additions & 0 deletions conversation/javascript/http/conversation/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const conversationComponentName = "echo";

async function main() {
const daprHost = process.env.DAPR_HOST || "http://localhost";
const daprHttpPort = process.env.DAPR_HTTP_PORT || "3500";

const inputBody = {
name: "echo",
inputs: [{ message: "What is dapr?" }],
parameters: {},
metadata: {},
};

const reqURL = `${daprHost}:${daprHttpPort}/v1.0-alpha1/conversation/${conversationComponentName}/converse`;

try {
const response = await fetch(reqURL, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(inputBody),
});

console.log("Input sent: What is dapr?");

const data = await response.json();
const result = data.outputs[0].result;
console.log("Output response:", result);
} catch (error) {
console.error("Error:", error.message);
process.exit(1);
}
}

main().catch((error) => {
console.error("Unhandled error:", error);
process.exit(1);
});
13 changes: 13 additions & 0 deletions conversation/javascript/http/conversation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions conversation/javascript/http/conversation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "conversation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js",
"start:dapr": "dapr run --app-id conversation --resources-path ../../../components/ -- npm start"
},
"keywords": [],
"author": "",
"license": "ISC"
}
8 changes: 8 additions & 0 deletions conversation/javascript/http/dapr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 1
common:
resourcesPath: ../../components/
apps:
- appID: conversation
appDirPath: ./conversation/
daprHTTPPort: 3502
command: ["npm", "run", "start"]
2 changes: 2 additions & 0 deletions conversation/javascript/http/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../docker.mk
include ../../../validate.mk
97 changes: 97 additions & 0 deletions conversation/python/http/README.md
Original file line number Diff line number Diff line change
@@ -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.

> **Note:** This example leverages HTTP `requests` only.
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 ..
```

2. Open a new terminal window and run the multi app run template:

<!-- STEP
name: Run multi app run template
expected_stdout_lines:
- '== APP == INFO:root:Input sent: What is dapr?'
- '== APP == INFO:root: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 == INFO:root:Input sent: What is dapr?
== APP == INFO:root:Output response: What is dapr?
```
31 changes: 31 additions & 0 deletions conversation/python/http/conversation/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import logging
import requests
import os

logging.basicConfig(level=logging.INFO)

base_url = os.getenv('BASE_URL', 'http://localhost') + ':' + os.getenv(
'DAPR_HTTP_PORT', '3500')

CONVERSATION_COMPONENT_NAME = 'echo'

input = {
'name': 'echo',
'inputs': [{'message':'What is dapr?'}],
'parameters': {},
'metadata': {}
}

# Send input to conversation endpoint
result = requests.post(
url='%s/v1.0-alpha1/conversation/%s/converse' % (base_url, CONVERSATION_COMPONENT_NAME),
json=input
)

logging.info('Input sent: What is dapr?')

# Parse conversation output
data = result.json()
output = data["outputs"][0]["result"]

logging.info('Output response: ' + output)
1 change: 1 addition & 0 deletions conversation/python/http/conversation/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
7 changes: 7 additions & 0 deletions conversation/python/http/dapr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 1
common:
resourcesPath: ../../components/
apps:
- appID: conversation
appDirPath: ./conversation/
command: ["python3", "app.py"]
2 changes: 2 additions & 0 deletions conversation/python/http/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../docker.mk
include ../../../validate.mk
2 changes: 1 addition & 1 deletion cryptography/python/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ expected_stdout_lines:
- '== APP == Encrypted the message, got 856 bytes'
- '== APP == Decrypted the message, got 24 bytes'
- '== APP == The secret is "passw0rd"'
- '== APP == Wrote decrypted data to encrypted.out'
- '== APP == Wrote encrypted data to encrypted.out'
- '== APP == Wrote decrypted data to decrypted.out.jpg'
- "Exited App successfully"
expected_stderr_lines:
Expand Down
Loading

0 comments on commit 6811987

Please sign in to comment.