-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement model structured output, and add model test #678
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
Implement model structured output, and add model test #678
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 PR implements model structured output functionality and adds comprehensive model tests for multiple chat model implementations including OpenAI, Ollama, Gemini, DashScope, and Anthropic.
Key changes:
- Added
structured_modelparameter to all chat models to enable structured output generation using Pydantic BaseModel schemas - Added
metadatafield toChatResponseclass to store structured output data - Implemented comprehensive unit tests for all model classes covering various scenarios including streaming, tool usage, and structured output
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/model_openai_test.py |
Complete test suite for OpenAI chat model |
tests/model_ollama_test.py |
Complete test suite for Ollama chat model |
tests/model_gemini_test.py |
Complete test suite for Gemini chat model |
tests/model_dashscope_test.py |
Complete test suite for DashScope chat model |
tests/model_anthropic_test.py |
Complete test suite for Anthropic chat model |
src/agentscope/model/_model_response.py |
Added metadata field to ChatResponse class |
src/agentscope/model/_openai_model.py |
Implemented structured output support for OpenAI models |
src/agentscope/model/_ollama_model.py |
Implemented structured output support for Ollama models |
src/agentscope/model/_gemini_model.py |
Implemented structured output support for Gemini models |
src/agentscope/model/_dashscope_model.py |
Implemented structured output support for DashScope models |
src/agentscope/model/_anthropic_model.py |
Implemented structured output support for Anthropic models |
src/agentscope/_utils/_common.py |
Added utility function to create tools from Pydantic BaseModel |
.github/workflows/unittest.yml |
Updated CI to use dev dependencies instead of full |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Please see inline comments, and remove the unnecessary unittests to keep the code clean and tidy
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.
lgtm
AgentScope Version
1.0.0
Description
As the title says.
Checklist
Please check the following items before code is ready to be reviewed.
pre-commit run --all-filescommand