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

Release 2.7.5 #1617

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions cookbook/agents/14_generate_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,5 @@
images = image_agent.get_images()
if images and isinstance(images, list):
for image_response in images:
image_data = image_response.get("data") # type: ignore
if image_data:
for image in image_data:
image_url = image.get("url") # type: ignore
if image_url:
print(image_url)
image_url = image_response.url
print(image_url)
Empty file added cookbook/chunking/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions cookbook/mysql-init/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Create 'users' table
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(100) NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Create 'products' table
CREATE TABLE IF NOT EXISTS products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
description TEXT,
price DECIMAL(10,2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
18 changes: 18 additions & 0 deletions cookbook/providers/ollama/agent_set_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Run `pip install yfinance` to install dependencies."""

from ollama import Client as OllamaClient
from phi.agent import Agent, RunResponse # noqa
from phi.model.ollama import Ollama
from phi.playground import Playground, serve_playground_app
from phi.tools.yfinance import YFinanceTools

agent = Agent(
model=Ollama(id="llama3.1:8b", client=OllamaClient()),
tools=[YFinanceTools(stock_price=True)],
markdown=True,
)

app = Playground(agents=[agent]).get_app()

if __name__ == "__main__":
serve_playground_app("agent_set_client:app", reload=True)
Empty file added cookbook/readers/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions cookbook/run_mysql.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a convenience for users

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docker run -d \
-e MYSQL_ROOT_PASSWORD=phi \
-e MYSQL_DATABASE=phi \
-e MYSQL_USER=phi \
-e MYSQL_PASSWORD=phi \
-p 3306:3306 \
-v mysql_data:/var/lib/mysql \
-v $(pwd)/cookbook/mysql-init:/docker-entrypoint-initdb.d \
--name mysql \
mysql:8.0
1 change: 0 additions & 1 deletion cookbook/tools/composio_tools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from phi.agent import Agent
from composio_phidata import Action, ComposioToolSet # type: ignore


toolset = ComposioToolSet()
composio_tools = toolset.get_tools(actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER])

Expand Down
4 changes: 4 additions & 0 deletions phi/model/ollama/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,3 +722,7 @@ async def aresponse_stream(self, messages: List[Message]) -> Any:
async for post_tool_call_response in self.ahandle_post_tool_call_messages_stream(messages=messages):
yield post_tool_call_response
logger.debug("---------- Ollama Async Response End ----------")

def model_copy(self, *, update: Optional[dict[str, Any]] = None, deep: bool = False) -> "Ollama":
new_model = Ollama(**self.model_dump(exclude={"client"}), client=self.client)
return new_model
13 changes: 10 additions & 3 deletions phi/tools/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Function(BaseModel):
# The parameters the functions accepts, described as a JSON Schema object.
# To describe a function that accepts no parameters, provide the value {"type": "object", "properties": {}}.
parameters: Dict[str, Any] = Field(
default_factory=lambda: {"type": "object", "properties": {}},
default_factory=lambda: {"type": "object", "properties": {}, "required": []},
description="JSON Schema object describing function parameters",
)
strict: Optional[bool] = None
Expand Down Expand Up @@ -139,6 +139,12 @@ def process_entrypoint(self, strict: bool = False):
return

parameters = {"type": "object", "properties": {}, "required": []}

params_set_by_user = False
# If the user set the parameters (i.e. they are different from the default), we should keep them
if self.parameters != parameters:
params_set_by_user = True

try:
sig = signature(self.entrypoint)
type_hints = get_type_hints(self.entrypoint)
Expand Down Expand Up @@ -174,8 +180,9 @@ def process_entrypoint(self, strict: bool = False):
except Exception as e:
logger.warning(f"Could not parse args for {self.name}: {e}", exc_info=True)

self.description = getdoc(self.entrypoint) or self.description
self.parameters = parameters
self.description = self.description or getdoc(self.entrypoint)
if not params_set_by_user:
self.parameters = parameters
self.entrypoint = validate_call(self.entrypoint)

def get_type_name(self, t: Type[T]):
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.7.4"
version = "2.7.5"
description = "Build multi-modal Agents with memory, knowledge and tools."
requires-python = ">=3.7"
readme = "README.md"
Expand Down
Loading