pydantic-ai-examples 1.0.0b1__py3-none-any.whl → 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pydantic-ai-examples might be problematic. Click here for more details.
- pydantic_ai_examples/bank_support.py +9 -6
- pydantic_ai_examples/weather_agent_gradio.py +6 -3
- {pydantic_ai_examples-1.0.0b1.dist-info → pydantic_ai_examples-1.0.1.dist-info}/METADATA +4 -4
- {pydantic_ai_examples-1.0.0b1.dist-info → pydantic_ai_examples-1.0.1.dist-info}/RECORD +6 -6
- {pydantic_ai_examples-1.0.0b1.dist-info → pydantic_ai_examples-1.0.1.dist-info}/WHEEL +0 -0
- {pydantic_ai_examples-1.0.0b1.dist-info → pydantic_ai_examples-1.0.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,7 +7,7 @@ Run with:
|
|
|
7
7
|
|
|
8
8
|
from dataclasses import dataclass
|
|
9
9
|
|
|
10
|
-
from pydantic import BaseModel
|
|
10
|
+
from pydantic import BaseModel
|
|
11
11
|
|
|
12
12
|
from pydantic_ai import Agent, RunContext
|
|
13
13
|
|
|
@@ -42,16 +42,19 @@ class SupportDependencies:
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class SupportOutput(BaseModel):
|
|
45
|
-
support_advice: str
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
support_advice: str
|
|
46
|
+
"""Advice returned to the customer"""
|
|
47
|
+
block_card: bool
|
|
48
|
+
"""Whether to block their card or not"""
|
|
49
|
+
risk: int
|
|
50
|
+
"""Risk level of query"""
|
|
48
51
|
|
|
49
52
|
|
|
50
53
|
support_agent = Agent(
|
|
51
54
|
'openai:gpt-4o',
|
|
52
55
|
deps_type=SupportDependencies,
|
|
53
56
|
output_type=SupportOutput,
|
|
54
|
-
|
|
57
|
+
instructions=(
|
|
55
58
|
'You are a support agent in our bank, give the '
|
|
56
59
|
'customer support and judge the risk level of their query. '
|
|
57
60
|
"Reply using the customer's name."
|
|
@@ -59,7 +62,7 @@ support_agent = Agent(
|
|
|
59
62
|
)
|
|
60
63
|
|
|
61
64
|
|
|
62
|
-
@support_agent.
|
|
65
|
+
@support_agent.instructions
|
|
63
66
|
async def add_customer_name(ctx: RunContext[SupportDependencies]) -> str:
|
|
64
67
|
customer_name = await ctx.deps.db.customer_name(id=ctx.deps.customer_id)
|
|
65
68
|
return f"The customer's name is {customer_name!r}"
|
|
@@ -3,6 +3,7 @@ from __future__ import annotations as _annotations
|
|
|
3
3
|
import json
|
|
4
4
|
|
|
5
5
|
from httpx import AsyncClient
|
|
6
|
+
from pydantic import BaseModel
|
|
6
7
|
|
|
7
8
|
from pydantic_ai.messages import ToolCallPart, ToolReturnPart
|
|
8
9
|
from pydantic_ai_examples.weather_agent import Deps, weather_agent
|
|
@@ -48,9 +49,11 @@ async def stream_from_agent(prompt: str, chatbot: list[dict], past_messages: lis
|
|
|
48
49
|
gr_message.get('metadata', {}).get('id', '')
|
|
49
50
|
== call.tool_call_id
|
|
50
51
|
):
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
if isinstance(call.content, BaseModel):
|
|
53
|
+
json_content = call.content.model_dump_json()
|
|
54
|
+
else:
|
|
55
|
+
json_content = json.dumps(call.content)
|
|
56
|
+
gr_message['content'] += f'\nOutput: {json_content}'
|
|
54
57
|
yield gr.skip(), chatbot, gr.skip()
|
|
55
58
|
chatbot.append({'role': 'assistant', 'content': ''})
|
|
56
59
|
async for message in result.stream_text():
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-examples
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Examples of how to use Pydantic AI and what it can do.
|
|
5
5
|
Author-email: Samuel Colvin <samuel@pydantic.dev>, Marcelo Trylesinski <marcelotryle@gmail.com>, David Montague <david@pydantic.dev>, Alex Hall <alex@pydantic.dev>, Douwe Maan <douwe@pydantic.dev>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
License-File: LICENSE
|
|
8
|
-
Classifier: Development Status ::
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
9
|
Classifier: Environment :: Console
|
|
10
10
|
Classifier: Environment :: MacOS X
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
@@ -34,8 +34,8 @@ Requires-Dist: logfire[asyncpg,fastapi,httpx,sqlite3]>=3.14.1
|
|
|
34
34
|
Requires-Dist: mcp[cli]>=1.4.1
|
|
35
35
|
Requires-Dist: modal>=1.0.4
|
|
36
36
|
Requires-Dist: pandas>=2.2.3
|
|
37
|
-
Requires-Dist: pydantic-ai-slim[ag-ui,anthropic,groq,openai,vertexai]==1.0.
|
|
38
|
-
Requires-Dist: pydantic-evals==1.0.
|
|
37
|
+
Requires-Dist: pydantic-ai-slim[ag-ui,anthropic,groq,openai,vertexai]==1.0.1
|
|
38
|
+
Requires-Dist: pydantic-evals==1.0.1
|
|
39
39
|
Requires-Dist: python-multipart>=0.0.17
|
|
40
40
|
Requires-Dist: rich>=13.9.2
|
|
41
41
|
Requires-Dist: uvicorn>=0.32.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
pydantic_ai_examples/__main__.py,sha256=i0LEo2JBOZ-gnHED0ou5Bya43gi7KmOyQ_jKN7M5Ces,1647
|
|
2
|
-
pydantic_ai_examples/bank_support.py,sha256=
|
|
2
|
+
pydantic_ai_examples/bank_support.py,sha256=TEy19B4iyB49A-ZMv1rOZIE_bOHml5er1Qaz700e2NU,2665
|
|
3
3
|
pydantic_ai_examples/chat_app.html,sha256=90XhxrpDAT09mPVTn9edEn8PqAD-tHxWkeeMz9r_okQ,2580
|
|
4
4
|
pydantic_ai_examples/chat_app.py,sha256=Aeep1DoXSsY7-STFT0gfDHqT7QpID_r_0sHloVOix5c,7078
|
|
5
5
|
pydantic_ai_examples/chat_app.ts,sha256=2KfZ2rJU2o0iCPjelyqEi5sH6vfemzWaa5Evx_VcAE4,3307
|
|
@@ -14,7 +14,7 @@ pydantic_ai_examples/sql_gen.py,sha256=rRp_C0ZvfLu6rkR5wrVvgah6wd92nh1vT4UYurx5p
|
|
|
14
14
|
pydantic_ai_examples/stream_markdown.py,sha256=rdhrR6XkqoeOpfv_xFbRpKDV4drEAd8ZrsFBXVrdvHs,2454
|
|
15
15
|
pydantic_ai_examples/stream_whales.py,sha256=Yoa7IuqN_6fowfYSINW39uPCthYu9FKChF-QBmQqWb8,2721
|
|
16
16
|
pydantic_ai_examples/weather_agent.py,sha256=E42RbuVDJzxlBw9lF2ARNSNAhL1HWVEmTt5MN70DyDU,3187
|
|
17
|
-
pydantic_ai_examples/weather_agent_gradio.py,sha256=
|
|
17
|
+
pydantic_ai_examples/weather_agent_gradio.py,sha256=sW1IV2B8ehrFrJKLDHv73ojosdpBI2h1S_HF662I6MQ,4728
|
|
18
18
|
pydantic_ai_examples/ag_ui/__init__.py,sha256=ZZs2V-5e9RaLl_7hJAq9-0Juk_f0mk2Vr7a4QT2QB-k,1174
|
|
19
19
|
pydantic_ai_examples/ag_ui/__main__.py,sha256=PMycatJt8Abb-Q8HXRGZoEY6vnOcvRebH7iI9MxLknA,225
|
|
20
20
|
pydantic_ai_examples/ag_ui/api/__init__.py,sha256=Pe307_ET_ERKBP-8Vs4L1yZRkK3ILPpajwxDpeW8YiI,673
|
|
@@ -44,7 +44,7 @@ pydantic_ai_examples/slack_lead_qualifier/modal.py,sha256=f464AaeyP-n3UIfvEVVc4D
|
|
|
44
44
|
pydantic_ai_examples/slack_lead_qualifier/models.py,sha256=WTp6D2WCASXqrjPVT3vGgTSYATLPBM3_cjq9wvXMRao,1586
|
|
45
45
|
pydantic_ai_examples/slack_lead_qualifier/slack.py,sha256=VJVfMeUXYClWUJBLHNuaW8PB2sxjNzpTC-O_AJwcxQ4,833
|
|
46
46
|
pydantic_ai_examples/slack_lead_qualifier/store.py,sha256=04vB4eZWKk_Tx0b9K4QuVI1U24JEyJyBS4X76cui7OI,896
|
|
47
|
-
pydantic_ai_examples-1.0.
|
|
48
|
-
pydantic_ai_examples-1.0.
|
|
49
|
-
pydantic_ai_examples-1.0.
|
|
50
|
-
pydantic_ai_examples-1.0.
|
|
47
|
+
pydantic_ai_examples-1.0.1.dist-info/METADATA,sha256=VTaZHeslB01sZdwEKdtUHLr8ayR1lZNbivvvQMK-7Xk,2760
|
|
48
|
+
pydantic_ai_examples-1.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
49
|
+
pydantic_ai_examples-1.0.1.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
|
|
50
|
+
pydantic_ai_examples-1.0.1.dist-info/RECORD,,
|
|
File without changes
|
{pydantic_ai_examples-1.0.0b1.dist-info → pydantic_ai_examples-1.0.1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|