Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jobs API - Python HTTP Quickstart #1159

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
eab9ad9
fix: configuration/python/http/order-processor/requirements.txt to re…
snyk-bot Jun 18, 2024
0b3c59f
fix: pub_sub/python/sdk/order-processor-fastapi/requirements.txt to r…
snyk-bot Jun 25, 2024
4de6f45
helloworld: add terminal to node app for vscode
jseguillon Jan 2, 2025
405b113
chore: bump runtime version to rc.2 (#1126)
mikeee Jan 14, 2025
a273031
chore: cleanup & unify workflows and bump kind version (#1127)
mikeee Jan 14, 2025
cf8397a
Creating Conversation folder
rochabr Jan 14, 2025
61390f6
Modernized and updated Workflow .NET quickstart to use latest best pr…
WhitWaldo Jan 15, 2025
7cca26b
Updated Dapr package version to use latest RC02
WhitWaldo Jan 16, 2025
e87f407
COnverstaion API
rochabr Jan 20, 2025
46658b1
add python-sdk in cryptography (#1093)
KentHsu Jan 14, 2025
6395fad
Fixing Conversation HTTP example for RC5
rochabr Jan 21, 2025
2f2c0b5
Fixing Conversation SDK example for RC5
rochabr Jan 21, 2025
e2b6a48
Update conversation.go
rochabr Jan 21, 2025
984c9c5
Update go.mod
rochabr Jan 21, 2025
a75d653
Update go.mod
rochabr Jan 21, 2025
fcf85cf
fix: updates CLI and runtime version to fix tests (#1138)
mikeee Jan 21, 2025
8d2c7ab
Merge branch 'dapr:release-1.15' into release-1.15
alicejgibbons Jan 21, 2025
b8ef1c0
Tests updates
alicejgibbons Jan 18, 2025
dcf1f9f
HTTP csharp jobs quickstart
alicejgibbons Jan 20, 2025
ea48818
Finishing conversation sdk and fixing components path
rochabr Jan 21, 2025
59b885c
Finishing conversation sdk and fixing components path
rochabr Jan 21, 2025
92a7033
Update conversation/go/http/README.md
rochabr Jan 21, 2025
3de34ba
fix: bump python crypto dep to >=1.14
mikeee Jan 22, 2025
796f7d7
fix: modify actors/cs test assertion
mikeee Jan 22, 2025
6cfd606
fix: define update deps for python wf quickstart
mikeee Jan 22, 2025
e62e65c
fix(test): typo in existing quickstart validation
mikeee Jan 22, 2025
878ca0f
fix: update python WF dep names
mikeee Jan 22, 2025
d0f825b
Merge pull request #1141 from mikeee/fix/tests-on-release
paulyuk Jan 22, 2025
bc6354e
Update global.env with Dapr CLI 1.15.0-rc.2
paulyuk Jan 22, 2025
ce9e3b5
Merge branch 'release-1.15' into release-1.15
mikeee Jan 23, 2025
8ad878f
Merge branch 'release-1.15' into workflow-dotnet
mikeee Jan 23, 2025
97476b1
Merge branch 'release-1.15' into release-1.15-a
mikeee Jan 23, 2025
695cec4
Update conversation/go/sdk/dapr.yaml
rochabr Jan 23, 2025
680cf29
Update conversation/go/http/dapr.yaml
rochabr Jan 23, 2025
5c32644
Update conversation/go/sdk/dapr.yaml
rochabr Jan 23, 2025
9820c13
Updating sleep and timeout times
rochabr Jan 23, 2025
0a8dc8b
Update conversation/go/sdk/README.md
rochabr Jan 23, 2025
ae9c2fb
Update conversation/go/http/README.md
rochabr Jan 23, 2025
63c2247
Update conversation/go/http/README.md
rochabr Jan 23, 2025
e47efba
Update conversation/go/sdk/README.md
rochabr Jan 23, 2025
834ab60
Update conversation/go/http/README.md
rochabr Jan 23, 2025
b4f0d21
Comversation README improvements
rochabr Jan 23, 2025
22ffde8
Merge pull request #1136 from alicejgibbons/release-1.15-a
paulyuk Jan 23, 2025
60f7f60
Merge pull request #1130 from WhitWaldo/workflow-dotnet
paulyuk Jan 23, 2025
a54d89d
Merge pull request #1125 from jseguillon/feat/vscode-terminal-nodeapp
paulyuk Jan 23, 2025
dda7f50
Merge branch 'release-1.15' into release-1.15
rochabr Jan 23, 2025
1abe940
Update conversation/go/http/README.md
rochabr Jan 23, 2025
8cd76a6
Update conversation/go/sdk/README.md
rochabr Jan 23, 2025
51b7ba5
Update conversation/go/sdk/README.md
rochabr Jan 23, 2025
5e29784
removing files from PR
rochabr Jan 23, 2025
1a01945
Merge pull request #1041 from dapr/snyk-fix-cb381e7559c391f0f4d7f1eb4…
paulyuk Jan 23, 2025
a60059f
Merge pull request #1033 from dapr/snyk-fix-c238b6cbdcc4a882f25690937…
paulyuk Jan 23, 2025
7000a78
Merge pull request #1128 from rochabr/release-1.15
paulyuk Jan 23, 2025
194d2b9
Csharp conversation quickstarts
alicejgibbons Jan 23, 2025
7830ad8
Merge pull request #1144 from alicejgibbons/alicejgibbons/csharp-http…
paulyuk Jan 24, 2025
988bde6
Merge branch 'master' of github.com:dapr/quickstarts into release-1.15
paulyuk Jan 24, 2025
7dfc415
Merge pull request #1145 from paulyuk/release-1.15
paulyuk Jan 24, 2025
1d7473a
Python Jobs API - HTTP quickstart
rochabr Jan 29, 2025
68165ac
splitting header
rochabr Feb 5, 2025
519713b
removing flask, fixing print statements
rochabr Feb 5, 2025
bece7f8
Merge branch 'master' into jobs-python
rochabr Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/env/global.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
DAPR_CLI_VERSION: 1.14.1
DAPR_RUNTIME_VERSION: 1.14.4
DAPR_CLI_VERSION: 1.15.0-rc.2
DAPR_RUNTIME_VERSION: 1.15.0-rc.5
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v${DAPR_CLI_VERSION}/install/
DAPR_DEFAULT_IMAGE_REGISTRY: ghcr

MACOS_PYTHON_VERSION: 3.10

PODMAN_VERSION: 4.4.4

GOVER: 1.22

KUBERNETES_VERSION: v1.32.0
KIND_VERSION: v0.26.0
KIND_IMAGE_SHA: sha256:c48c62eac5da28cdadcf560d1d8616cfa6783b58f0d94cf63ad1bf49600cb027
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ jobs:
name: Validate C# quickstart on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 130
env:
DAPR_DEFAULT_IMAGE_REGISTRY: GHCR
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install
GOVER: 1.18
KUBERNETES_VERSION: v1.25.3
KIND_VERSION: v0.17.0
KIND_IMAGE_SHA: sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
PODMAN_VERSION: 4.4.4
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/validate_go_quickstarts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ jobs:
name: Validate Go quickstarts on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 130
env:
DAPR_DEFAULT_IMAGE_REGISTRY: GHCR
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install
GOVER: 1.21
KUBERNETES_VERSION: v1.21.1
KIND_VERSION: v0.11.0
KIND_IMAGE_SHA: sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
PODMAN_VERSION: 4.4.4
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ jobs:
name: Validate Java quickstart on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 130
env:
DAPR_DEFAULT_IMAGE_REGISTRY: GHCR
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install
GOVER: 1.19
KUBERNETES_VERSION: v1.25.3
KIND_VERSION: v0.17.0
KIND_IMAGE_SHA: sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
PODMAN_VERSION: 4.4.4
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ jobs:
name: Validate Javascript quickstart on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 130
env:
DAPR_DEFAULT_IMAGE_REGISTRY: GHCR
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install
GOVER: 1.19
KUBERNETES_VERSION: v1.25.3
KIND_VERSION: v0.17.0
KIND_IMAGE_SHA: sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
PODMAN_VERSION: 4.4.4
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ jobs:
name: Validate Python quickstart on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 130
env:
DAPR_DEFAULT_IMAGE_REGISTRY: GHCR
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install
GOVER: 1.19
KUBERNETES_VERSION: v1.25.3
KIND_VERSION: v0.17.0
KIND_IMAGE_SHA: sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
PODMAN_VERSION: 4.4.4
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/validate_tutorials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ jobs:
name: Validate tutorials on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 40
env:
GOVER: 1.22
KUBERNETES_VERSION: v1.29.4
KIND_VERSION: v0.23.0
KIND_IMAGE_SHA: sha256:3abb816a5b1061fb15c6e9e60856ec40d56b7b52bcea5f5f1350bc6e2320b6f8
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
19 changes: 14 additions & 5 deletions actors/csharp/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Run the `SmartDevice.Service`, which will start service itself and the Dapr side
<!-- STEP
name: Run actor service
expected_stdout_lines:
- "Request finished HTTP/1.1 GET http://127.0.0.1:5001/healthz - 200"
- "Request finished HTTP/1.1 GET http://127.0.0.1:5001/dapr/config - 200"
expected_stderr_lines:
working_dir: .
output_match_mode: substring
Expand All @@ -50,14 +50,23 @@ dapr run --app-id actorservice --app-port 5001 --app-protocol http --dapr-http-p
Expected output:

```bash
== APP == info: Microsoft.Hosting.Lifetime[14]
== APP == Now listening on: http://localhost:5001
== APP == info: Microsoft.Hosting.Lifetime[0]
== APP == Application started. Press Ctrl+C to shut down.
== APP == info: Microsoft.Hosting.Lifetime[0]
== APP == Hosting environment: Production
== APP == info: Microsoft.Hosting.Lifetime[0]
== APP == info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
== APP == Request starting HTTP/1.1 GET http://127.0.0.1:5001/healthz - -
== APP == Request starting HTTP/1.1 GET http://127.0.0.1:5001/dapr/config - application/json -
== APP == warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
== APP == Failed to determine the https port for redirect.
== APP == info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
== APP == Executing endpoint 'Dapr Actors Health Check'
== APP == Executing endpoint 'Dapr Actors Config'
== APP == info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
== APP == Executed endpoint 'Dapr Actors Health Check'
== APP == Executed endpoint 'Dapr Actors Config'
== APP == info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
== APP == Request finished HTTP/1.1 GET http://127.0.0.1:5001/healthz - - - 200 - text/plain 5.2599ms
== APP == Request finished HTTP/1.1 GET http://127.0.0.1:5001/dapr/config - 200 - application/json 30.6175ms
```

### Step 4: Run the client app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
requests
flask
flask
urllib3>=2.2.2 # not directly required, pinned by Snyk to avoid a vulnerability
7 changes: 7 additions & 0 deletions conversation/components/conversation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: echo
spec:
type: conversation.echo
version: v1
85 changes: 85 additions & 0 deletions conversation/csharp/http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Dapr Conversation API (C# 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. If you are looking for the example using the Dapr Client SDK (recommended) [click here](../sdk/).

This quickstart includes one app:

- Conversation, 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 file](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) and Dapr CLI with `dapr run -f .`.

This example uses the default LLM Component provided by Dapr which simply echoes the input provided, for testing purposes. Integrate with popular LLM models by using one of the other [supported conversation components](https://v1-15.docs.dapr.io/reference/components-reference/supported-conversation/).

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: 15
-->

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

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

<!-- END_STEP -->

## Run the app individually

1. Open a terminal and run the `conversation` app. Build the dependencies if you haven't already.

```bash
cd ./conversation
dotnet build
```

2. Run the Dapr process alongside the application.

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

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?
```
67 changes: 67 additions & 0 deletions conversation/csharp/http/conversation/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Copyright 2024 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.
*/

using System.Net.Http;
using System.Text.Json;
using System.Text;

class Program
{
private const string ConversationComponentName = "echo";

static async Task Main(string[] args)
{
var daprHost = Environment.GetEnvironmentVariable("DAPR_HOST") ?? "http://localhost";
var daprHttpPort = Environment.GetEnvironmentVariable("DAPR_HTTP_PORT") ?? "3500";

var client = new HttpClient
{
Timeout = TimeSpan.FromSeconds(15)
};

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

var daprUrl = $"{daprHost}:{daprHttpPort}/v1.0-alpha1/conversation/{ConversationComponentName}/converse";

try
{
var content = new StringContent(JsonSerializer.Serialize(inputBody), Encoding.UTF8, "application/json");

// Send a request to the echo mock LLM component
var response = await client.PostAsync(daprUrl, content);
response.EnsureSuccessStatusCode();

Console.WriteLine("Input sent: " + inputBody.inputs[0].message);

var responseBody = await response.Content.ReadAsStringAsync();

// Parse the response
var data = JsonSerializer.Deserialize<Dictionary<string, List<Dictionary<string, string>>>>(responseBody);
var result = data?["outputs"]?[0]?["result"];

Console.WriteLine("Output response: " + result);
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}
14 changes: 14 additions & 0 deletions conversation/csharp/http/conversation/Program.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="9.0.1" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions conversation/csharp/http/dapr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 1
common:
resourcesPath: ../../components/
apps:
- appDirPath: ./conversation/
appID: conversation
daprHTTPPort: 3500
command: ["dotnet", "run"]
2 changes: 2 additions & 0 deletions conversation/csharp/http/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../docker.mk
include ../../../validate.mk
Loading
Loading