diff --git a/cookbook/providers/ollama/agent_stream.py b/cookbook/providers/ollama/agent_stream.py index 13c8e1060..d39e0b46e 100644 --- a/cookbook/providers/ollama/agent_stream.py +++ b/cookbook/providers/ollama/agent_stream.py @@ -3,6 +3,7 @@ from typing import Iterator # noqa from phi.agent import Agent, RunResponse # noqa from phi.model.ollama import Ollama +from phi.tools.crawl4ai_tools import Crawl4aiTools from phi.tools.yfinance import YFinanceTools agent = Agent( @@ -20,3 +21,10 @@ # Print the response in the terminal agent.print_response("What are analyst recommendations for NVDA and TSLA", stream=True) + + +agent = Agent(model=Ollama(id="llama3.1:8b"), tools=[Crawl4aiTools(max_length=1000)], show_tool_calls=True) +agent.print_response( + "Summarize me the key points in bullet points of this: https://blog.google/products/gemini/google-gemini-deep-research/", + stream=True, +) diff --git a/phi/model/ollama/chat.py b/phi/model/ollama/chat.py index 4c5c809da..acc744454 100644 --- a/phi/model/ollama/chat.py +++ b/phi/model/ollama/chat.py @@ -134,6 +134,11 @@ def request_kwargs(self) -> Dict[str, Any]: request_params["keep_alive"] = self.keep_alive if self.tools is not None: request_params["tools"] = self.get_tools_for_api() + # Ensure types are valid strings + for tool in request_params["tools"]: + for prop, obj in tool["function"]["parameters"]["properties"].items(): + if isinstance(obj["type"], list): + obj["type"] = obj["type"][0] if self.request_params is not None: request_params.update(self.request_params) return request_params diff --git a/phi/tools/function.py b/phi/tools/function.py index 89520833e..a8174e147 100644 --- a/phi/tools/function.py +++ b/phi/tools/function.py @@ -158,7 +158,6 @@ def process_entrypoint(self, strict: bool = False): # Get JSON schema for parameters only parameters = get_json_schema(type_hints=param_type_hints, strict=strict) - # If strict=True mark all fields as required # See: https://platform.openai.com/docs/guides/structured-outputs/supported-schemas#all-fields-must-be-required if strict: