Merge branch 'Shubhamsaboo:main' into ai-health

This commit is contained in:
Madhu Shantan 2024-11-29 23:02:42 +05:30 committed by GitHub
commit 0d2dc1daae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 165 additions and 12 deletions

View file

@ -1,7 +1,6 @@
import streamlit as st
from crewai import Agent, Task, Crew, Process
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from crewai import Agent, Task, Crew, LLM
from crewai.process import Process
from crewai_tools import SerperDevTool
import os
@ -11,20 +10,16 @@ st.title("AI Meeting Preparation Agent 📝")
# Sidebar for API keys
st.sidebar.header("API Keys")
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
anthropic_api_key = st.sidebar.text_input("Anthropic API Key", type="password")
serper_api_key = st.sidebar.text_input("Serper API Key", type="password")
# Check if all API keys are set
if openai_api_key and anthropic_api_key and serper_api_key:
# Set API keys as environment variables
os.environ["OPENAI_API_KEY"] = openai_api_key
if anthropic_api_key and serper_api_key:
# # Set API keys as environment variables
os.environ["ANTHROPIC_API_KEY"] = anthropic_api_key
os.environ["SERPER_API_KEY"] = serper_api_key
# Initialize the AI models and tools
gpt4 = ChatOpenAI(model_name="gpt-4o-mini")
claude = ChatAnthropic(model_name="claude-3-5-sonnet-20240620")
claude = LLM(model="claude-3-5-sonnet-20240620", temperature= 0.7, api_key=anthropic_api_key)
search_tool = SerperDevTool()
# Input fields
@ -41,7 +36,7 @@ if openai_api_key and anthropic_api_key and serper_api_key:
backstory='You are an expert at quickly understanding complex business contexts and identifying critical information.',
verbose=True,
allow_delegation=False,
llm=gpt4,
llm=claude,
tools=[search_tool]
)
@ -51,7 +46,7 @@ if openai_api_key and anthropic_api_key and serper_api_key:
backstory='You are a seasoned industry analyst with a knack for spotting emerging trends and opportunities.',
verbose=True,
allow_delegation=False,
llm=gpt4,
llm=claude,
tools=[search_tool]
)

View file

@ -0,0 +1,12 @@
from phi.agent import Agent
from phi.model.ollama import Ollama
from phi.playground import Playground, serve_playground_app
reasoning_agent = Agent(name="Reasoning Agent", model=Ollama(id="qwq:32b"), markdown=True)
# UI for Reasoning agent
app = Playground(agents=[reasoning_agent]).get_app()
# Run the Playground app
if __name__ == "__main__":
serve_playground_app("local_ai_reasoning_agent:app", reload=True)

View file

@ -0,0 +1,42 @@
## 📈 AI Startup Trend Analysis Agent
The AI Startup Trend Analysis Agent is tool for budding entrepreneurs that generates actionable insights by identifying nascent trends, potential market gaps, and growth opportunities in specific sectors. Entrepreneurs can use these data-driven insights to validate ideas, spot market opportunities, and make informed decisions about their startup ventures. It combines Newspaper4k and DuckDuckGo to scan and analyze startup-focused articles and market data. Using Claude 3.5 Sonnet, it processes this information to extract emerging patterns and enable entrepreneurs to identify promising startup opportunities.
### Features
- **User Prompt**: Entrepreneurs can input specific startup sectors or technologies of interest for research.
- **News Collection**: This agent gathers recent startup news, funding rounds, and market analyses using DuckDuckGo.
- **Summary Generation**: Concise summaries of verified information are generated using Newspaper4k.
- **Trend Analysis**: The system identifies emerging patterns in startup funding, technology adoption, and market opportunities across analyzed stories.
- **Streamlit UI**: The application features a user-friendly interface built with Streamlit for easy interaction.
### How to Get Started
1. **Clone the repository**:
```bash
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
cd ai_agent_tutorials/ai_business_insider_agent
```
2. **Create and activate a virtual environment**:
```bash
# For macOS/Linux
python -m venv venv
source venv/bin/activate
# For Windows
python -m venv venv
.\venv\Scripts\activate
```
3. **Install the required packages**:
```bash
pip install -r requirements.txt
```
4. **Run the application**:
```bash
streamlit run business_insider_agent.py
```
### Important Note
- The system specifically uses Claude's API for advanced language processing. You can obtain your Anthropic API key from [Anthropic's website](https://www.anthropic.com/api).

View file

@ -0,0 +1,5 @@
phidata==2.5.33
streamlit==1.40.2
duckduckgo_search==6.3.7
newspaper4k==0.9.3.1
lxml_html_clean==0.4.1

View file

@ -0,0 +1,99 @@
import streamlit as st
from phi.agent import Agent
from phi.tools.duckduckgo import DuckDuckGo
from phi.model.anthropic import Claude
from phi.tools.newspaper4k import Newspaper4k
from phi.tools import Tool
import logging
logging.basicConfig(level=logging.DEBUG)
# Setting up Streamlit app
st.title("AI Startup Trend Analysis Agent 📈")
st.caption("Get the latest trend analysis and startup opportunities based on your topic of interest in a click!.")
topic = st.text_input("Enter the area of interest for your Startup:")
anthropic_api_key = st.sidebar.text_input("Enter Anthropic API Key", type="password")
if st.button("Generate Analysis"):
if not anthropic_api_key:
st.warning("Please enter the required API key.")
else:
with st.spinner("Processing your request..."):
try:
# Initialize Anthropic model
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.
search_tool = DuckDuckGo(search=True, news=True, fixed_max_results=5)
news_collector = Agent(
name="News Collector",
role="Collects recent news articles on the given topic",
tools=[search_tool],
model=anthropic_model,
instructions=["Gather latest articles on the topic"],
show_tool_calls=True,
markdown=True,
)
# Define Summary Writer Agent
news_tool = Newspaper4k(read_article=True, include_summary=True)
summary_writer = Agent(
name="Summary Writer",
role="Summarizes collected news articles",
tools=[news_tool],
model=anthropic_model,
instructions=["Provide concise summaries of the articles"],
show_tool_calls=True,
markdown=True,
)
# Define Trend Analyzer Agent
trend_analyzer = Agent(
name="Trend Analyzer",
role="Analyzes trends from summaries",
model=anthropic_model,
instructions=["Identify emerging trends and startup opportunities"],
show_tool_calls=True,
markdown=True,
)
# The multi agent Team setup of phidata:
agent_team = Agent(
agents=[news_collector, summary_writer, trend_analyzer],
instructions=[
"First, search DuckDuckGo for recent news articles related to the user's specified topic.",
"Then, provide the collected article links to the summary writer.",
"Important: you must ensure that the summary writer receives all the article links to read.",
"Next, the summary writer will read the articles and prepare concise summaries of each.",
"After summarizing, the summaries will be passed to the trend analyzer.",
"Finally, the trend analyzer will identify emerging trends and potential startup opportunities based on the summaries provided in a detailed Report form so that any young entreprenur can get insane value reading this easily"
],
show_tool_calls=True,
markdown=True,
)
# Executing the workflow
# Step 1: Collect news
news_response = news_collector.run(f"Collect recent news on {topic}")
articles = news_response.content
# Step 2: Summarize articles
summary_response = summary_writer.run(f"Summarize the following articles:\n{articles}")
summaries = summary_response.content
# Step 3: Analyze trends
trend_response = trend_analyzer.run(f"Analyze trends from the following summaries:\n{summaries}")
analysis = trend_response.content
# Display results - if incase you want to use this furthur, you can uncomment the below 2 lines to get the summaries too!
# st.subheader("News Summaries")
# # st.write(summaries)
st.subheader("Trend Analysis and Potential Startup Opportunities")
st.write(analysis)
except Exception as e:
st.error(f"An error occurred: {e}")
else:
st.info("Enter the topic and API keys, then click 'Generate Analysis' to start.")