Skip to content
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

openrouter claude3.5 tool use failed #1104

Open
wangdake5111 opened this issue Aug 21, 2024 · 1 comment
Open

openrouter claude3.5 tool use failed #1104

wangdake5111 opened this issue Aug 21, 2024 · 1 comment

Comments

@wangdake5111
Copy link

When I use the the model 'anthropic/claude-3.5-sonnet' of openrouter to use tool yfinance,

from phi.assistant import Assistant
from phi.llm.openrouter import OpenRouter
from phi.tools.yfinance import YFinanceTools
assistant = Assistant(
    llm=OpenRouter(model="anthropic/claude-3.5-sonnet"),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
    show_tool_calls=True,
    debug_mode=True,
    markdown=True,
)
assistant.print_response("What is the stock price of NVDA")
assistant.print_response("Write a comparison between NVDA and AMD, use all tools available.")

there will be an error
CleanShot 2024-08-21 at 20 18 41@2x
Missing required argument [type=missing_argument, input_value=ArgsKwargs(()), input_type=ArgsKwargs]
I see in the debug mode, this is the output:

Tool Calls: [
           {
             "id": "toolu_016QmLxNKSHwVwzCEiUadoAx",
             "type": "function",
             "function": {
               "name": "get_current_stock_price",
               "arguments": ""
             }
           },
           {
             "id": null,
             "type": "function",
             "function": {
               "arguments": "{\"symbol\": \"NVDA\"}"
             }
           }
         ]

It seems the func and arguments separated.
But if I use 'openai/gpt-4o', it will work well.
Also, if I use 'anthropic/claude-3.5-sonnet' with tool DuckDuckGo, it will work well.

@ysolanky
Copy link
Contributor

@wangdake5111 it looks like anthropic/claude-3.5-sonnet is making an incorrect function call, which is resulting in the pydantic error that you shared.

Could you please try updating the tools to the following and sharing your result?
tools=[YFinanceTools(stock_price=True)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants