-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 添加 Google ADK、CrewAI、LangChain 和 PydanticAI 模型适配器的流选项支持,更新数据 AP… #11
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
Conversation
…I 以包含使用情况,优化测试用例 Change-Id: If568ea68a8f888784070096876f3b61535ea87d7 Signed-off-by: OhYee <oyohyee@oyohyee.com>
0d866e2 to
2486aaf
Compare
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 adds include_usage parameter support to streaming options across multiple AI framework model adapters (Google ADK, CrewAI, LangChain, PydanticAI, and AgentScope) and the data API to ensure probes can properly collect token usage information. Additionally, a new GitHub workflow for test package releases has been added.
Key Changes:
- Added
stream_options: {"include_usage": True}to all model adapters for proper token usage collection - Updated data API methods (
completionsandresponses) to setinclude_usage: Truein stream options - Added test assertions to verify stream_options are correctly configured
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| agentrun/model/api/data.py | Modified completions() and responses() methods to set stream_options.include_usage = True, but contains a critical bug with KeyError handling |
| agentrun/integration/google_adk/model_adapter.py | Added stream_options={"include_usage": True} to LiteLlm initialization |
| agentrun/integration/crewai/model_adapter.py | Added stream_options={"include_usage": True} to LLM initialization |
| agentrun/integration/langchain/model_adapter.py | Added stream_usage=True parameter to ChatOpenAI initialization |
| agentrun/integration/pydantic_ai/model_adapter.py | Added ModelSettings with extra_body containing stream_options, removed unused imports |
| agentrun/integration/agentscope/model_adapter.py | Added generate_kwargs={"stream_options": {"include_usage": True}} to OpenAIChatModel |
| tests/unittests/integration/test_integration.py | Added assertions to verify stream_options.include_usage is True in mocked completion calls |
| .github/workflows/release-test.yml | New workflow for building and publishing test packages to PyPI with tag-based triggers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agentrun/model/api/data.py
Outdated
| if kwargs["stream_options"] is None: | ||
| kwargs["stream_options"] = {} | ||
| kwargs["stream_options"]["include_usage"] = True |
Copilot
AI
Dec 5, 2025
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.
This code will raise a KeyError when stream_options is not present in kwargs. The condition checks if kwargs["stream_options"] is None, but this will fail if the key doesn't exist at all. Use kwargs.get("stream_options") instead or check with if "stream_options" not in kwargs or kwargs["stream_options"] is None:.
Change-Id: Id5caaaf81550827216a8445af904f60dd8b86142 Signed-off-by: OhYee <oyohyee@oyohyee.com>
4dd8d69 to
701bb43
Compare
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
[WIP] WIP Address feedback on Google ADK support
增加
include_usage参数,确保探针可以正确采集 tokenFix bugs
Bug detail
Pull request tasks
Update docs
Reason for update
Pull request tasks
Add contributor
Contributed content
Content detail
Others
Reason for update