diff --git a/cookbook/agents/14_generate_image.py b/cookbook/agents/14_generate_image.py index 1f8323155..642d62710 100644 --- a/cookbook/agents/14_generate_image.py +++ b/cookbook/agents/14_generate_image.py @@ -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) diff --git a/cookbook/chunking/__init__.py b/cookbook/chunking/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cookbook/mysql-init/init.sql b/cookbook/mysql-init/init.sql new file mode 100644 index 000000000..398c886a0 --- /dev/null +++ b/cookbook/mysql-init/init.sql @@ -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 +); diff --git a/cookbook/providers/ollama/agent_set_client.py b/cookbook/providers/ollama/agent_set_client.py new file mode 100644 index 000000000..3377811e6 --- /dev/null +++ b/cookbook/providers/ollama/agent_set_client.py @@ -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) diff --git a/cookbook/readers/__init__.py b/cookbook/readers/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cookbook/run_mysql.sh b/cookbook/run_mysql.sh new file mode 100755 index 000000000..908347566 --- /dev/null +++ b/cookbook/run_mysql.sh @@ -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 diff --git a/phi/model/ollama/chat.py b/phi/model/ollama/chat.py index acc744454..51f39089e 100644 --- a/phi/model/ollama/chat.py +++ b/phi/model/ollama/chat.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 1ca8e856e..f59e309b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"