phidatahq / phidata

Build AI Assistants with memory, knowledge and tools.
https://docs.phidata.com
Mozilla Public License 2.0
10.45k stars 1.51k forks source link

Query not being passed to `duckduckgo_search` #998

Open slashtechno opened 1 month ago

slashtechno commented 1 month ago

I've been testing Phidata with Ollama. Whilst the code sometimes works, trying to perform a query using the LLM often results in it calling duckduckgo_search without any arguments, causing an error.

 😎 User : Weather in New York City
WARNING  Could not run function duckduckgo_search()
ERROR    1 validation error for duckduckgo_search
         query
           Missing required argument [type=missing_argument, input_value=ArgsKwargs(()), input_type=ArgsKwargs]
             For further information visit https://errors.pydantic.dev/2.7/v/missing_argument
         Traceback (most recent call last):
           File "...\phidata-testing\.venv\Lib\site-packages\phi\tools\function.py", line 150, in execute
             self.result = self.function.entrypoint(**self.arguments)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "...\phidata-testing\.venv\Lib\site-packages\pydantic\validate_call_decorator.py", line  
         59, in wrapper_function
             return validate_call_wrapper(*args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "...\phidata-testing\.venv\Lib\site-packages\pydantic\_internal\_validate_call.py", line 
         81, in __call__
             res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pydantic_core._pydantic_core.ValidationError: 1 validation error for duckduckgo_search
         query
           Missing required argument [type=missing_argument, input_value=ArgsKwargs(()), input_type=ArgsKwargs]
             For further information visit https://errors.pydantic.dev/2.7/v/missing_argument
╭──────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Message  │ Weather in New York City                                                                                                   │
├──────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Response │ I apologize for not being able to provide the weather information in my previous response. It seems that there was an      │
│ (8.9s)   │ error with the "duckduckgo_search" function.                                                                               │
│          │                                                                                                                            │
│          │ Let me try again! Here's a new attempt:                                                                                    │
│          │                                                                                                                            │
│          │ I hope this one is successful!Here's a summary of the weather forecast for New York City:                                  │
│          │                                                                                                                            │
│          │ The current weather conditions in New York City are fair with a temperature of 70°F (21°C) and humidity of 47%. The wind   │
│          │ speed is moderate, coming from the northeast at 3 mph. There is no active alert.                                           │
│          │                                                                                                                            │
│          │ For the next few days, there is a chance of showers this afternoon, followed by showers likely tonight. Tomorrow will be   │
│          │ mostly cloudy with a high temperature of 72°F (22°C) and a low of 61°F (16°C).                                             │
│          │                                                                                                                            │
│          │ Additionally, you can check the hourly weather forecast or the extended forecast for more detailed information.            │
│          │                                                                                                                            │
│          │ Source: National Weather Service and AccuWeather.                                                                          │
│          │                                                                                                                            │
│          │ I hope this helps!                                                                                                         │
╰──────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Here's the code I'm using:

from phi.assistant import Assistant
from phi.tools.duckduckgo import DuckDuckGo
from phi.llm.ollama import OllamaTools

model = "llama3"

assistant = Assistant(
    llm=OllamaTools(model=model),
    tools=[DuckDuckGo(search=True, news=True)],
    show_tool_calls=False,
    read_chat_history=True,
    read_tool_call_history=True,
)
assistant.cli_app(markdown=False)
ysolanky commented 3 weeks ago

Hey @slashtechno, could you please try running the following code:

from phi.assistant import Assistant
from phi.tools.duckduckgo import DuckDuckGo
from phi.llm.ollama import Ollama

model = "llama3"

assistant = Assistant(
    llm=Ollama(model=model),
    tools=[DuckDuckGo(search=True, news=True)],
    show_tool_calls=False,
    read_chat_history=True,
    read_tool_call_history=True,
)
assistant.cli_app(markdown=False)
slashtechno commented 3 weeks ago

I'm currently travelling and won't have access to my machine with Ollama for a while, sorry. Is the only change using Ollama instead of OllamaTools? If I rememeber correctly, I tried Ollama with llama3 to no avail.