-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix response parsing to make gemini tool use work #1591
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.
Please check these comments before merging the branch.
finance_agent = Agent( | ||
name="Finance Agent", | ||
model=Gemini(id="gemini-2.0-flash-exp"), | ||
tools=[YFinanceTools(stock_price=True)], | ||
debug_mode=True, | ||
) |
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.
Add these two flags
add_chat_history_to_messages=True,
num_history_responses=3
And see if you get error.
Persistent memory is not working.
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 test with this sample config
master = Agent(
name="Master",
model=model,
agent_id="master",
team=[web_agent],
storage=SqlAgentStorage(table_name="master_sessions", db_file="tmp/agents.db"),
markdown=True,
add_chat_history_to_messages=True,
num_history_responses=3
)
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.
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.
@samyogdhital @manthanguptaa It seems that persistence still cannot save messages related to tool use in Gemini
Is there a fix on the way?
If not, I can try to fix it after the New Year holidays.
DEBUG ============== user ==============
DEBUG how many messages did i send?
DEBUG ============== model ==============
DEBUG Tool Calls: [
{
"type": "function",
"function": {
"name": "get_chat_history",
"arguments": "{}"
}
}
]
DEBUG ============== tool ==============
DEBUG ['']
DEBUG ============== model ==============
DEBUG I'm sorry, I cannot fulfill this request. There is no information about how many messages you sent.
DEBUG **************** METRICS START ****************
DEBUG * Time to first token: 1.4130s
DEBUG * Time to generate response: 1.5110s
DEBUG * Tokens per second: 15.2219 tokens/s
DEBUG * Input tokens: 1065
DEBUG * Output tokens: 23
DEBUG * Total tokens: 1088
DEBUG **************** METRICS END ******************
DEBUG ---------- Gemini Response End ----------
DEBUG ---------- Gemini Response End ----------
DEBUG Added 4 Messages to AgentMemory
DEBUG Added AgentRun to AgentMemory
DEBUG Exception upserting into table: (builtins.TypeError) Object of type RepeatedComposite is not JSON serializable
[SQL: INSERT INTO agent_sessions (session_id, agent_id, user_id, memory, agent_data, user_data, session_data, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON
CONFLICT (session_id) DO UPDATE SET agent_id = ?, user_id = ?, memory = ?, agent_data = ?, user_data = ?, session_data = ?, updated_at = ?]
[parameters: [{}]]
DEBUG Checking if table exists: agent_sessions
DEBUG *********** Agent Run End: df9761df-1868-4b4d-afc4-b7305132d7b8 ***********
Exception upserting into table: (builtins.TypeError) Object of type RepeatedComposite is not JSON serializable
debug_mode=True, | ||
) | ||
|
||
app = Playground(agents=[finance_agent]).get_app(use_async=False) |
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.
can we have use_async
as true and still having gemini working perfectly?
cause openi, groq and other models work without turning off use_async
.
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.
@samyogdhital Gemini right now doesn't support async. It's on the roadmap but till then you have to use use_async=False
@dirkbrnd I tried the PR against what @samyogdhital raised with the following agent config and it threw an error
Error
|
Description
Our run response parsing for the playground was not able to adequately parse
messages
in responses where tool_calls contained unserializable objects from Gemini. This resolves it.Fixes #1509
Type of change
Please check the options that are relevant:
Checklist