Skip to content

Commit f05a2b6

Browse files
committed
fix: minor glitches in quickstart 01
Signed-off-by: Xavier Vergés <github@verg.es>
1 parent 67a4c69 commit f05a2b6

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

dapr_agents/workflow/runners/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ async def _get_status(instance_id: str) -> dict:
587587
)
588588
logger.info("Mounted default workflow status endpoint at %s", status_path)
589589

590-
def shutdown(self, agent: Optional[AgentComponents]) -> None:
590+
def shutdown(self, agent: Optional[AgentComponents] = None) -> None:
591591
"""
592592
Unwire subscriptions and close owned clients.
593593

quickstarts/01-dapr-agents-fundamentals/05_agent_memory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
from pathlib import Path
23

34
from dapr_agents.llm import DaprChatClient
45

@@ -21,7 +22,7 @@ async def main() -> None:
2122
memory=AgentMemoryConfig(
2223
store=ConversationDaprStateMemory(
2324
store_name="conversation-statestore",
24-
session_id="03-agent-with-memory",
25+
session_id=Path(__file__).stem,
2526
)
2627
),
2728
)

quickstarts/01-dapr-agents-fundamentals/06_durable_agent_http.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pathlib import Path
2+
13
from dapr_agents.llm import DaprChatClient
24

35
from dapr_agents import DurableAgent
@@ -21,7 +23,7 @@ def main() -> None:
2123
memory=AgentMemoryConfig(
2224
store=ConversationDaprStateMemory(
2325
store_name="conversation-statestore",
24-
session_id="04-durable-agent-http",
26+
session_id=Path(__file__).stem,
2527
)
2628
),
2729
# This is where the execution state is stored

quickstarts/01-dapr-agents-fundamentals/07_durable_agent_pubsub.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
from pathlib import Path
23

34
from dapr_agents.llm import DaprChatClient
45

@@ -16,7 +17,7 @@
1617
from function_tools import slow_weather_func
1718

1819

19-
def main() -> None:
20+
async def main() -> None:
2021
weather_agent = DurableAgent(
2122
name="WeatherAgent",
2223
role="Weather Assistant",
@@ -28,7 +29,7 @@ def main() -> None:
2829
memory=AgentMemoryConfig(
2930
store=ConversationDaprStateMemory(
3031
store_name="conversation-statestore",
31-
session_id="05-durable-agent-sub",
32+
session_id=Path(__file__).stem,
3233
)
3334
),
3435
# This is where the execution state is stored
@@ -50,12 +51,10 @@ def main() -> None:
5051
runner = AgentRunner()
5152
try:
5253
runner.subscribe(weather_agent)
54+
await wait_for_shutdown()
5355
finally:
5456
runner.shutdown()
5557

5658

5759
if __name__ == "__main__":
58-
try:
59-
main()
60-
except KeyboardInterrupt:
61-
print("\nInterrupted by user. Exiting gracefully...")
60+
asyncio.run(main())

quickstarts/01-dapr-agents-fundamentals/09_workflow_agents.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pathlib import Path
12
import time
23

34
import dapr.ext.workflow as wf
@@ -46,7 +47,7 @@ def get_customer_info(customer_name: str) -> str:
4647
memory=AgentMemoryConfig(
4748
store=ConversationDaprStateMemory(
4849
store_name="conversation-statestore",
49-
session_id="04-support-triage",
50+
session_id=f"{Path(__file__).stem}-triage",
5051
)
5152
),
5253
)
@@ -62,7 +63,7 @@ def get_customer_info(customer_name: str) -> str:
6263
memory=AgentMemoryConfig(
6364
store=ConversationDaprStateMemory(
6465
store_name="conversation-statestore",
65-
session_id="04-support-expert",
66+
session_id=f"{Path(__file__).stem}-expert",
6667
)
6768
),
6869
)

quickstarts/01-dapr-agents-fundamentals/10_durable_agent_tracing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import logging
3+
from pathlib import Path
34

45
from dapr_agents.llm import DaprChatClient
56

@@ -28,7 +29,7 @@ async def main() -> None:
2829
memory=AgentMemoryConfig(
2930
store=ConversationDaprStateMemory(
3031
store_name="conversation-statestore",
31-
session_id="08-durable-agent-trace",
32+
session_id=Path(__file__).stem,
3233
)
3334
),
3435
state=AgentStateConfig(

quickstarts/01-dapr-agents-fundamentals/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ metadata:
7373
value: "{{OPENAI_API_KEY}}"
7474
```
7575
76-
Replace `OPENAI_API_KEY` with your actual OpenAI API key.
76+
Replace `OPENAI_API_KEY` with your actual OpenAI API key. If you are using a different provider, make sure that you keep the name of the component as `llm-provider`.
7777

7878
---
7979

0 commit comments

Comments
 (0)