Repository navigation
pydanticai example - #127
Guidosalimbeni wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
djsamseng
left a comment
There was a problem hiding this comment.
I'm not an owner, but I think since this is a python example, all the files should be under samples/python instead of top level?
Also it would be great if we could have this based off of this pull request that properly sets up the samples/python directory structure for proper namespacing
| @@ -0,0 +1,9 @@ | |||
| from a2a.server import A2AServer | |||
There was a problem hiding this comment.
Where is the import a2a coming from? I only see common and server being exported per pyproject.toml
| @@ -0,0 +1,22 @@ | |||
| from pydantic import BaseModel, Field | |||
There was a problem hiding this comment.
pydantic and pydantic_ai both need to be added as dependencies? In pyproject.toml
| @@ -0,0 +1,3 @@ | |||
| pydantic | |||
| pydantic_ai | |||
| a2a No newline at end of file | |||
|
Please move this PR to the new samples repo here https://github.com/google-a2a/a2a-samples |
feat: Add Pydantic AI Summarizer Agent with A2A Integration
This pull request introduces the
SummarizerAgent, a new agent built using Pydantic AI, showcasing how to integrate this library with the A2A framework. TheSummarizerAgentis designed to take a text string as input and return a concise summary of that text.Motivation:
This example provides a clear illustration of how Pydantic AI can be leveraged to create agents and how such agents can be easily integrated into the A2A ecosystem.
Changes:
samples/python/agents/pydantic_agent/agent.py:SummarizerAgentclass, inheriting from Pydantic'sBaseModel.@AICallabledecorator to define thesummarizemethod, which handles the summarization logic.OPENAI_API_KEYenvironment variable.samples/python/agents/pydantic_agent/__main__.py:SummarizerAgent.A2AAgentto make it compatible with the A2A protocol.A2AServerto host the agent and handle incoming A2A requests.samples/python/agents/pydantic_agent/README.md:samples/python/agents/pydantic_agent/__init__.py:How to Run and Test:
OPENAI_API_KEYenvironment variable is set.samples/python/agents/pydantic_agent/directory.python __main__.py.Benefits: