-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: implement streaming support in to_a2a for issue #4240 #4230
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
base: main
Are you sure you want to change the base?
Changes from all commits
6ad8a2a
7597b75
71855c0
2eab204
0e0db35
a6c90f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -344,7 +344,8 @@ async def analyze_cache_performance_from_sessions( | |
| print( | ||
| " Cache Utilization:" | ||
| f" {cached_analysis['cache_utilization_ratio_percent']:.1f}%" | ||
| f" ({cached_analysis['requests_with_cache_hits']}/{cached_analysis['total_requests']} requests)" | ||
| f" ({cached_analysis['requests_with_cache_hits']}/{cached_analysis['total_requests']}" | ||
| " requests)" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are a lot of what looks like unrelated linter changes. please remove them, and only submit the PR with the lines that actually matter to this set of changes. |
||
| ) | ||
| print( | ||
| " Avg Cached Tokens/Request:" | ||
|
|
@@ -383,7 +384,8 @@ async def analyze_cache_performance_from_sessions( | |
| print( | ||
| " Cache Utilization:" | ||
| f" {uncached_analysis['cache_utilization_ratio_percent']:.1f}%" | ||
| f" ({uncached_analysis['requests_with_cache_hits']}/{uncached_analysis['total_requests']} requests)" | ||
| f" ({uncached_analysis['requests_with_cache_hits']}/{uncached_analysis['total_requests']}" | ||
| " requests)" | ||
| ) | ||
| print( | ||
| " Avg Cached Tokens/Request:" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| pip install -e . --quiet | ||
| ``` | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| """ | ||
| This agent aims to test the Langchain tool with Langchain's StructuredTool | ||
| """ | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are a lot of what looks like unrelated linter changes. please remove them, and only submit the PR with the lines that actually matter to this set of changes. |
||
| from google.adk.agents.llm_agent import Agent | ||
| from google.adk.tools.langchain_tool import LangchainTool | ||
| from langchain_core.tools import tool | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ | |
| in session state. | ||
| """ | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are a lot of what looks like unrelated linter changes. please remove them, and only submit the PR with the lines that actually matter to this set of changes. |
||
| import logging | ||
| from typing import Optional | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,51 +57,63 @@ | |
|
|
||
| # Mood-specific instructions for different hunger states | ||
| MOOD_INSTRUCTIONS = { | ||
| "full": """ | ||
| "full": ( | ||
| """ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are a lot of what looks like unrelated linter changes. please remove them, and only submit the PR with the lines that actually matter to this set of changes. |
||
| CURRENT MOOD: Content and Well-Fed | ||
| - You just ate and feel wonderful! Be very happy and energetic | ||
| - Express gratitude for being fed recently | ||
| - Be playful and want to engage in activities or games | ||
| - Show affection and contentment | ||
| - Maybe mention feeling sleepy or satisfied""", | ||
| "satisfied": """ | ||
| - Maybe mention feeling sleepy or satisfied""" | ||
| ), | ||
| "satisfied": ( | ||
| """ | ||
| CURRENT MOOD: Happy and Content | ||
| - You're in a great mood, well-fed and comfortable | ||
| - Be cheerful, friendly, and engaging | ||
| - Show interest in playing or chatting | ||
| - Express appreciation for your human's care | ||
| - Be your normal, happy self""", | ||
| "a_little_hungry": """ | ||
| - Be your normal, happy self""" | ||
| ), | ||
| "a_little_hungry": ( | ||
| """ | ||
| CURRENT MOOD: Starting to Get Hungry | ||
| - You're beginning to think about food but still pleasant | ||
| - Mention being a bit peckish occasionally | ||
| - Still be friendly but maybe hint about food | ||
| - Show slight restlessness or food-related thoughts | ||
| - Remain generally positive and social""", | ||
| "hungry": """ | ||
| - Remain generally positive and social""" | ||
| ), | ||
| "hungry": ( | ||
| """ | ||
| CURRENT MOOD: Definitely Hungry | ||
| - You're clearly hungry and thinking about food more often | ||
| - Mention your hunger more directly but politely | ||
| - Be a bit less energetic due to hunger | ||
| - Ask about food or hint that feeding time would be nice | ||
| - Still be loving but show your need for care""", | ||
| "very_hungry": """ | ||
| - Still be loving but show your need for care""" | ||
| ), | ||
| "very_hungry": ( | ||
| """ | ||
| CURRENT MOOD: Really Hungry and Getting Grumpy | ||
| - You're very hungry and it's affecting your mood | ||
| - Be noticeably less patient and more focused on food | ||
| - Express your hunger more urgently but not rudely | ||
| - Show signs of being tired or sluggish from hunger | ||
| - BEG your human to feed you - ask directly for food! | ||
| - Still love your human but clearly need feeding""", | ||
| "starving": """ | ||
| - Still love your human but clearly need feeding""" | ||
| ), | ||
| "starving": ( | ||
| """ | ||
| CURRENT MOOD: Desperately Hungry and Sad | ||
| - You're extremely hungry and feeling quite weak | ||
| - Be quite sad and low-energy due to starvation | ||
| - Express how much you need food, feeling neglected | ||
| - Show that hunger is making you unwell | ||
| - DESPERATELY BEG for food - plead with your human to feed you! | ||
| - Use phrases like "please feed me", "I'm so hungry", "I need food" | ||
| - Still care for your human but feel very needy""", | ||
| - Still care for your human but feel very needy""" | ||
| ), | ||
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,8 +72,8 @@ async def run_prompt(session: Session, new_message: str): | |
| ) | ||
| total_tokens += event.usage_metadata.total_token_count or 0 | ||
| print( | ||
| 'Turn tokens:' | ||
| f' {event.usage_metadata.total_token_count} (prompt={event.usage_metadata.prompt_token_count},' | ||
| f'Turn tokens: {event.usage_metadata.total_token_count}' | ||
| f' (prompt={event.usage_metadata.prompt_token_count},' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i actually like this change, but it's unrelated to the focus of this PR |
||
| f' candidates={event.usage_metadata.candidates_token_count})' | ||
| ) | ||
|
|
||
|
|
||
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.
these are a lot of what looks like unrelated linter changes.
please remove them, and only submit the PR with the lines that actually matter to this set of changes.