Skip to content

Commit

Permalink
v2.5.32
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Nov 14, 2024
1 parent c3f9639 commit 3cf86a9
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/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=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
tools=[YFinanceTools(stock_price=True)],
show_tool_calls=True,
markdown=True,
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/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=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
tools=[YFinanceTools(stock_price=True)],
instructions=["Use tables where possible."],
markdown=True,
Expand Down
4 changes: 2 additions & 2 deletions cookbook/providers/ollama_tools/agent_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
web_agent = Agent(
name="Web Agent",
role="Search the web for information",
model=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
tools=[DuckDuckGo()],
instructions=["Always include sources"],
show_tool_calls=True,
Expand All @@ -16,7 +16,7 @@
finance_agent = Agent(
name="Finance Agent",
role="Get financial data",
model=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
instructions=["Use tables to display data"],
show_tool_calls=True,
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from phi.agent import Agent, RunResponse # noqa
from phi.model.ollama import OllamaTools

agent = Agent(model=OllamaTools(id="llama3.2"), markdown=True)
agent = Agent(model=OllamaTools(id="llama3.1:8b"), markdown=True)

# Get the response in a variable
# run: RunResponse = agent.run("Share a 2 sentence horror story")
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/basic_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from phi.agent import Agent, RunResponse # noqa
from phi.model.ollama import OllamaTools

agent = Agent(model=OllamaTools(id="llama3.2"), markdown=True)
agent = Agent(model=OllamaTools(id="llama3.1:8b"), markdown=True)

# Get the response in a variable
# run_response: Iterator[RunResponse] = agent.run("Share a 2 sentence horror story", stream=True)
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/data_analyst.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

agent = Agent(
model=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
tools=[duckdb_tools],
markdown=True,
show_tool_calls=True,
Expand Down
10 changes: 4 additions & 6 deletions cookbook/providers/ollama_tools/finance_agent.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
"""Run `pip install yfinance` to install dependencies."""
"""Run `pip install yfinance ollama phidata` to install dependencies."""

from phi.agent import Agent
from phi.model.ollama import OllamaTools
from phi.tools.yfinance import YFinanceTools

agent = Agent(
model=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True)],
show_tool_calls=True,
description="You are an investment analyst that researches stocks and helps users make informed decisions.",
instructions=["Use tables to display data where possible."],
instructions=["Use tables to display data"],
markdown=True,
)

# agent.print_response("Share the NVDA stock price and analyst recommendations", stream=True)
agent.print_response("Summarize fundamentals for TSLA", stream=True)
agent.print_response("Share fundamentals and analyst recommendations for TSLA in a table", stream=True)
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
knowledge_base.load(recreate=False) # Comment out after first run

agent = Agent(
model=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
knowledge_base=knowledge_base,
use_tools=True,
show_tool_calls=True,
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

agent = Agent(
model=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
storage=PgAgentStorage(table_name="agent_sessions", db_url=db_url),
tools=[DuckDuckGo()],
add_history_to_messages=True,
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/structured_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MovieScript(BaseModel):

# Agent that uses JSON mode
movie_agent = Agent(
model=OllamaTools(id="llama3.2"),
model=OllamaTools(id="llama3.1:8b"),
description="You write movie scripts.",
response_model=MovieScript,
)
Expand Down
2 changes: 1 addition & 1 deletion cookbook/providers/ollama_tools/web_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
from phi.model.ollama import OllamaTools
from phi.tools.duckduckgo import DuckDuckGo

agent = Agent(model=OllamaTools(id="llama3.2"), tools=[DuckDuckGo()], show_tool_calls=True, markdown=True)
agent = Agent(model=OllamaTools(id="llama3.1:8b"), tools=[DuckDuckGo()], show_tool_calls=True, markdown=True)
agent.print_response("Whats happening in France?", stream=True)
4 changes: 2 additions & 2 deletions phi/tools/duckduckgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
if news:
self.register(self.duckduckgo_news)

def duckduckgo_search(self, query: str, max_results: int = 5) -> str:
def duckduckgo_search(self, query: str, max_results: Optional[int] = 5) -> str:
"""Use this function to search DuckDuckGo for a query.
Args:
Expand All @@ -47,7 +47,7 @@ def duckduckgo_search(self, query: str, max_results: int = 5) -> str:
ddgs = DDGS(headers=self.headers, proxy=self.proxy, proxies=self.proxies, timeout=self.timeout)
return json.dumps(ddgs.text(keywords=query, max_results=(self.fixed_max_results or max_results)), indent=2)

def duckduckgo_news(self, query: str, max_results: int = 5) -> str:
def duckduckgo_news(self, query: str, max_results: Optional[int] = 5) -> str:
"""Use this function to get the latest news from DuckDuckGo.
Args:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "phidata"
version = "2.5.31"
version = "2.5.32"
description = "Build AI Agents with memory, knowledge and tools."
requires-python = ">=3.7"
readme = "README.md"
Expand Down

0 comments on commit 3cf86a9

Please sign in to comment.