Merge pull request #110 from Madhuvod/phidata-agno
Move phidata to Agno + few old error corrections
This commit is contained in:
commit
641cc1a35e
69 changed files with 276 additions and 275 deletions
|
|
@ -0,0 +1,7 @@
|
||||||
|
scrapegraphai
|
||||||
|
playwright
|
||||||
|
langchain-community
|
||||||
|
streamlit-chat
|
||||||
|
streamlit
|
||||||
|
crewai
|
||||||
|
ollama
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
streamlit
|
streamlit
|
||||||
"routellm[serve,eval]"
|
"routellm[serve,eval]"
|
||||||
|
routellm
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
import os
|
import os
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.llm.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
from phi.tools.yfinance import YFinanceTools
|
from agno.tools.yfinance import YFinanceTools
|
||||||
from phi.tools.serpapi_tools import SerpApiTools
|
from agno.tools.serpapi import SerpApiTools
|
||||||
|
|
||||||
st.set_page_config(page_title="Llama-3 Tool Use", page_icon="🦙")
|
st.set_page_config(page_title="Llama-3 Tool Use", page_icon="🦙")
|
||||||
|
|
||||||
|
|
@ -13,9 +13,9 @@ if 'SERPAPI_API_KEY' not in os.environ:
|
||||||
st.stop()
|
st.stop()
|
||||||
|
|
||||||
def get_assistant(tools):
|
def get_assistant(tools):
|
||||||
return Assistant(
|
return Agent(
|
||||||
name="llama3_assistant",
|
name="llama3_assistant",
|
||||||
llm=Ollama(model="llama3"),
|
model=Ollama(id="llama3.1:8b"),
|
||||||
tools=tools,
|
tools=tools,
|
||||||
description="You are a helpful assistant that can access specific tools based on user selection.",
|
description="You are a helpful assistant that can access specific tools based on user selection.",
|
||||||
show_tool_calls=True,
|
show_tool_calls=True,
|
||||||
|
|
@ -25,7 +25,7 @@ def get_assistant(tools):
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
st.title("🦙 Local Llama-3 Tool Use")
|
st.title("🦙 Local Llama-3.1 Tool Use")
|
||||||
st.markdown("""
|
st.markdown("""
|
||||||
This app demonstrates function calling with the local Llama3 model using Ollama.
|
This app demonstrates function calling with the local Llama3 model using Ollama.
|
||||||
Select tools in the sidebar and ask relevant questions!
|
Select tools in the sidebar and ask relevant questions!
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
streamlit
|
streamlit
|
||||||
ollama
|
ollama
|
||||||
phidata
|
agno
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from phi.llm.anthropic import Claude
|
from agno.models.anthropic import Claude
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("Claude Sonnet + AI Web Search 🤖")
|
st.title("Claude Sonnet + AI Web Search 🤖")
|
||||||
|
|
@ -13,12 +13,12 @@ anthropic_api_key = st.text_input("Anthropic's Claude API Key", type="password")
|
||||||
|
|
||||||
# If Anthropic API key is provided, create an instance of Assistant
|
# If Anthropic API key is provided, create an instance of Assistant
|
||||||
if anthropic_api_key:
|
if anthropic_api_key:
|
||||||
assistant = Assistant(
|
assistant = Agent(
|
||||||
llm=Claude(
|
model=Claude(
|
||||||
model="claude-3-5-sonnet-20240620",
|
id="claude-3-5-sonnet-20240620",
|
||||||
max_tokens=1024,
|
max_tokens=1024,
|
||||||
temperature=0.9,
|
temperature=0.3,
|
||||||
api_key=anthropic_api_key) , tools=[DuckDuckGo()], show_tool_calls=True
|
api_key=anthropic_api_key) , tools=[DuckDuckGoTools()], show_tool_calls=True
|
||||||
)
|
)
|
||||||
# Get the search query from the user
|
# Get the search query from the user
|
||||||
query= st.text_input("Enter the Search Query", type="default")
|
query= st.text_input("Enter the Search Query", type="default")
|
||||||
|
|
@ -26,4 +26,4 @@ if anthropic_api_key:
|
||||||
if query:
|
if query:
|
||||||
# Search the web using the AI Assistant
|
# Search the web using the AI Assistant
|
||||||
response = assistant.run(query, stream=False)
|
response = assistant.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("AI Web Search Assistant 🤖")
|
st.title("AI Web Search Assistant 🤖")
|
||||||
|
|
@ -14,12 +14,12 @@ openai_access_token = st.text_input("OpenAI API Key", type="password")
|
||||||
# If OpenAI API key is provided, create an instance of Assistant
|
# If OpenAI API key is provided, create an instance of Assistant
|
||||||
if openai_access_token:
|
if openai_access_token:
|
||||||
# Create an instance of the Assistant
|
# Create an instance of the Assistant
|
||||||
assistant = Assistant(
|
assistant = Agent(
|
||||||
llm=OpenAIChat(
|
model=OpenAIChat(
|
||||||
model="gpt-4o",
|
id="gpt-4o",
|
||||||
max_tokens=1024,
|
max_tokens=1024,
|
||||||
temperature=0.9,
|
temperature=0.9,
|
||||||
api_key=openai_access_token) , tools=[DuckDuckGo()], show_tool_calls=True
|
api_key=openai_access_token) , tools=[DuckDuckGoTools()], show_tool_calls=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get the search query from the user
|
# Get the search query from the user
|
||||||
|
|
@ -28,4 +28,4 @@ if openai_access_token:
|
||||||
if query:
|
if query:
|
||||||
# Search the web using the AI Assistant
|
# Search the web using the AI Assistant
|
||||||
response = assistant.run(query, stream=False)
|
response = assistant.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
streamlit
|
streamlit
|
||||||
openai
|
openai
|
||||||
phidata
|
agno
|
||||||
duckduckgo-search
|
duckduckgo-search
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# 📊 AI Data Analysis Agent
|
# 📊 AI Data Analysis Agent
|
||||||
|
|
||||||
An AI data analysis Agent built using the phidata Agent framework and Openai's gpt-4o model. This agent helps users analyze their data - csv, excel files through natural language queries, powered by OpenAI's language models and DuckDB for efficient data processing - making data analysis accessible to users regardless of their SQL expertise.
|
An AI data analysis Agent built using the Agno Agent framework and Openai's gpt-4o model. This agent helps users analyze their data - csv, excel files through natural language queries, powered by OpenAI's language models and DuckDB for efficient data processing - making data analysis accessible to users regardless of their SQL expertise.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import tempfile
|
||||||
import csv
|
import csv
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.agent.duckdb import DuckDbAgent
|
from phi.agent.duckdb import DuckDbAgent
|
||||||
from phi.tools.pandas import PandasTools
|
from agno.tools.pandas import PandasTools
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Function to preprocess and save the uploaded file
|
# Function to preprocess and save the uploaded file
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
phidata==2.7.3
|
phidata
|
||||||
streamlit==1.41.1
|
streamlit==1.41.1
|
||||||
openai==1.58.1
|
openai==1.58.1
|
||||||
duckdb==1.1.3
|
duckdb==1.1.3
|
||||||
pandas
|
pandas
|
||||||
numpy==1.26.4
|
numpy==1.26.4
|
||||||
|
agno
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.storage.agent.sqlite import SqlAgentStorage
|
from agno.storage.agent.sqlite import SqliteAgentStorage
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from phi.tools.yfinance import YFinanceTools
|
from agno.tools.yfinance import YFinanceTools
|
||||||
from phi.playground import Playground, serve_playground_app
|
from agno.playground import Playground, serve_playground_app
|
||||||
|
|
||||||
web_agent = Agent(
|
web_agent = Agent(
|
||||||
name="Web Agent",
|
name="Web Agent",
|
||||||
role="Search the web for information",
|
role="Search the web for information",
|
||||||
model=OpenAIChat(id="gpt-4o"),
|
model=OpenAIChat(id="gpt-4o"),
|
||||||
tools=[DuckDuckGo()],
|
tools=[DuckDuckGoTools()],
|
||||||
storage=SqlAgentStorage(table_name="web_agent", db_file="agents.db"),
|
storage=SqliteAgentStorage(table_name="web_agent", db_file="agents.db"),
|
||||||
add_history_to_messages=True,
|
add_history_to_messages=True,
|
||||||
markdown=True,
|
markdown=True,
|
||||||
)
|
)
|
||||||
|
|
@ -21,7 +21,7 @@ finance_agent = Agent(
|
||||||
model=OpenAIChat(id="gpt-4o"),
|
model=OpenAIChat(id="gpt-4o"),
|
||||||
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
|
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
|
||||||
instructions=["Always use tables to display data"],
|
instructions=["Always use tables to display data"],
|
||||||
storage=SqlAgentStorage(table_name="finance_agent", db_file="agents.db"),
|
storage=SqliteAgentStorage(table_name="finance_agent", db_file="agents.db"),
|
||||||
add_history_to_messages=True,
|
add_history_to_messages=True,
|
||||||
markdown=True,
|
markdown=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
openai
|
openai
|
||||||
phidata
|
agno
|
||||||
duckduckgo-search
|
duckduckgo-search
|
||||||
yfinance
|
yfinance
|
||||||
fastapi[standard]
|
fastapi[standard]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# AI Health & Fitness Planner Agent 🏋️♂️
|
# AI Health & Fitness Planner Agent 🏋️♂️
|
||||||
|
|
||||||
The **AI Health & Fitness Planner** is a personalized health and fitness Agent powered by Phidata's AI Agent framework. This app generates tailored dietary and fitness plans based on user inputs such as age, weight, height, activity level, dietary preferences, and fitness goals.
|
The **AI Health & Fitness Planner** is a personalized health and fitness Agent powered by Agno AI Agent framework. This app generates tailored dietary and fitness plans based on user inputs such as age, weight, height, activity level, dietary preferences, and fitness goals.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ The **AI Health & Fitness Planner** is a personalized health and fitness Agent p
|
||||||
|
|
||||||
The application requires the following Python libraries:
|
The application requires the following Python libraries:
|
||||||
|
|
||||||
- `phidata`
|
- `agno`
|
||||||
- `google-generativeai`
|
- `google-generativeai`
|
||||||
- `streamlit`
|
- `streamlit`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.google import Gemini
|
from agno.models.google import Gemini
|
||||||
|
|
||||||
st.set_page_config(
|
st.set_page_config(
|
||||||
page_title="AI Health & Fitness Planner",
|
page_title="AI Health & Fitness Planner",
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
phidata==2.5.33
|
|
||||||
google-generativeai==0.8.3
|
google-generativeai==0.8.3
|
||||||
streamlit==1.40.2
|
streamlit==1.40.2
|
||||||
|
agno
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
## 📈 AI Investment Agent
|
## 📈 AI Investment Agent
|
||||||
This Streamlit app is an AI-powered investment agent that compares the performance of two stocks and generates detailed reports. By using GPT-4o with Yahoo Finance data, this app provides valuable insights to help you make informed investment decisions.
|
This Streamlit app is an AI-powered investment agent built with Agno's AI Agent framework that compares the performance of two stocks and generates detailed reports. By using GPT-4o with Yahoo Finance data, this app provides valuable insights to help you make informed investment decisions.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
- Compare the performance of two stocks
|
- Compare the performance of two stocks
|
||||||
|
|
@ -32,7 +32,7 @@ streamlit run investment_agent.py
|
||||||
### How it Works?
|
### How it Works?
|
||||||
|
|
||||||
- Upon running the app, you will be prompted to enter your OpenAI API key. This key is used to authenticate and access the OpenAI language model.
|
- Upon running the app, you will be prompted to enter your OpenAI API key. This key is used to authenticate and access the OpenAI language model.
|
||||||
- Once you provide a valid API key, an instance of the Assistant class is created. This assistant utilizes the GPT-4 language model from OpenAI and the YFinanceTools for accessing stock data.
|
- Once you provide a valid API key, an instance of the Assistant class is created. This assistant utilizes the GPT-4o language model from OpenAI and the YFinanceTools for accessing stock data.
|
||||||
- Enter the stock symbols of the two companies you want to compare in the provided text input fields.
|
- Enter the stock symbols of the two companies you want to compare in the provided text input fields.
|
||||||
- The assistant will perform the following steps:
|
- The assistant will perform the following steps:
|
||||||
- Retrieve real-time stock prices and historical data using YFinanceTools
|
- Retrieve real-time stock prices and historical data using YFinanceTools
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Assistant
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.tools.yfinance import YFinanceTools
|
from agno.tools.yfinance import YFinanceTools
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("AI Investment Agent 📈🤖")
|
st.title("AI Investment Agent 📈🤖")
|
||||||
|
|
@ -27,4 +27,4 @@ if openai_api_key:
|
||||||
# Get the response from the assistant
|
# Get the response from the assistant
|
||||||
query = f"Compare {stock1} to {stock2}. Use every tool you have."
|
query = f"Compare {stock1} to {stock2}. Use every tool you have."
|
||||||
response = assistant.run(query, stream=False)
|
response = assistant.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
openai
|
openai
|
||||||
yfinance
|
yfinance
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.serpapi_tools import SerpApiTools
|
from agno.tools.serpapi import SerpApiTools
|
||||||
from phi.tools.newspaper4k import Newspaper4k as NewspaperToolkit
|
from agno.tools.newspaper4k import Newspaper4kTools
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("AI Journalist Agent 🗞️")
|
st.title("AI Journalist Agent 🗞️")
|
||||||
|
|
@ -17,10 +17,10 @@ openai_api_key = st.text_input("Enter OpenAI API Key to access GPT-4o", type="pa
|
||||||
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
||||||
|
|
||||||
if openai_api_key and serp_api_key:
|
if openai_api_key and serp_api_key:
|
||||||
searcher = Assistant(
|
searcher = Agent(
|
||||||
name="Searcher",
|
name="Searcher",
|
||||||
role="Searches for top URLs based on a topic",
|
role="Searches for top URLs based on a topic",
|
||||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a world-class journalist for the New York Times. Given a topic, generate a list of 3 search terms
|
You are a world-class journalist for the New York Times. Given a topic, generate a list of 3 search terms
|
||||||
|
|
@ -37,10 +37,10 @@ if openai_api_key and serp_api_key:
|
||||||
tools=[SerpApiTools(api_key=serp_api_key)],
|
tools=[SerpApiTools(api_key=serp_api_key)],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
)
|
)
|
||||||
writer = Assistant(
|
writer = Agent(
|
||||||
name="Writer",
|
name="Writer",
|
||||||
role="Retrieves text from URLs and writes a high-quality article",
|
role="Retrieves text from URLs and writes a high-quality article",
|
||||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a senior writer for the New York Times. Given a topic and a list of URLs,
|
You are a senior writer for the New York Times. Given a topic and a list of URLs,
|
||||||
|
|
@ -57,15 +57,14 @@ if openai_api_key and serp_api_key:
|
||||||
"Focus on clarity, coherence, and overall quality.",
|
"Focus on clarity, coherence, and overall quality.",
|
||||||
"Never make up facts or plagiarize. Always provide proper attribution.",
|
"Never make up facts or plagiarize. Always provide proper attribution.",
|
||||||
],
|
],
|
||||||
tools=[NewspaperToolkit()],
|
tools=[Newspaper4kTools()],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
add_chat_history_to_prompt=True,
|
markdown=True,
|
||||||
num_history_messages=3,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
editor = Assistant(
|
editor = Agent(
|
||||||
name="Editor",
|
name="Editor",
|
||||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||||
team=[searcher, writer],
|
team=[searcher, writer],
|
||||||
description="You are a senior NYT editor. Given a topic, your goal is to write a NYT worthy article.",
|
description="You are a senior NYT editor. Given a topic, your goal is to write a NYT worthy article.",
|
||||||
instructions=[
|
instructions=[
|
||||||
|
|
@ -88,4 +87,4 @@ if openai_api_key and serp_api_key:
|
||||||
with st.spinner("Processing..."):
|
with st.spinner("Processing..."):
|
||||||
# Get the response from the assistant
|
# Get the response from the assistant
|
||||||
response = editor.run(query, stream=False)
|
response = editor.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
openai
|
openai
|
||||||
google-search-results
|
google-search-results
|
||||||
newspaper4k
|
newspaper4k
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
import requests
|
import requests
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.tools.firecrawl import FirecrawlTools
|
from agno.tools.firecrawl import FirecrawlTools
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from firecrawl import FirecrawlApp
|
from firecrawl import FirecrawlApp
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
firecrawl-py==1.9.0
|
firecrawl-py==1.9.0
|
||||||
phidata==2.7.3
|
agno
|
||||||
composio-phidata==0.6.15
|
composio-phidata
|
||||||
composio==0.1.1
|
composio==0.1.1
|
||||||
pydantic==2.10.5
|
pydantic==2.10.5
|
||||||
streamlit
|
streamlit
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.knowledge.pdf import PDFKnowledgeBase, PDFReader
|
from agno.knowledge.pdf import PDFKnowledgeBase, PDFReader
|
||||||
from phi.vectordb.qdrant import Qdrant
|
from agno.vectordb.qdrant import Qdrant
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.embedder.openai import OpenAIEmbedder
|
from agno.embedder.openai import OpenAIEmbedder
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ def main():
|
||||||
name="Legal Researcher",
|
name="Legal Researcher",
|
||||||
role="Legal research specialist",
|
role="Legal research specialist",
|
||||||
model=OpenAIChat(model="gpt-4o"),
|
model=OpenAIChat(model="gpt-4o"),
|
||||||
tools=[DuckDuckGo()],
|
tools=[DuckDuckGoTools()],
|
||||||
knowledge=st.session_state.knowledge_base,
|
knowledge=st.session_state.knowledge_base,
|
||||||
search_knowledge=True,
|
search_knowledge=True,
|
||||||
instructions=[
|
instructions=[
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.knowledge.pdf import PDFKnowledgeBase, PDFReader
|
from agno.knowledge.pdf import PDFKnowledgeBase, PDFReader
|
||||||
from phi.vectordb.qdrant import Qdrant
|
from agno.vectordb.qdrant import Qdrant
|
||||||
from phi.model.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
from phi.embedder.ollama import OllamaEmbedder
|
from agno.embedder.ollama import OllamaEmbedder
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
phidata==2.6.7
|
agno
|
||||||
streamlit==1.40.2
|
streamlit==1.40.2
|
||||||
qdrant-client==1.12.1
|
qdrant-client==1.12.1
|
||||||
ollama==0.4.4
|
ollama==0.4.4
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
phidata==2.5.33
|
agno
|
||||||
streamlit==1.40.2
|
streamlit==1.40.2
|
||||||
qdrant-client==1.12.1
|
qdrant-client==1.12.1
|
||||||
openai
|
openai
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# 🩻 Medical Imaging Diagnosis Agent
|
# 🩻 Medical Imaging Diagnosis Agent
|
||||||
|
|
||||||
A Medical Imaging Diagnosis Agent build on phidata powered by Gemini 2.0 Flash Experimental that provides AI-assisted analysis of medical images of various scans. The agent acts as a medical imaging diagnosis expert to analyze various types of medical images and videos, providing detailed diagnostic insights and explanations.
|
A Medical Imaging Diagnosis Agent build on agno powered by Gemini 2.0 Flash Experimental that provides AI-assisted analysis of medical images of various scans. The agent acts as a medical imaging diagnosis expert to analyze various types of medical images and videos, providing detailed diagnostic insights and explanations.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import os
|
import os
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.google import Gemini
|
from agno.models.google import Gemini
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
|
|
||||||
if "GOOGLE_API_KEY" not in st.session_state:
|
if "GOOGLE_API_KEY" not in st.session_state:
|
||||||
st.session_state.GOOGLE_API_KEY = None
|
st.session_state.GOOGLE_API_KEY = None
|
||||||
|
|
@ -45,7 +45,7 @@ medical_agent = Agent(
|
||||||
api_key=st.session_state.GOOGLE_API_KEY,
|
api_key=st.session_state.GOOGLE_API_KEY,
|
||||||
id="gemini-2.0-flash-exp"
|
id="gemini-2.0-flash-exp"
|
||||||
),
|
),
|
||||||
tools=[DuckDuckGo()],
|
tools=[DuckDuckGoTools()],
|
||||||
markdown=True
|
markdown=True
|
||||||
) if st.session_state.GOOGLE_API_KEY else None
|
) if st.session_state.GOOGLE_API_KEY else None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
streamlit==1.40.2
|
streamlit==1.40.2
|
||||||
phidata==2.7.3
|
agno
|
||||||
Pillow==10.0.0
|
Pillow==10.0.0
|
||||||
duckduckgo-search==6.4.1
|
duckduckgo-search==6.4.1
|
||||||
google-generativeai==0.8.3
|
google-generativeai==0.8.3
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.serpapi_tools import SerpApiTools
|
from agno.tools.serpapi import SerpApiTools
|
||||||
from phi.llm.anthropic import Claude
|
from agno.models.anthropic import Claude
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
|
|
@ -15,9 +15,9 @@ anthropic_api_key = st.text_input("Enter Anthropic API Key to access Claude Sonn
|
||||||
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
||||||
|
|
||||||
if anthropic_api_key and serp_api_key:
|
if anthropic_api_key and serp_api_key:
|
||||||
script_writer = Assistant(
|
script_writer = Agent(
|
||||||
name="ScriptWriter",
|
name="ScriptWriter",
|
||||||
llm=Claude(model="claude-3-5-sonnet-20240620", api_key=anthropic_api_key),
|
model=Claude(id="claude-3-5-sonnet-20240620", api_key=anthropic_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are an expert screenplay writer. Given a movie idea and genre,
|
You are an expert screenplay writer. Given a movie idea and genre,
|
||||||
|
|
@ -31,9 +31,9 @@ if anthropic_api_key and serp_api_key:
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
casting_director = Assistant(
|
casting_director = Agent(
|
||||||
name="CastingDirector",
|
name="CastingDirector",
|
||||||
llm=Claude(model="claude-3-5-sonnet-20240620", api_key=anthropic_api_key),
|
model=Claude(id="claude-3-5-sonnet-20240620", api_key=anthropic_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a talented casting director. Given a script outline and character descriptions,
|
You are a talented casting director. Given a script outline and character descriptions,
|
||||||
|
|
@ -49,9 +49,9 @@ if anthropic_api_key and serp_api_key:
|
||||||
tools=[SerpApiTools(api_key=serp_api_key)],
|
tools=[SerpApiTools(api_key=serp_api_key)],
|
||||||
)
|
)
|
||||||
|
|
||||||
movie_producer = Assistant(
|
movie_producer = Agent(
|
||||||
name="MovieProducer",
|
name="MovieProducer",
|
||||||
llm=Claude(model="claude-3-5-sonnet-20240620", api_key=anthropic_api_key),
|
model=Claude(id="claude-3-5-sonnet-20240620", api_key=anthropic_api_key),
|
||||||
team=[script_writer, casting_director],
|
team=[script_writer, casting_director],
|
||||||
description="Experienced movie producer overseeing script and casting.",
|
description="Experienced movie producer overseeing script and casting.",
|
||||||
instructions=[
|
instructions=[
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
anthropic
|
anthropic
|
||||||
google-search-results
|
google-search-results
|
||||||
lxml_html_clean
|
lxml_html_clean
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.serpapi_tools import SerpApiTools
|
from agno.tools.serpapi import SerpApiTools
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("AI Personal Finance Planner 💰")
|
st.title("AI Personal Finance Planner 💰")
|
||||||
|
|
@ -15,10 +15,10 @@ openai_api_key = st.text_input("Enter OpenAI API Key to access GPT-4o", type="pa
|
||||||
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
||||||
|
|
||||||
if openai_api_key and serp_api_key:
|
if openai_api_key and serp_api_key:
|
||||||
researcher = Assistant(
|
researcher = Agent(
|
||||||
name="Researcher",
|
name="Researcher",
|
||||||
role="Searches for financial advice, investment opportunities, and savings strategies based on user preferences",
|
role="Searches for financial advice, investment opportunities, and savings strategies based on user preferences",
|
||||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a world-class financial researcher. Given a user's financial goals and current financial situation,
|
You are a world-class financial researcher. Given a user's financial goals and current financial situation,
|
||||||
|
|
@ -35,10 +35,10 @@ if openai_api_key and serp_api_key:
|
||||||
tools=[SerpApiTools(api_key=serp_api_key)],
|
tools=[SerpApiTools(api_key=serp_api_key)],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
)
|
)
|
||||||
planner = Assistant(
|
planner = Agent(
|
||||||
name="Planner",
|
name="Planner",
|
||||||
role="Generates a personalized financial plan based on user preferences and research results",
|
role="Generates a personalized financial plan based on user preferences and research results",
|
||||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a senior financial planner. Given a user's financial goals, current financial situation, and a list of research results,
|
You are a senior financial planner. Given a user's financial goals, current financial situation, and a list of research results,
|
||||||
|
|
@ -54,8 +54,6 @@ if openai_api_key and serp_api_key:
|
||||||
"Never make up facts or plagiarize. Always provide proper attribution.",
|
"Never make up facts or plagiarize. Always provide proper attribution.",
|
||||||
],
|
],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
add_chat_history_to_prompt=True,
|
|
||||||
num_history_messages=3,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Input fields for the user's financial goals and current financial situation
|
# Input fields for the user's financial goals and current financial situation
|
||||||
|
|
@ -66,4 +64,4 @@ if openai_api_key and serp_api_key:
|
||||||
with st.spinner("Processing..."):
|
with st.spinner("Processing..."):
|
||||||
# Get the response from the assistant
|
# Get the response from the assistant
|
||||||
response = planner.run(f"Financial goals: {financial_goals}, Current situation: {current_situation}", stream=False)
|
response = planner.run(f"Financial goals: {financial_goals}, Current situation: {current_situation}", stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
openai
|
openai
|
||||||
google-search-results
|
google-search-results
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
from phi.playground import Playground, serve_playground_app
|
from agno.playground import Playground, serve_playground_app
|
||||||
|
|
||||||
reasoning_agent = Agent(name="Reasoning Agent", model=Ollama(id="qwq:32b"), markdown=True)
|
reasoning_agent = Agent(name="Reasoning Agent", model=Ollama(id="qwq:32b"), markdown=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.cli.console import console
|
from rich.console import Console
|
||||||
|
|
||||||
regular_agent = Agent(model=OpenAIChat(id="gpt-4o-mini"), markdown=True)
|
regular_agent = Agent(model=OpenAIChat(id="gpt-4o-mini"), markdown=True)
|
||||||
|
console = Console()
|
||||||
reasoning_agent = Agent(
|
reasoning_agent = Agent(
|
||||||
model=OpenAIChat(id="gpt-4o"),
|
model=OpenAIChat(id="gpt-4o"),
|
||||||
reasoning=True,
|
reasoning=True,
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ from datetime import datetime, timedelta
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.tools.email import EmailTools
|
from agno.tools.email import EmailTools
|
||||||
from phi.tools.zoom import ZoomTool
|
from phi.tools.zoom import ZoomTool
|
||||||
from phi.utils.log import logger
|
from phi.utils.log import logger
|
||||||
from streamlit_pdf_viewer import pdf_viewer
|
from streamlit_pdf_viewer import pdf_viewer
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# Core dependencies
|
# Core dependencies
|
||||||
phidata==2.7.3
|
phidata
|
||||||
|
agno
|
||||||
streamlit==1.40.2
|
streamlit==1.40.2
|
||||||
PyPDF2==3.0.1
|
PyPDF2==3.0.1
|
||||||
streamlit-pdf-viewer==0.0.19
|
streamlit-pdf-viewer==0.0.19
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
phidata==2.5.33
|
agno
|
||||||
streamlit==1.40.2
|
streamlit==1.40.2
|
||||||
duckduckgo_search==6.3.7
|
duckduckgo_search==6.3.7
|
||||||
newspaper4k==0.9.3.1
|
newspaper4k==0.9.3.1
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from phi.model.anthropic import Claude
|
from agno.models.anthropic import Claude
|
||||||
from phi.tools.newspaper4k import Newspaper4k
|
from agno.tools.newspaper4k import Newspaper4kTools
|
||||||
from phi.tools import Tool
|
from agno.tools import Tool
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
@ -25,7 +25,7 @@ if st.button("Generate Analysis"):
|
||||||
anthropic_model = Claude(id ="claude-3-5-sonnet-20240620",api_key=anthropic_api_key)
|
anthropic_model = Claude(id ="claude-3-5-sonnet-20240620",api_key=anthropic_api_key)
|
||||||
|
|
||||||
# Define News Collector Agent - Duckduckgo_search tool enables an Agent to search the web for information.
|
# Define News Collector Agent - Duckduckgo_search tool enables an Agent to search the web for information.
|
||||||
search_tool = DuckDuckGo(search=True, news=True, fixed_max_results=5)
|
search_tool = DuckDuckGoTools(search=True, news=True, fixed_max_results=5)
|
||||||
news_collector = Agent(
|
news_collector = Agent(
|
||||||
name="News Collector",
|
name="News Collector",
|
||||||
role="Collects recent news articles on the given topic",
|
role="Collects recent news articles on the given topic",
|
||||||
|
|
@ -37,7 +37,7 @@ if st.button("Generate Analysis"):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define Summary Writer Agent
|
# Define Summary Writer Agent
|
||||||
news_tool = Newspaper4k(read_article=True, include_summary=True)
|
news_tool = Newspaper4kTools(read_article=True, include_summary=True)
|
||||||
summary_writer = Agent(
|
summary_writer = Agent(
|
||||||
name="Summary Writer",
|
name="Summary Writer",
|
||||||
role="Summarizes collected news articles",
|
role="Summarizes collected news articles",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ streamlit==1.41.1
|
||||||
openai==1.58.1
|
openai==1.58.1
|
||||||
duckduckgo-search==6.4.1
|
duckduckgo-search==6.4.1
|
||||||
typing-extensions>=4.5.0
|
typing-extensions>=4.5.0
|
||||||
phidata==2.7.3
|
agno
|
||||||
composio-phidata==0.6.9
|
composio-phidata==0.6.9
|
||||||
composio_core
|
composio_core
|
||||||
composio==0.1.1
|
composio==0.1.1
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent, RunResponse
|
from agno.agent import Agent, RunResponse
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from composio_phidata import Action, ComposioToolSet
|
from composio_phidata import Action, ComposioToolSet
|
||||||
import os
|
import os
|
||||||
from phi.tools.arxiv_toolkit import ArxivToolkit
|
from agno.tools.arxiv import ArxivTools
|
||||||
from phi.utils.pprint import pprint_run_response
|
from agno.utils.pprint import pprint_run_response
|
||||||
from phi.tools.serpapi_tools import SerpApiTools
|
from agno.tools.serpapi import SerpApiTools
|
||||||
|
|
||||||
# Set page configuration
|
# Set page configuration
|
||||||
st.set_page_config(page_title="👨🏫 AI Teaching Agent Team", layout="centered")
|
st.set_page_config(page_title="👨🏫 AI Teaching Agent Team", layout="centered")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# 🎮 Agent X vs Agent O: Tic-Tac-Toe Game
|
# 🎮 Agent X vs Agent O: Tic-Tac-Toe Game
|
||||||
|
|
||||||
An interactive Tic-Tac-Toe game where two AI agents powered by different language models compete against each other built on phidata Agent Framework and Streamlit as UI. Watch as GPT-4O battles against either DeepSeek V3 or Google's Gemini 1.5 Flash in this classic game.
|
An interactive Tic-Tac-Toe game where two AI agents powered by different language models compete against each other built on Agno Agent Framework and Streamlit as UI. Watch as GPT-4O battles against either DeepSeek V3 or Google's Gemini 1.5 Flash in this classic game.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import re
|
import re
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.model.deepseek import DeepSeekChat
|
from agno.models.deepseek import DeepSeek
|
||||||
from phi.model.google import Gemini
|
from agno.models.google import Gemini
|
||||||
|
|
||||||
# Streamlit App Title
|
# Streamlit App Title
|
||||||
st.title("🎮 Agent X vs Agent O: Tic-Tac-Toe Game")
|
st.title("🎮 Agent X vs Agent O: Tic-Tac-Toe Game")
|
||||||
|
|
@ -122,7 +122,7 @@ if 'openai_api_key' in st.session_state:
|
||||||
if 'deepseek_api_key' in st.session_state:
|
if 'deepseek_api_key' in st.session_state:
|
||||||
player_o = Agent(
|
player_o = Agent(
|
||||||
name="Player O",
|
name="Player O",
|
||||||
model=DeepSeekChat(api_key=st.session_state.deepseek_api_key),
|
model=DeepSeek(id="deepseek-chat", api_key=st.session_state.deepseek_api_key),
|
||||||
instructions=[
|
instructions=[
|
||||||
"You are a Tic-Tac-Toe player using the symbol 'O'.",
|
"You are a Tic-Tac-Toe player using the symbol 'O'.",
|
||||||
"Your opponent is using the symbol 'X'. Block their potential winning moves.",
|
"Your opponent is using the symbol 'X'. Block their potential winning moves.",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
streamlit==1.41.1
|
streamlit==1.41.1
|
||||||
phidata==2.7.3
|
agno
|
||||||
openai==1.58.1
|
openai==1.58.1
|
||||||
google-generativeai==0.8.3
|
google-generativeai==0.8.3
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.serpapi_tools import SerpApiTools
|
from agno.tools.serpapi import SerpApiTools
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.llm.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("AI Travel Planner using Llama-3 ✈️")
|
st.title("AI Travel Planner using Llama-3.2 ✈️")
|
||||||
st.caption("Plan your next adventure with AI Travel Planner by researching and planning a personalized itinerary on autopilot using local Llama-3")
|
st.caption("Plan your next adventure with AI Travel Planner by researching and planning a personalized itinerary on autopilot using local Llama-3")
|
||||||
|
|
||||||
# Get SerpAPI key from the user
|
# Get SerpAPI key from the user
|
||||||
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
||||||
|
|
||||||
if serp_api_key:
|
if serp_api_key:
|
||||||
researcher = Assistant(
|
researcher = Agent(
|
||||||
name="Researcher",
|
name="Researcher",
|
||||||
role="Searches for travel destinations, activities, and accommodations based on user preferences",
|
role="Searches for travel destinations, activities, and accommodations based on user preferences",
|
||||||
llm=Ollama(model="llama3:instruct", max_tokens=1024),
|
model=Ollama(id="llama3.2", max_tokens=1024),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a world-class travel researcher. Given a travel destination and the number of days the user wants to travel for,
|
You are a world-class travel researcher. Given a travel destination and the number of days the user wants to travel for,
|
||||||
|
|
@ -32,10 +32,10 @@ if serp_api_key:
|
||||||
tools=[SerpApiTools(api_key=serp_api_key)],
|
tools=[SerpApiTools(api_key=serp_api_key)],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
)
|
)
|
||||||
planner = Assistant(
|
planner = Agent(
|
||||||
name="Planner",
|
name="Planner",
|
||||||
role="Generates a draft itinerary based on user preferences and research results",
|
role="Generates a draft itinerary based on user preferences and research results",
|
||||||
llm=Ollama(model="llama3:instruct", max_tokens=1024),
|
model=Ollama(id="llama3.2", max_tokens=1024),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a senior travel planner. Given a travel destination, the number of days the user wants to travel for, and a list of research results,
|
You are a senior travel planner. Given a travel destination, the number of days the user wants to travel for, and a list of research results,
|
||||||
|
|
@ -51,8 +51,6 @@ if serp_api_key:
|
||||||
"Never make up facts or plagiarize. Always provide proper attribution.",
|
"Never make up facts or plagiarize. Always provide proper attribution.",
|
||||||
],
|
],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
add_chat_history_to_prompt=True,
|
|
||||||
num_history_messages=3,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Input fields for the user's destination and the number of days they want to travel for
|
# Input fields for the user's destination and the number of days they want to travel for
|
||||||
|
|
@ -63,4 +61,4 @@ if serp_api_key:
|
||||||
with st.spinner("Processing..."):
|
with st.spinner("Processing..."):
|
||||||
# Get the response from the assistant
|
# Get the response from the assistant
|
||||||
response = planner.run(f"{destination} for {num_days} days", stream=False)
|
response = planner.run(f"{destination} for {num_days} days", stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
openai
|
openai
|
||||||
google-search-results
|
google-search-results
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.serpapi_tools import SerpApiTools
|
from agno.tools.serpapi import SerpApiTools
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("AI Travel Planner ✈️")
|
st.title("AI Travel Planner ✈️")
|
||||||
|
|
@ -15,10 +15,10 @@ openai_api_key = st.text_input("Enter OpenAI API Key to access GPT-4o", type="pa
|
||||||
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")
|
||||||
|
|
||||||
if openai_api_key and serp_api_key:
|
if openai_api_key and serp_api_key:
|
||||||
researcher = Assistant(
|
researcher = Agent(
|
||||||
name="Researcher",
|
name="Researcher",
|
||||||
role="Searches for travel destinations, activities, and accommodations based on user preferences",
|
role="Searches for travel destinations, activities, and accommodations based on user preferences",
|
||||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a world-class travel researcher. Given a travel destination and the number of days the user wants to travel for,
|
You are a world-class travel researcher. Given a travel destination and the number of days the user wants to travel for,
|
||||||
|
|
@ -35,10 +35,10 @@ if openai_api_key and serp_api_key:
|
||||||
tools=[SerpApiTools(api_key=serp_api_key)],
|
tools=[SerpApiTools(api_key=serp_api_key)],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
)
|
)
|
||||||
planner = Assistant(
|
planner = Agent(
|
||||||
name="Planner",
|
name="Planner",
|
||||||
role="Generates a draft itinerary based on user preferences and research results",
|
role="Generates a draft itinerary based on user preferences and research results",
|
||||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||||
description=dedent(
|
description=dedent(
|
||||||
"""\
|
"""\
|
||||||
You are a senior travel planner. Given a travel destination, the number of days the user wants to travel for, and a list of research results,
|
You are a senior travel planner. Given a travel destination, the number of days the user wants to travel for, and a list of research results,
|
||||||
|
|
@ -54,8 +54,6 @@ if openai_api_key and serp_api_key:
|
||||||
"Never make up facts or plagiarize. Always provide proper attribution.",
|
"Never make up facts or plagiarize. Always provide proper attribution.",
|
||||||
],
|
],
|
||||||
add_datetime_to_instructions=True,
|
add_datetime_to_instructions=True,
|
||||||
add_chat_history_to_prompt=True,
|
|
||||||
num_history_messages=3,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Input fields for the user's destination and the number of days they want to travel for
|
# Input fields for the user's destination and the number of days they want to travel for
|
||||||
|
|
@ -66,4 +64,4 @@ if openai_api_key and serp_api_key:
|
||||||
with st.spinner("Processing..."):
|
with st.spinner("Processing..."):
|
||||||
# Get the response from the assistant
|
# Get the response from the assistant
|
||||||
response = planner.run(f"{destination} for {num_days} days", stream=False)
|
response = planner.run(f"{destination} for {num_days} days", stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.google import Gemini
|
from agno.models.google import Gemini
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from google.generativeai import upload_file, get_file
|
from google.generativeai import upload_file, get_file
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# 1. Initialize the Multimodal Agent
|
# 1. Initialize the Multimodal Agent
|
||||||
agent = Agent(model=Gemini(id="gemini-2.0-flash-exp"), tools=[DuckDuckGo()], markdown=True)
|
agent = Agent(model=Gemini(id="gemini-2.0-flash-exp"), tools=[DuckDuckGoTools()], markdown=True)
|
||||||
|
|
||||||
# 2. Image Input
|
# 2. Image Input
|
||||||
image_url = "https://example.com/sample_image.jpg"
|
image_url = "https://example.com/sample_image.jpg"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
openai
|
openai
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.hackernews import HackerNews
|
from agno.tools.hackernews import HackerNewsTools
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("Multi-Agent AI Researcher 🔍🤖")
|
st.title("Multi-Agent AI Researcher 🔍🤖")
|
||||||
|
|
@ -13,23 +13,23 @@ openai_api_key = st.text_input("OpenAI API Key", type="password")
|
||||||
|
|
||||||
if openai_api_key:
|
if openai_api_key:
|
||||||
# Create instances of the Assistant
|
# Create instances of the Assistant
|
||||||
story_researcher = Assistant(
|
story_researcher = Agent(
|
||||||
name="HackerNews Story Researcher",
|
name="HackerNews Story Researcher",
|
||||||
role="Researches hackernews stories and users.",
|
role="Researches hackernews stories and users.",
|
||||||
tools=[HackerNews()],
|
tools=[HackerNewsTools()],
|
||||||
)
|
)
|
||||||
|
|
||||||
user_researcher = Assistant(
|
user_researcher = Agent(
|
||||||
name="HackerNews User Researcher",
|
name="HackerNews User Researcher",
|
||||||
role="Reads articles from URLs.",
|
role="Reads articles from URLs.",
|
||||||
tools=[HackerNews()],
|
tools=[HackerNewsTools()],
|
||||||
)
|
)
|
||||||
|
|
||||||
hn_assistant = Assistant(
|
hn_assistant = Agent(
|
||||||
name="Hackernews Team",
|
name="Hackernews Team",
|
||||||
team=[story_researcher, user_researcher],
|
team=[story_researcher, user_researcher],
|
||||||
llm=OpenAIChat(
|
model=OpenAIChat(
|
||||||
model="gpt-4o",
|
id="gpt-4o",
|
||||||
max_tokens=1024,
|
max_tokens=1024,
|
||||||
temperature=0.5,
|
temperature=0.5,
|
||||||
api_key=openai_api_key
|
api_key=openai_api_key
|
||||||
|
|
@ -42,4 +42,4 @@ if openai_api_key:
|
||||||
if query:
|
if query:
|
||||||
# Get the response from the assistant
|
# Get the response from the assistant
|
||||||
response = hn_assistant.run(query, stream=False)
|
response = hn_assistant.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,32 +1,32 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.tools.hackernews import HackerNews
|
from agno.tools.hackernews import HackerNews
|
||||||
from phi.llm.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("Multi-Agent AI Researcher using Llama-3 🔍🤖")
|
st.title("Multi-Agent AI Researcher using Llama-3 🔍🤖")
|
||||||
st.caption("This app allows you to research top stories and users on HackerNews and write blogs, reports and social posts.")
|
st.caption("This app allows you to research top stories and users on HackerNews and write blogs, reports and social posts.")
|
||||||
|
|
||||||
# Create instances of the Assistant
|
# Create instances of the Assistant
|
||||||
story_researcher = Assistant(
|
story_researcher = Agent(
|
||||||
name="HackerNews Story Researcher",
|
name="HackerNews Story Researcher",
|
||||||
role="Researches hackernews stories and users.",
|
role="Researches hackernews stories and users.",
|
||||||
tools=[HackerNews()],
|
tools=[HackerNews()],
|
||||||
llm=Ollama(model="llama3:instruct", max_tokens=1024)
|
model=Ollama(id="llama3.2", max_tokens=1024)
|
||||||
)
|
)
|
||||||
|
|
||||||
user_researcher = Assistant(
|
user_researcher = Agent(
|
||||||
name="HackerNews User Researcher",
|
name="HackerNews User Researcher",
|
||||||
role="Reads articles from URLs.",
|
role="Reads articles from URLs.",
|
||||||
tools=[HackerNews()],
|
tools=[HackerNews()],
|
||||||
llm=Ollama(model="llama3:instruct", max_tokens=1024)
|
model=Ollama(id="llama3.2", max_tokens=1024)
|
||||||
)
|
)
|
||||||
|
|
||||||
hn_assistant = Assistant(
|
hn_assistant = Agent(
|
||||||
name="Hackernews Team",
|
name="Hackernews Team",
|
||||||
team=[story_researcher, user_researcher],
|
team=[story_researcher, user_researcher],
|
||||||
llm=Ollama(model="llama3:instruct", max_tokens=1024)
|
model=Ollama(id="llama3.2", max_tokens=1024)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Input field for the report query
|
# Input field for the report query
|
||||||
|
|
@ -35,4 +35,4 @@ query = st.text_input("Enter your report query")
|
||||||
if query:
|
if query:
|
||||||
# Get the response from the assistant
|
# Get the response from the assistant
|
||||||
response = hn_assistant.run(query, stream=False)
|
response = hn_assistant.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.google import Gemini
|
from agno.models.google import Gemini
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.google import Gemini
|
from agno.models.google import Gemini
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from google.generativeai import upload_file, get_file
|
from google.generativeai import upload_file, get_file
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
@ -21,7 +21,7 @@ def initialize_agent():
|
||||||
return Agent(
|
return Agent(
|
||||||
name="Multimodal Analyst",
|
name="Multimodal Analyst",
|
||||||
model=Gemini(id="gemini-2.0-flash-exp"),
|
model=Gemini(id="gemini-2.0-flash-exp"),
|
||||||
tools=[DuckDuckGo()],
|
tools=[DuckDuckGoTools()],
|
||||||
markdown=True,
|
markdown=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
phidata==2.7.2
|
agno
|
||||||
google-generativeai==0.8.3
|
google-generativeai==0.8.3
|
||||||
streamlit==1.40.2
|
streamlit==1.40.2
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.google import Gemini
|
from agno.models.google import Gemini
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
@ -37,7 +37,7 @@ def initialize_agents(api_key: str) -> tuple[Agent, Agent, Agent]:
|
||||||
|
|
||||||
market_agent = Agent(
|
market_agent = Agent(
|
||||||
model=model,
|
model=model,
|
||||||
tools=[DuckDuckGo(search=True)],
|
tools=[DuckDuckGoTools()],
|
||||||
instructions=[
|
instructions=[
|
||||||
"You are a market research expert that:",
|
"You are a market research expert that:",
|
||||||
"1. Identifies market trends and competitor patterns",
|
"1. Identifies market trends and competitor patterns",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
google-generativeai==0.8.3
|
google-generativeai==0.8.3
|
||||||
streamlit==1.41.1
|
streamlit==1.41.1
|
||||||
phidata==2.7.2
|
agno
|
||||||
Pillow==11.0.0
|
Pillow==11.0.0
|
||||||
duckduckgo-search==6.3.7
|
duckduckgo-search==6.3.7
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
phidata
|
agno
|
||||||
duckduckgo-search
|
duckduckgo-search
|
||||||
yfinance
|
yfinance
|
||||||
fastapi[standard]
|
fastapi[standard]
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
# import necessary python libraries
|
# import necessary python libraries
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.xai import xAI
|
from agno.models.xai import xAI
|
||||||
from phi.tools.yfinance import YFinanceTools
|
from agno.tools.yfinance import YFinanceTools
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from phi.playground import Playground, serve_playground_app
|
from agno.playground import Playground, serve_playground_app
|
||||||
|
|
||||||
# create the AI finance agent
|
# create the AI finance agent
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
name="xAI Finance Agent",
|
name="xAI Finance Agent",
|
||||||
model = xAI(id="grok-beta"),
|
model = xAI(id="grok-beta"),
|
||||||
tools=[DuckDuckGo(), YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True)],
|
tools=[DuckDuckGoTools(), YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True)],
|
||||||
instructions = ["Always use tables to display financial/numerical data. For text data use bullet points and small paragrpahs."],
|
instructions = ["Always use tables to display financial/numerical data. For text data use bullet points and small paragrpahs."],
|
||||||
show_tool_calls = True,
|
show_tool_calls = True,
|
||||||
markdown = True,
|
markdown = True,
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
streamlit
|
streamlit
|
||||||
embedchain
|
embedchain
|
||||||
|
streamlit-chat
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.tools.arxiv_toolkit import ArxivToolkit
|
from agno.tools.arxiv import ArxivTools
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("Chat with Research Papers 🔎🤖")
|
st.title("Chat with Research Papers 🔎🤖")
|
||||||
|
|
@ -14,12 +14,12 @@ openai_access_token = st.text_input("OpenAI API Key", type="password")
|
||||||
# If OpenAI API key is provided, create an instance of Assistant
|
# If OpenAI API key is provided, create an instance of Assistant
|
||||||
if openai_access_token:
|
if openai_access_token:
|
||||||
# Create an instance of the Assistant
|
# Create an instance of the Assistant
|
||||||
assistant = Assistant(
|
assistant = Agent(
|
||||||
llm=OpenAIChat(
|
model=OpenAIChat(
|
||||||
model="gpt-4o",
|
id="gpt-4o",
|
||||||
max_tokens=1024,
|
max_tokens=1024,
|
||||||
temperature=0.9,
|
temperature=0.9,
|
||||||
api_key=openai_access_token) , tools=[ArxivToolkit()]
|
api_key=openai_access_token) , tools=[ArxivTools()]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get the search query from the user
|
# Get the search query from the user
|
||||||
|
|
@ -28,4 +28,4 @@ if openai_access_token:
|
||||||
if query:
|
if query:
|
||||||
# Search the web using the AI Assistant
|
# Search the web using the AI Assistant
|
||||||
response = assistant.run(query, stream=False)
|
response = assistant.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
# Import the required libraries
|
# Import the required libraries
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.llm.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
from phi.tools.arxiv_toolkit import ArxivToolkit
|
from agno.tools.arxiv import ArxivTools
|
||||||
|
|
||||||
# Set up the Streamlit app
|
# Set up the Streamlit app
|
||||||
st.title("Chat with Research Papers 🔎🤖")
|
st.title("Chat with Research Papers 🔎🤖")
|
||||||
st.caption("This app allows you to chat with arXiv research papers using Llama-3 running locally.")
|
st.caption("This app allows you to chat with arXiv research papers using Llama-3 running locally.")
|
||||||
|
|
||||||
# Create an instance of the Assistant
|
# Create an instance of the Assistant
|
||||||
assistant = Assistant(
|
assistant = Agent(
|
||||||
llm=Ollama(
|
model=Ollama(
|
||||||
model="llama3:instruct") , tools=[ArxivToolkit()], show_tool_calls=True
|
id="llama3.1:8b") , tools=[ArxivTools()], show_tool_calls=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get the search query from the user
|
# Get the search query from the user
|
||||||
|
|
@ -20,4 +20,4 @@ query= st.text_input("Enter the Search Query", type="default")
|
||||||
if query:
|
if query:
|
||||||
# Search the web using the AI Assistant
|
# Search the web using the AI Assistant
|
||||||
response = assistant.run(query, stream=False)
|
response = assistant.run(query, stream=False)
|
||||||
st.write(response)
|
st.write(response.content)
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
arxiv
|
arxiv
|
||||||
openai
|
openai
|
||||||
pypdf
|
pypdf
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.knowledge.pdf import PDFUrlKnowledgeBase
|
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
|
||||||
from phi.vectordb.lancedb import LanceDb, SearchType
|
from agno.vectordb.lancedb import LanceDb, SearchType
|
||||||
from phi.playground import Playground, serve_playground_app
|
from agno.playground import Playground, serve_playground_app
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
|
|
||||||
db_uri = "tmp/lancedb"
|
db_uri = "tmp/lancedb"
|
||||||
# Create a knowledge base from a PDF
|
# Create a knowledge base from a PDF
|
||||||
|
|
@ -19,7 +19,7 @@ rag_agent = Agent(
|
||||||
model=OpenAIChat(id="gpt-4o"),
|
model=OpenAIChat(id="gpt-4o"),
|
||||||
agent_id="rag-agent",
|
agent_id="rag-agent",
|
||||||
knowledge=knowledge_base, # Add the knowledge base to the agent
|
knowledge=knowledge_base, # Add the knowledge base to the agent
|
||||||
tools=[DuckDuckGo()],
|
tools=[DuckDuckGoTools()],
|
||||||
show_tool_calls=True,
|
show_tool_calls=True,
|
||||||
markdown=True,
|
markdown=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
phidata
|
agno
|
||||||
openai
|
openai
|
||||||
lancedb
|
lancedb
|
||||||
tantivy
|
tantivy
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
import nest_asyncio
|
import nest_asyncio
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from phi.assistant import Assistant
|
from agno.agent import Agent
|
||||||
from phi.document.reader.pdf import PDFReader
|
from agno.document.reader.pdf_reader import PDFReader
|
||||||
from phi.llm.openai import OpenAIChat
|
from agno.models.openai import OpenAIChat
|
||||||
from phi.knowledge import AssistantKnowledge
|
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
|
||||||
from phi.tools.duckduckgo import DuckDuckGo
|
from agno.tools.duckduckgo import DuckDuckGoTools
|
||||||
from phi.embedder.openai import OpenAIEmbedder
|
from agno.embedder.openai import OpenAIEmbedder
|
||||||
from phi.vectordb.pgvector import PgVector2
|
from agno.vectordb.pgvector import PgVector, SearchType
|
||||||
from phi.storage.assistant.postgres import PgAssistantStorage
|
from agno.storage.agent.postgres import PostgresAgentStorage
|
||||||
|
|
||||||
# Apply nest_asyncio to allow nested event loops, required for running async functions in Streamlit
|
# Apply nest_asyncio to allow nested event loops, required for running async functions in Streamlit
|
||||||
nest_asyncio.apply()
|
nest_asyncio.apply()
|
||||||
|
|
@ -18,22 +18,22 @@ DB_URL = "postgresql+psycopg://ai:ai@localhost:5532/ai"
|
||||||
|
|
||||||
# Function to set up the Assistant, utilizing caching for resource efficiency
|
# Function to set up the Assistant, utilizing caching for resource efficiency
|
||||||
@st.cache_resource
|
@st.cache_resource
|
||||||
def setup_assistant(api_key: str) -> Assistant:
|
def setup_assistant(api_key: str) -> Agent:
|
||||||
llm = OpenAIChat(model="gpt-4o-mini", api_key=api_key)
|
llm = OpenAIChat(id="gpt-4o-mini", api_key=api_key)
|
||||||
# Set up the Assistant with storage, knowledge base, and tools
|
# Set up the Assistant with storage, knowledge base, and tools
|
||||||
return Assistant(
|
return Agent(
|
||||||
name="auto_rag_assistant", # Name of the Assistant
|
id="auto_rag_agent", # Name of the Assistant
|
||||||
llm=llm, # Language model to be used
|
model=llm, # Language model to be used
|
||||||
storage=PgAssistantStorage(table_name="auto_rag_storage", db_url=DB_URL),
|
storage=PostgresAgentStorage(table_name="auto_rag_storage", db_url=DB_URL),
|
||||||
knowledge_base=AssistantKnowledge(
|
knowledge_base=PDFUrlKnowledgeBase(
|
||||||
vector_db=PgVector2(
|
vector_db=PgVector(
|
||||||
db_url=DB_URL,
|
db_url=DB_URL,
|
||||||
collection="auto_rag_docs",
|
collection="auto_rag_docs",
|
||||||
embedder=OpenAIEmbedder(model="text-embedding-ada-002", dimensions=1536, api_key=api_key),
|
embedder=OpenAIEmbedder(id="text-embedding-ada-002", dimensions=1536, api_key=api_key),
|
||||||
),
|
),
|
||||||
num_documents=3,
|
num_documents=3,
|
||||||
),
|
),
|
||||||
tools=[DuckDuckGo()], # Additional tool for web search via DuckDuckGo
|
tools=[DuckDuckGoTools()], # Additional tool for web search via DuckDuckGo
|
||||||
instructions=[
|
instructions=[
|
||||||
"Search your knowledge base first.",
|
"Search your knowledge base first.",
|
||||||
"If not found, search the internet.",
|
"If not found, search the internet.",
|
||||||
|
|
@ -41,24 +41,23 @@ def setup_assistant(api_key: str) -> Assistant:
|
||||||
],
|
],
|
||||||
show_tool_calls=True,
|
show_tool_calls=True,
|
||||||
search_knowledge=True,
|
search_knowledge=True,
|
||||||
read_chat_history=True,
|
|
||||||
markdown=True,
|
markdown=True,
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Function to add a PDF document to the knowledge base
|
# Function to add a PDF document to the knowledge base
|
||||||
def add_document(assistant: Assistant, file: BytesIO):
|
def add_document(agent: Agent, file: BytesIO):
|
||||||
reader = PDFReader()
|
reader = PDFReader()
|
||||||
docs = reader.read(file)
|
docs = reader.read(file)
|
||||||
if docs:
|
if docs:
|
||||||
assistant.knowledge_base.load_documents(docs, upsert=True)
|
agent.knowledge_base.load_documents(docs, upsert=True)
|
||||||
st.success("Document added to the knowledge base.")
|
st.success("Document added to the knowledge base.")
|
||||||
else:
|
else:
|
||||||
st.error("Failed to read the document.")
|
st.error("Failed to read the document.")
|
||||||
|
|
||||||
# Function to query the Assistant and return a response
|
# Function to query the Assistant and return a response
|
||||||
def query_assistant(assistant: Assistant, question: str) -> str:
|
def query_assistant(agent: Agent, question: str) -> str:
|
||||||
return "".join([delta for delta in assistant.run(question)])
|
return "".join([delta for delta in agent.run(question)])
|
||||||
|
|
||||||
# Main function to handle Streamlit app layout and interactions
|
# Main function to handle Streamlit app layout and interactions
|
||||||
def main():
|
def main():
|
||||||
|
|
@ -87,7 +86,7 @@ def main():
|
||||||
with st.spinner("🤔 Thinking..."):
|
with st.spinner("🤔 Thinking..."):
|
||||||
# Query the assistant and display the response
|
# Query the assistant and display the response
|
||||||
answer = query_assistant(assistant, question)
|
answer = query_assistant(assistant, question)
|
||||||
st.write("📝 **Response:**", answer)
|
st.write("📝 **Response:**", answer.content)
|
||||||
else:
|
else:
|
||||||
# Show an error if the question input is empty
|
# Show an error if the question input is empty
|
||||||
st.error("Please enter a question.")
|
st.error("Please enter a question.")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
streamlit
|
streamlit
|
||||||
phidata
|
agno
|
||||||
openai
|
openai
|
||||||
psycopg-binary
|
psycopg-binary
|
||||||
pgvector
|
pgvector
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
# Import necessary libraries
|
# Import necessary libraries
|
||||||
from phi.agent import Agent
|
from agno.agent import Agent
|
||||||
from phi.model.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
from phi.knowledge.pdf import PDFUrlKnowledgeBase
|
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
|
||||||
from phi.vectordb.qdrant import Qdrant
|
from agno.vectordb.qdrant import Qdrant
|
||||||
from phi.embedder.ollama import OllamaEmbedder
|
from agno.embedder.ollama import OllamaEmbedder
|
||||||
from phi.playground import Playground, serve_playground_app
|
from agno.playground import Playground, serve_playground_app
|
||||||
|
|
||||||
# Define the collection name for the vector database
|
# Define the collection name for the vector database
|
||||||
collection_name = "thai-recipe-index"
|
collection_name = "thai-recipe-index"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
phidata
|
agno
|
||||||
qdrant-client
|
qdrant-client
|
||||||
ollama
|
ollama
|
||||||
pypdf
|
pypdf
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ from langchain_google_genai import ChatGoogleGenerativeAI
|
||||||
from langchain_core.output_parsers import StrOutputParser
|
from langchain_core.output_parsers import StrOutputParser
|
||||||
from langchain_core.runnables import RunnablePassthrough
|
from langchain_core.runnables import RunnablePassthrough
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
# Initialize embedding model
|
# Initialize embedding model
|
||||||
embedding_model = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
embedding_model = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue