-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: [Breaking] Simplified Content types to a single class with classmethod constructors. #3252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: [Breaking] Simplified Content types to a single class with classmethod constructors. #3252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors the Content model in the Python Agent Framework, replacing the old inheritance-based Content types (derived from BaseContent) with a single Content class that uses classmethods to create specific content types. This is a significant architectural change that modernizes the content type system.
Changes:
- Replaced multiple Content classes (TextContent, DataContent, FunctionCallContent, etc.) with a single
Contentclass with factory methods (from_text, from_data, from_function_call, etc.) - Updated all code references from the old class-based approach to the new classmethod-based approach
- Changed attribute name from
detailstousage_detailsin UsageContent - Updated dependency versions in uv.lock (anthropic, azure-core, huggingface-hub, identify, langfuse, librt, litellm, mem0ai, openai-agents, openai-chatkit, plotly, polars, py2docfx, regex, ruff, uv)
- Updated TypeScript types to match the new Content structure
- Fixed observability settings usage in lightning package
Reviewed changes
Copilot reviewed 121 out of 123 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Updated package dependency versions |
| python/samples (multiple files) | Updated from old Content classes to new Content.from_* factory methods |
| python/packages (multiple test files) | Updated test assertions and imports to use new Content model |
| python/packages/ollama | Updated OllamaChatClient to use new Content type checking |
| python/packages/devui | Updated TypeScript types and Python mapper to use new Content structure |
| python/packages/declarative | Updated loader to use new Content factory methods |
| python/packages/lab/lightning | Fixed observability settings API usage |
4cb5c39 to
dcf83e0
Compare
4ddd0d9 to
a42a3e5
Compare
5254138 to
fb03609
Compare
Motivation and Context
Replaced all old Content types (derived from BaseContent) to a single Content
with classmethods to create specific ones.
This gives chat client builders the option* to create custom types without having that abstracted. They can put in some other value for the type and drop any other fields into additional_propertiers.
*: this will not work for all clients, since those won't know what to do with them, but they can internally create and parse them.
Description
Contribution Checklist