Skip to content

Commit 19f6c61

Browse files
.
1 parent 0ad4b60 commit 19f6c61

2 files changed

Lines changed: 43 additions & 19 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from deepeval.prompt import Prompt
2+
from deepeval.integrations.pydantic_ai import Agent
3+
from deepeval.tracing import observe
4+
import asyncio
5+
6+
@observe(type="tool", metric_collection="test_collection_1")
7+
def get_weather(city: str) -> str:
8+
"""Gets the weather for a given city."""
9+
return f"I don't know the weather for {city}."
10+
11+
prompt = Prompt(alias="asd")
12+
prompt.pull(version="00.00.01")
13+
14+
agent = Agent(
15+
"openai:gpt-4o-mini",
16+
tools=[get_weather],
17+
system_prompt="You are a helpful weather agent.",
18+
name="test_name_1",
19+
tags=["test_tag_1"],
20+
metadata={"test_metadata_1": "test_metadata_1"},
21+
thread_id="test_thread_id_1",
22+
user_id="test_user_id_1",
23+
metric_collection="test_collection_1",
24+
llm_metric_collection="test_collection_1",
25+
llm_prompt=prompt,
26+
agent_metric_collection="test_collection_1",
27+
)
28+
29+
async def execute_agent_stream():
30+
async with agent.run_stream("What is the weather in London?", name="test_name_2") as result:
31+
async for chunk in result.stream_text(delta=True):
32+
print(chunk, end="", flush=True)
33+
final = await result.get_output()
34+
print("\n\nFinal:", final)
35+
36+
async def execute_agent_run():
37+
result = await agent.run("What is the weather in London?", name="test_name_4")
38+
print(result.output)
39+
40+
def execute_all():
41+
asyncio.run(execute_agent_stream())
42+
agent.run_sync("What is the weather in London?", name="test_name_3")
43+
asyncio.run(execute_agent_run())

tests/test_integrations/test_pydanticai/pydantic_run_sync.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)