Skip to content

Commit

Permalink
Merge pull request #1546 from phidatahq/gemini-2-flash-phi-2171
Browse files Browse the repository at this point in the history
gemini-2-flash-phi-2171
  • Loading branch information
ashpreetbedi authored Dec 11, 2024
2 parents 78cbcbf + 64cb59f commit 958c0fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cookbook/providers/google/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from phi.tools.yfinance import YFinanceTools

agent = Agent(
model=Gemini(id="gemini-1.5-flash"),
model=Gemini(id="gemini-2.0-flash-exp"),
tools=[YFinanceTools(stock_price=True)],
show_tool_calls=True,
markdown=True,
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/google/agent_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from phi.tools.yfinance import YFinanceTools

agent = Agent(
model=Gemini(id="gemini-1.5-flash"),
model=Gemini(id="gemini-2.0-flash-exp"),
tools=[YFinanceTools(stock_price=True)],
instructions=["Use tables where possible."],
markdown=True,
Expand Down
14 changes: 13 additions & 1 deletion phi/model/google/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,25 @@ def _format_function_call_results(
messages (List[Message]): The list of conversation messages.
"""
if function_call_results:
combined_content = [] # Use a list to collect all result contents
combined_parts = [] # Use a list to collect all function responses

for result in function_call_results:
s = Struct()
s.update({"result": [result.content]})
function_response = genai.protos.Part(
function_response=genai.protos.FunctionResponse(name=result.tool_name, response=s)
)
messages.append(Message(role="tool", content=result.content, parts=[function_response]))
combined_content.append(result.content)
combined_parts.append(function_response)

messages.append(
Message(
role="tool",
content="\n".join(combined_content),
parts=combined_parts
)
)

def _handle_tool_calls(self, assistant_message: Message, messages: List[Message], model_response: ModelResponse):
"""
Expand Down

0 comments on commit 958c0fa

Please sign in to comment.