• unwind ai
  • Posts
  • Build an AI Startup Trend Analysis Agent using Claude 3.5 Sonnet

Build an AI Startup Trend Analysis Agent using Claude 3.5 Sonnet

Fully-functional AI agent app in just 50 lines of Python Code (step-by-step instructions)

AI tools are transforming how entrepreneurs identify trends and make decisions, but building a scalable solution to analyze startup opportunities often involves integrating multiple data sources and processing them quickly. But with advanced LLMs equipped with the right tools, this processcan be automated to deliver actionable insights.

In this tutorial, we’ll guide you through building an AI Startup Trend Analysis Agent. This AI agent will analyze startup news, identify emerging trends, and validate ideas. It’ll integrate Newspaper4k and DuckDuckGo with Claude 3.5 Sonnet using less than 50 lines of Python code.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

What We’re Building

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. 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 enables 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.

Prerequisites

Before we begin, make sure you have:

  1. Python installed on your machine (version 3.7 or higher is recommended)

  2. Your Anthropic API key

  3. Basic familiarity with Python programming

  4. A code editor of your choice (we recommend VS Code or PyCharm for their excellent Python support)

Step-by-Step Instructions

Setting Up the Environment

First, let's get our development environment ready:

  1. Clone the GitHub repository:

git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
cd ai_agent_tutorials/ai_startup_trend_analysis_agent
pip install -r requirements.txt
  1. Get your API Key: Sign up for Anthropic account and get your API key.

Creating the Streamlit App

Let’s create our app. Create a new file startup_trends_agent.py and add the following code:

  1. Import necessary libraries:

    • Streamlit for building the web app

    • Phidata for building AI agents and tools

    • Claude Sonnet 3.5 as LLM

    • DuckDuckGo for search

    • Newspaper4k for article processing

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
  1. Create the Streamlit App:

    • Clean, simple interface

    • Secure API key input

    • Topic-based analysis

# 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)
  1. Create the News Collector Agent:

    • Uses DuckDuckGo for searches

    • Collects recent articles

    • Limits to 5 results for focus

# 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,
                )
  1. Add the Summary Writer Agent:

    • Processes article content

    • Creates concise summaries

    • Maintains key information

# 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,
                )
  1. Create the Trend Analyzer Agent:

    • Analyzes summarized content

    • Identifies trends

    • Spots opportunities

# 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,
                )
  1. Combine agents into a team:

    • Orchestrates workflow

    • Ensures data flow

    • Maintains context

                # 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,
                )
  1. Execute the analysis workflow:

    • Sequential processing

    • Maintains data flow

    • Displays results

                # 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.")

Running the App

With our code in place, it's time to launch the app.

  • In your terminal, navigate to the project folder, and run the following command

streamlit run startup_trends_agent.py
  • Streamlit will provide a local URL (typically http://localhost:8501). Open this in your web browser, put in your API key, give it an area you’d want to explore, and watch your AI agent doing the research for you.

Working Application Demo

Conclusion

In just under 50 lines of code, your AI agent is ready to give trend analysis actionable insights for entrepreneurs.

For further enhancements, consider:

  • Visualization: Represent trends graphically to make patterns clearer and actionable.

  • Data Filtering: Add advanced filters for users to refine insights based on geography, funding size, or technology type.

  • Collaboration: Enable sharing and team discussions on insights within the app.

Keep experimenting and refining to build even smarter AI solutions!

We share hands-on tutorials like this 2-3 times a week, to help you stay ahead in the world of AI. If you're serious about levelling up your AI skills and staying ahead of the curve, subscribe now and be the first to access our latest tutorials.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

Reply

or to participate.