-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtest_sequential_tool_calling.py
More file actions
49 lines (41 loc) · 1.56 KB
/
test_sequential_tool_calling.py
File metadata and controls
49 lines (41 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Test sequential tool calling fix"""
from praisonaiagents import Agent
def get_stock_price(company_name: str) -> str:
"""
Get the stock price of a company
Args:
company_name (str): The name of the company
Returns:
str: The stock price of the company
"""
print(f"Tool called: get_stock_price({company_name})")
return f"The stock price of {company_name} is 100"
def multiply(a: int, b: int) -> int:
"""
Multiply two numbers
"""
print(f"Tool called: multiply({a}, {b})")
return a * b
# Test with streaming disabled to verify the fix
print("Testing sequential tool calling with stream=False...")
agent = Agent(
instructions="You are a helpful assistant. You can use the tools provided to you to help the user.",
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
self_reflect=False,
verbose=True,
tools=[get_stock_price, multiply],
stream=False # Force non-streaming mode - use stream parameter directly
)
result = agent.chat("Get the stock price of Google and multiply it by 2")
print(f"\nFinal result: {result}")
# Test with default streaming mode
print("\n\nTesting sequential tool calling with default streaming...")
agent2 = Agent(
instructions="You are a helpful assistant. You can use the tools provided to you to help the user.",
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
self_reflect=False,
verbose=True,
tools=[get_stock_price, multiply]
)
result2 = agent2.chat("Get the stock price of Google and multiply it by 2")
print(f"\nFinal result: {result2}")