diff --git a/cookbook/examples/autonomous/README.md b/cookbook/examples/autonomous/README.md deleted file mode 100644 index 8d9d96477..000000000 --- a/cookbook/examples/autonomous/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# Autonomous Assistant - -> Fork and clone the repository if needed. - -### 1. Create a virtual environment - -```shell -python3 -m venv ~/.venvs/aienv -source ~/.venvs/aienv/bin/activate -``` - -### 2. Install libraries - -```shell -pip install -U pgvector pypdf "psycopg[binary]" sqlalchemy openai phidata -``` - -### 3. Run PgVector - -> Install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) first. - -- Run using a helper script - -```shell -./cookbook/run_pgvector.sh -``` - -- OR run using the docker run command - -```shell -docker run -d \ - -e POSTGRES_DB=ai \ - -e POSTGRES_USER=ai \ - -e POSTGRES_PASSWORD=ai \ - -e PGDATA=/var/lib/postgresql/data/pgdata \ - -v pgvolume:/var/lib/postgresql/data \ - -p 5532:5432 \ - --name pgvector \ - phidata/pgvector:16 -``` - -### 4. Run Autonomous Assistant - -```shell -python cookbook/examples/autonomous/assistant.py -``` diff --git a/cookbook/examples/autonomous/__init__.py b/cookbook/examples/autonomous/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/cookbook/examples/autonomous/assistant.py b/cookbook/examples/autonomous/assistant.py deleted file mode 100644 index 0a8528238..000000000 --- a/cookbook/examples/autonomous/assistant.py +++ /dev/null @@ -1,22 +0,0 @@ -from phi.assistant import Assistant -from phi.knowledge.pdf import PDFUrlKnowledgeBase -from phi.vectordb.pgvector import PgVector2 - -knowledge_base = PDFUrlKnowledgeBase( - urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"], - vector_db=PgVector2(collection="recipes", db_url="postgresql+psycopg://ai:ai@localhost:5532/ai"), -) -knowledge_base.load(recreate=False) - -assistant = Assistant( - knowledge_base=knowledge_base, - # Show tool calls in the response - show_tool_calls=True, - # Enable the assistant to search the knowledge base - search_knowledge=True, - # Enable the assistant to read the chat history - read_chat_history=True, -) - -assistant.print_response("How do I make pad thai?", markdown=True) -assistant.print_response("What was my last question?", markdown=True) diff --git a/cookbook/examples/data_eng/README.md b/cookbook/examples/data_eng/README.md index 718c6ab8e..fdfb80103 100644 --- a/cookbook/examples/data_eng/README.md +++ b/cookbook/examples/data_eng/README.md @@ -1,44 +1,38 @@ -# Data Engineering AI +# Data Engineering Examples > Note: Fork and clone this repository if needed -1. Create a virtual environment +### Create a virtual environment ```shell python3 -m venv ~/.venvs/aienv source ~/.venvs/aienv/bin/activate ``` -2. Install libraries +### 2. Install libraries ```shell pip install -r cookbook/examples/data_eng/requirements.txt ``` -3. Run Python Assistant +### 3. Run DuckDb Assistant ```shell -python cookbook/examples/data_eng/python_assistant.py -``` - -Ask: - -```text -What is the average rating of movies? +python cookbook/examples/data_eng/duckdb_assistant.py ``` -4. Run DuckDb Assistant +### 4. Run Python Assistant ```shell -python cookbook/examples/data_eng/duckdb_assistant.py +python cookbook/examples/data_eng/python_assistant.py ``` Ask: ```text -What is the average rating of movies? Show me the SQL. +What is the average rating of movies? ``` -5. Message me on [discord](https://discord.gg/4MtYHHrgA8) if you have any questions +### 5. Message me on [discord](https://discord.gg/4MtYHHrgA8) if you have any questions -6. Star ⭐️ the project if you like it. +### 6. Star ⭐️ the project if you like it. diff --git a/cookbook/examples/data_eng/duckdb_assistant.py b/cookbook/examples/data_eng/duckdb_assistant.py index 01adc56a8..2d718d1a9 100644 --- a/cookbook/examples/data_eng/duckdb_assistant.py +++ b/cookbook/examples/data_eng/duckdb_assistant.py @@ -14,8 +14,12 @@ ] } ), + markdown=True, show_tool_calls=True, base_dir=Path(__file__).parent.joinpath("scratch"), ) -duckdb_assistant.cli_app(markdown=True) +# duckdb_assistant.cli_app() +duckdb_assistant.print_response("What is the average rating of movies? Show me the SQL?") +duckdb_assistant.print_response("Show me a histogram of movie ratings?") +duckdb_assistant.print_response("What are the top 5 movies?") diff --git a/cookbook/examples/data_eng/requirements.txt b/cookbook/examples/data_eng/requirements.txt index 49439bda7..a7a4ab97d 100644 --- a/cookbook/examples/data_eng/requirements.txt +++ b/cookbook/examples/data_eng/requirements.txt @@ -2,9 +2,9 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --strip-extras cookbook/examples/data_eng/requirements.in +# pip-compile cookbook/examples/data_eng/requirements.in # -altair==5.2.0 +altair==5.3.0 # via streamlit annotated-types==0.6.0 # via pydantic @@ -18,14 +18,7 @@ attrs==23.2.0 # referencing blinker==1.7.0 # via streamlit -boto3==1.34.45 - # via phidata -botocore==1.34.45 - # via - # boto3 - # phidata - # s3transfer -cachetools==5.3.2 +cachetools==5.3.3 # via streamlit certifi==2024.2.2 # via @@ -40,39 +33,31 @@ click==8.1.7 # typer distro==1.9.0 # via openai -docker==7.0.0 - # via phidata -duckdb==0.10.0 +duckdb==0.10.2 # via -r cookbook/examples/data_eng/requirements.in gitdb==4.0.11 # via gitpython -gitpython==3.1.42 +gitpython==3.1.43 # via # phidata # streamlit h11==0.14.0 # via httpcore -httpcore==1.0.3 +httpcore==1.0.5 # via httpx -httpx==0.26.0 +httpx==0.27.0 # via # openai # phidata -idna==3.6 +idna==3.7 # via # anyio # httpx # requests -importlib-metadata==7.0.1 - # via streamlit jinja2==3.1.3 # via # altair # pydeck -jmespath==1.0.1 - # via - # boto3 - # botocore jsonschema==4.21.1 # via altair jsonschema-specifications==2023.12.1 @@ -90,44 +75,40 @@ numpy==1.26.4 # pyarrow # pydeck # streamlit -openai==1.12.0 +openai==1.23.6 # via -r cookbook/examples/data_eng/requirements.in -packaging==23.2 +packaging==24.0 # via # altair - # docker # streamlit -pandas==2.2.0 +pandas==2.2.2 # via # -r cookbook/examples/data_eng/requirements.in # altair # streamlit phidata==2.3.83 # via -r cookbook/examples/data_eng/requirements.in -pillow==10.2.0 +pillow==10.3.0 # via streamlit protobuf==4.25.3 # via streamlit -pyarrow==15.0.0 +pyarrow==16.0.0 # via streamlit -pydantic==2.6.1 +pydantic==2.7.1 # via # openai # phidata # pydantic-settings -pydantic-core==2.16.2 +pydantic-core==2.18.2 # via pydantic pydantic-settings==2.2.1 # via phidata -pydeck==0.8.1b0 +pydeck==0.9.0b0 # via streamlit pygments==2.17.2 # via rich -python-dateutil==2.8.2 - # via - # botocore - # pandas - # streamlit +python-dateutil==2.9.0.post0 + # via pandas python-dotenv==1.0.1 # via # phidata @@ -136,36 +117,35 @@ pytz==2024.1 # via pandas pyyaml==6.0.1 # via phidata -referencing==0.33.0 +referencing==0.35.0 # via # jsonschema # jsonschema-specifications requests==2.31.0 - # via - # docker - # streamlit -rich==13.7.0 + # via streamlit +rich==13.7.1 # via # phidata # streamlit + # typer rpds-py==0.18.0 # via # jsonschema # referencing -s3transfer==0.10.0 - # via boto3 +shellingham==1.5.4 + # via typer six==1.16.0 # via python-dateutil smmap==5.0.1 # via gitdb -sniffio==1.3.0 +sniffio==1.3.1 # via # anyio # httpx # openai -sqlalchemy==2.0.27 +sqlalchemy==2.0.29 # via -r cookbook/examples/data_eng/requirements.in -streamlit==1.31.1 +streamlit==1.33.0 # via -r cookbook/examples/data_eng/requirements.in tenacity==8.2.3 # via streamlit @@ -179,9 +159,9 @@ tornado==6.4 # via streamlit tqdm==4.66.2 # via openai -typer==0.9.0 +typer==0.12.3 # via phidata -typing-extensions==4.9.0 +typing-extensions==4.11.0 # via # openai # phidata @@ -192,14 +172,5 @@ typing-extensions==4.9.0 # typer tzdata==2024.1 # via pandas -tzlocal==5.2 - # via streamlit -urllib3==2.0.7 - # via - # botocore - # docker - # requests -validators==0.22.0 - # via streamlit -zipp==3.17.0 - # via importlib-metadata +urllib3==2.2.1 + # via requests