Skip to content

Commit 5dec36a

Browse files
sicoyleJoshVanLacrocacicoylematheusandre1
authored
fix(release): grab missing commits needed for release branch 1.17 (#938)
* Workflow: remove sleeps from example (#894) * Workflow: remove sleeps from example Remove arbitrary sleeps from workflow examples Signed-off-by: joshvanl <me@joshvanl.dev> * tox -e ruff Signed-off-by: joshvanl <me@joshvanl.dev> --------- Signed-off-by: joshvanl <me@joshvanl.dev> Signed-off-by: Samantha Coyle <sam@diagrid.io> * Workflow versioning (#893) Signed-off-by: Albert Callarisa <albert@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: signal when dt reader stream is ready within wf client start call (#901) * fix: signal when dt reader stream is ready within wf client start call Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: appease linter Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: enable configurability + lint fixes Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(build): add tests and fix bug Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(build): add more tests Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: appease linter Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(build): add another test Signed-off-by: Samantha Coyle <sam@diagrid.io> * test: add even more tests for build to pass lol Signed-off-by: Samantha Coyle <sam@diagrid.io> --------- Signed-off-by: Samantha Coyle <sam@diagrid.io> * feat(convo): add new fields to conversation api (#902) * feat(convo): add new fields to conversation api Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: update proto/grpc code generator and add more tests Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: appease linter Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: tox -e type fixes Signed-off-by: Samantha Coyle <sam@diagrid.io> --------- Signed-off-by: Samantha Coyle <sam@diagrid.io> * add venv (#921) Signed-off-by: Cassandra Coyle <cassie@diagrid.io> Co-authored-by: Sam <sam@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: Align Workflow Multi App Naming Convention (#932) Signed-off-by: Matheus André <92062874+matheusandre1@users.noreply.github.com> Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(bug): workflow client missing close function to pass to durable task (#889) * chore(deps): bump dapr dep to 1.17.0.dev Signed-off-by: Casper Nielsen <casper@diagrid.io> * chore(deps): bump durabletask-dapr to 0.2.0a15 Signed-off-by: Casper Nielsen <casper@diagrid.io> * feat: ensure taskhubgrpcclient expose .close() method for clients to pass down a close call to durabletask Signed-off-by: Casper Nielsen <casper@diagrid.io> --------- Signed-off-by: Casper Nielsen <casper@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: signal when dt reader stream is ready within wf client start call (#901) * fix: signal when dt reader stream is ready within wf client start call Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: appease linter Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: enable configurability + lint fixes Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(build): add tests and fix bug Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(build): add more tests Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: appease linter Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(build): add another test Signed-off-by: Samantha Coyle <sam@diagrid.io> * test: add even more tests for build to pass lol Signed-off-by: Samantha Coyle <sam@diagrid.io> --------- Signed-off-by: Samantha Coyle <sam@diagrid.io> * style: rm prefix of == APP == Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix(build): grab latest 1.17 runtime Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: exclude prereleases Signed-off-by: Samantha Coyle <sam@diagrid.io> * fix: update readmes for release branch Signed-off-by: Samantha Coyle <sam@diagrid.io> --------- Signed-off-by: joshvanl <me@joshvanl.dev> Signed-off-by: Samantha Coyle <sam@diagrid.io> Signed-off-by: Albert Callarisa <albert@diagrid.io> Signed-off-by: Cassandra Coyle <cassie@diagrid.io> Signed-off-by: Matheus André <92062874+matheusandre1@users.noreply.github.com> Signed-off-by: Casper Nielsen <casper@diagrid.io> Co-authored-by: Josh van Leeuwen <me@joshvanl.dev> Co-authored-by: Albert Callarisa <albert@diagrid.io> Co-authored-by: Cassie Coyle <cassie@diagrid.io> Co-authored-by: Matheus André <92062874+matheusandre1@users.noreply.github.com> Co-authored-by: Casper Nielsen <casper@diagrid.io>
1 parent f3339f6 commit 5dec36a

File tree

39 files changed

+1147
-642
lines changed

39 files changed

+1147
-642
lines changed

.github/workflows/validate_examples.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ jobs:
6565
repository: ${{ env.CHECKOUT_REPO }}
6666
ref: ${{ env.CHECKOUT_REF }}
6767
- uses: azure/setup-helm@v4
68-
- name: Determine latest Dapr Runtime version (including prerelease)
68+
- name: Determine latest Dapr Runtime version
6969
run: |
70-
RUNTIME_VERSION=$(curl -s "https://api.github.com/repos/dapr/dapr/releases" | grep '"tag_name"' | head -n 1 | cut -d ':' -f2 | tr -d '",v ')
70+
RUNTIME_VERSION=$(curl -s "https://api.github.com/repos/dapr/dapr/releases" | grep '"tag_name"' | cut -d ':' -f2 | tr -d '",v ' | grep -v -E '\-rc|\-alpha|\-beta|\-pre' | sort -V | tail -1)
7171
echo "DAPR_RUNTIME_VER=$RUNTIME_VERSION" >> $GITHUB_ENV
7272
echo "Found $RUNTIME_VERSION"
73-
- name: Determine latest Dapr Cli version (including prerelease)
73+
- name: Determine latest Dapr Cli version
7474
run: |
75-
CLI_VERSION=$(curl -s "https://api.github.com/repos/dapr/cli/releases" | grep '"tag_name"' | head -n 1 | cut -d ':' -f2 | tr -d '",v ')
75+
CLI_VERSION=$(curl -s "https://api.github.com/repos/dapr/cli/releases" | grep '"tag_name"' | cut -d ':' -f2 | tr -d '",v ' | grep -v -E '\-rc|\-alpha|\-beta|\-pre' | sort -V | tail -1)
7676
echo "DAPR_CLI_VER=$CLI_VERSION" >> $GITHUB_ENV
7777
echo "Found $CLI_VERSION"
7878
- name: Set up Python ${{ matrix.python_ver }}

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ git clone https://github.com/dapr/python-sdk.git
7979
cd python-sdk
8080
```
8181

82-
2. Install a project in a editable mode
82+
2. Create and activate a virtual environment
83+
84+
```bash
85+
python3 -m venv .venv
86+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
87+
```
88+
89+
3. Install a project in editable mode
8390

8491
```bash
8592
pip3 install -e .
@@ -90,31 +97,31 @@ pip3 install -e ./ext/dapr-ext-langgraph/
9097
pip3 install -e ./ext/dapr-ext-strands/
9198
```
9299

93-
3. Install required packages
100+
4. Install required packages
94101

95102
```bash
96103
pip3 install -r dev-requirements.txt
97104
```
98105

99-
4. Run linter and autofix
106+
5. Run linter and autofix
100107

101108
```bash
102109
tox -e ruff
103110
```
104111

105-
5. Run unit-test
112+
6. Run unit-test
106113

107114
```bash
108115
tox -e py311
109116
```
110117

111-
6. Run type check
118+
7. Run type check
112119

113120
```bash
114121
tox -e type
115122
```
116123

117-
7. Run examples
124+
8. Run examples
118125

119126
```bash
120127
tox -e examples

dapr/clients/grpc/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525

2626
import grpc # type: ignore
2727
from google.protobuf.any_pb2 import Any as GrpcAny
28+
from google.protobuf.duration_pb2 import Duration as GrpcDuration
2829
from google.protobuf.empty_pb2 import Empty as GrpcEmpty
2930
from google.protobuf.message import Message as GrpcMessage
31+
from google.protobuf.struct_pb2 import Struct as GrpcStruct
3032
from grpc import ( # type: ignore
3133
RpcError,
3234
StatusCode,
@@ -1880,6 +1882,8 @@ def converse_alpha2(
18801882
temperature: Optional[float] = None,
18811883
tools: Optional[List[conversation.ConversationTools]] = None,
18821884
tool_choice: Optional[str] = None,
1885+
response_format: Optional[GrpcStruct] = None,
1886+
prompt_cache_retention: Optional[GrpcDuration] = None,
18831887
) -> conversation.ConversationResponseAlpha2:
18841888
"""Invoke an LLM using the conversation API (Alpha2) with tool calling support.
18851889
@@ -1893,6 +1897,8 @@ def converse_alpha2(
18931897
temperature: Optional temperature setting for the LLM to optimize for creativity or predictability
18941898
tools: Optional list of tools available for the LLM to call
18951899
tool_choice: Optional control over which tools can be called ('none', 'auto', 'required', or specific tool name)
1900+
response_format: Optional response format (google.protobuf.struct_pb2.Struct, ex: json_schema for structured output)
1901+
prompt_cache_retention: Optional retention for prompt cache (google.protobuf.duration_pb2.Duration)
18961902
18971903
Returns:
18981904
ConversationResponseAlpha2 containing the conversation results with choices and tool calls
@@ -1949,6 +1955,10 @@ def converse_alpha2(
19491955
request.temperature = temperature
19501956
if tool_choice is not None:
19511957
request.tool_choice = tool_choice
1958+
if response_format is not None and hasattr(request, 'response_format'):
1959+
request.response_format.CopyFrom(response_format)
1960+
if prompt_cache_retention is not None and hasattr(request, 'prompt_cache_retention'):
1961+
request.prompt_cache_retention.CopyFrom(prompt_cache_retention)
19521962

19531963
try:
19541964
response, call = self.retry_policy.run_rpc(self._stub.ConverseAlpha2.with_call, request)

dapr/clients/grpc/conversation.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,46 @@ class ConversationResultAlpha2Choices:
338338
message: ConversationResultAlpha2Message
339339

340340

341+
@dataclass
342+
class ConversationResultAlpha2CompletionUsageCompletionTokensDetails:
343+
"""Breakdown of tokens used in the completion."""
344+
345+
accepted_prediction_tokens: int = 0
346+
audio_tokens: int = 0
347+
reasoning_tokens: int = 0
348+
rejected_prediction_tokens: int = 0
349+
350+
351+
@dataclass
352+
class ConversationResultAlpha2CompletionUsagePromptTokensDetails:
353+
"""Breakdown of tokens used in the prompt."""
354+
355+
audio_tokens: int = 0
356+
cached_tokens: int = 0
357+
358+
359+
@dataclass
360+
class ConversationResultAlpha2CompletionUsage:
361+
"""Token usage for one Alpha2 conversation result."""
362+
363+
completion_tokens: int = 0
364+
prompt_tokens: int = 0
365+
total_tokens: int = 0
366+
completion_tokens_details: Optional[
367+
ConversationResultAlpha2CompletionUsageCompletionTokensDetails
368+
] = None
369+
prompt_tokens_details: Optional[ConversationResultAlpha2CompletionUsagePromptTokensDetails] = (
370+
None
371+
)
372+
373+
341374
@dataclass
342375
class ConversationResultAlpha2:
343376
"""One of the outputs in Alpha2 response from conversation input."""
344377

345378
choices: List[ConversationResultAlpha2Choices] = field(default_factory=list)
379+
model: Optional[str] = None
380+
usage: Optional[ConversationResultAlpha2CompletionUsage] = None
346381

347382

348383
@dataclass
@@ -657,5 +692,38 @@ def _get_outputs_from_grpc_response(
657692
)
658693
)
659694

660-
outputs.append(ConversationResultAlpha2(choices=choices))
695+
model: Optional[str] = None
696+
usage: Optional[ConversationResultAlpha2CompletionUsage] = None
697+
if hasattr(output, 'model') and getattr(output, 'model', None):
698+
model = output.model
699+
if hasattr(output, 'usage') and output.usage:
700+
u = output.usage
701+
completion_details: Optional[
702+
ConversationResultAlpha2CompletionUsageCompletionTokensDetails
703+
] = None
704+
prompt_details: Optional[ConversationResultAlpha2CompletionUsagePromptTokensDetails] = (
705+
None
706+
)
707+
if hasattr(u, 'completion_tokens_details') and u.completion_tokens_details:
708+
cd = u.completion_tokens_details
709+
completion_details = ConversationResultAlpha2CompletionUsageCompletionTokensDetails(
710+
accepted_prediction_tokens=getattr(cd, 'accepted_prediction_tokens', 0) or 0,
711+
audio_tokens=getattr(cd, 'audio_tokens', 0) or 0,
712+
reasoning_tokens=getattr(cd, 'reasoning_tokens', 0) or 0,
713+
rejected_prediction_tokens=getattr(cd, 'rejected_prediction_tokens', 0) or 0,
714+
)
715+
if hasattr(u, 'prompt_tokens_details') and u.prompt_tokens_details:
716+
pd = u.prompt_tokens_details
717+
prompt_details = ConversationResultAlpha2CompletionUsagePromptTokensDetails(
718+
audio_tokens=getattr(pd, 'audio_tokens', 0) or 0,
719+
cached_tokens=getattr(pd, 'cached_tokens', 0) or 0,
720+
)
721+
usage = ConversationResultAlpha2CompletionUsage(
722+
completion_tokens=getattr(u, 'completion_tokens', 0) or 0,
723+
prompt_tokens=getattr(u, 'prompt_tokens', 0) or 0,
724+
total_tokens=getattr(u, 'total_tokens', 0) or 0,
725+
completion_tokens_details=completion_details,
726+
prompt_tokens_details=prompt_details,
727+
)
728+
outputs.append(ConversationResultAlpha2(choices=choices, model=model, usage=usage))
661729
return outputs

examples/configuration/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ To run this example, use the following command:
4747
name: Run get configuration example
4848
match_order: none
4949
expected_stdout_lines:
50-
- "== APP == Got key=orderId1 value=100 version=1 metadata={}"
51-
- "== APP == Got key=orderId2 value=200 version=1 metadata={}"
52-
- "== APP == Subscribe key=orderId2 value=210 version=2 metadata={}"
53-
- "== APP == Unsubscribed successfully? True"
50+
- "Got key=orderId1 value=100 version=1 metadata={}"
51+
- "Got key=orderId2 value=200 version=1 metadata={}"
52+
- "Subscribe key=orderId2 value=210 version=2 metadata={}"
53+
- "Unsubscribed successfully? True"
5454
background: true
5555
timeout_seconds: 30
5656
sleep: 3
@@ -75,7 +75,7 @@ docker exec dapr_redis redis-cli SET orderId2 "210||2"
7575

7676
You should be able to see the following output:
7777
```
78-
== APP == Got key=orderId1 value=100 version=1
79-
== APP == Got key=orderId2 value=200 version=1
80-
== APP == Subscribe key=orderId2 value=210 version=2
78+
Got key=orderId1 value=100 version=1
79+
Got key=orderId2 value=200 version=1
80+
Subscribe key=orderId2 value=210 version=2
8181
```

examples/conversation/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ The Conversation API supports real LLM providers including:
2828
<!-- STEP
2929
name: Run Conversation Alpha V1
3030
expected_stdout_lines:
31-
- "== APP == Result: What's Dapr?"
32-
- "== APP == Give a brief overview."
31+
- "Result: What's Dapr?"
32+
- "Give a brief overview."
3333
background: true
3434
timeout_seconds: 60
3535
-->
@@ -47,8 +47,8 @@ The Conversation API supports real LLM providers including:
4747
<!-- STEP
4848
name: Run Conversation Alpha V2
4949
expected_stdout_lines:
50-
- "== APP == Result: What's Dapr?"
51-
- "== APP == Give a brief overview."
50+
- "Result: What's Dapr?"
51+
- "Give a brief overview."
5252
background: true
5353
timeout_seconds: 60
5454
-->

examples/crypto/README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ openssl rand -out keys/symmetric-key-256 32
3939
<!-- STEP
4040
name: Run crypto example
4141
expected_stdout_lines:
42-
- '== APP == Running gRPC client synchronous API'
43-
- '== APP == Running encrypt/decrypt operation on string'
44-
- '== APP == Encrypted the message, got 856 bytes'
45-
- '== APP == Decrypted the message, got 24 bytes'
46-
- '== APP == The secret is "passw0rd"'
47-
- '== APP == Running encrypt/decrypt operation on file'
48-
- '== APP == Wrote encrypted data to encrypted.out'
49-
- '== APP == Wrote decrypted data to decrypted.out.jpg'
42+
- 'Running gRPC client synchronous API'
43+
- 'Running encrypt/decrypt operation on string'
44+
- 'Encrypted the message, got 856 bytes'
45+
- 'Decrypted the message, got 24 bytes'
46+
- 'The secret is "passw0rd"'
47+
- 'Running encrypt/decrypt operation on file'
48+
- 'Wrote encrypted data to encrypted.out'
49+
- 'Wrote decrypted data to decrypted.out.jpg'
5050
- "Exited App successfully"
5151
output_match_mode: substring
5252
timeout_seconds: 10
@@ -63,14 +63,14 @@ dapr run --app-id crypto --resources-path ./components/ -- python3 crypto.py
6363
<!-- STEP
6464
name: Run async crypto example
6565
expected_stdout_lines:
66-
- '== APP == Running gRPC client asynchronous API'
67-
- '== APP == Running encrypt/decrypt operation on string'
68-
- '== APP == Encrypted the message, got 856 bytes'
69-
- '== APP == Decrypted the message, got 24 bytes'
70-
- '== APP == The secret is "passw0rd"'
71-
- '== APP == Running encrypt/decrypt operation on file'
72-
- '== APP == Wrote encrypted data to encrypted.out'
73-
- '== APP == Wrote decrypted data to decrypted.out.jpg'
66+
- 'Running gRPC client asynchronous API'
67+
- 'Running encrypt/decrypt operation on string'
68+
- 'Encrypted the message, got 856 bytes'
69+
- 'Decrypted the message, got 24 bytes'
70+
- 'The secret is "passw0rd"'
71+
- 'Running encrypt/decrypt operation on file'
72+
- 'Wrote encrypted data to encrypted.out'
73+
- 'Wrote decrypted data to decrypted.out.jpg'
7474
- "Exited App successfully"
7575
output_match_mode: substring
7676
timeout_seconds: 10
@@ -102,20 +102,20 @@ rm decrypted.out.jpg
102102
The output should be as follows:
103103

104104
```shell
105-
== APP == Running gRPC client synchronous API
106-
== APP == Running encrypt/decrypt operation on string
107-
== APP == Encrypted the message, got 856 bytes
108-
== APP == Decrypted the message, got 24 bytes
109-
== APP == b'The secret is "passw0rd"'
110-
== APP == Running encrypt/decrypt operation on file
111-
== APP == Wrote encrypted data to encrypted.out
112-
== APP == Wrote decrypted data to decrypted.out.jpg
113-
== APP == Running gRPC client asynchronous API
114-
== APP == Running encrypt/decrypt operation on string
115-
== APP == Encrypted the message, got 856 bytes
116-
== APP == Decrypted the message, got 24 bytes
117-
== APP == b'The secret is "passw0rd"'
118-
== APP == Running encrypt/decrypt operation on file
119-
== APP == Wrote encrypted data to encrypted.out
120-
== APP == Wrote decrypted data to decrypted.out.jpg
105+
Running gRPC client synchronous API
106+
Running encrypt/decrypt operation on string
107+
Encrypted the message, got 856 bytes
108+
Decrypted the message, got 24 bytes
109+
b'The secret is "passw0rd"'
110+
Running encrypt/decrypt operation on file
111+
Wrote encrypted data to encrypted.out
112+
Wrote decrypted data to decrypted.out.jpg
113+
Running gRPC client asynchronous API
114+
Running encrypt/decrypt operation on string
115+
Encrypted the message, got 856 bytes
116+
Decrypted the message, got 24 bytes
117+
b'The secret is "passw0rd"'
118+
Running encrypt/decrypt operation on file
119+
Wrote encrypted data to encrypted.out
120+
Wrote decrypted data to decrypted.out.jpg
121121
```

0 commit comments

Comments
 (0)