Reflex LLM Examples

repository·main·Indexed 21 days ago

https://github.com/reflex-dev/reflex-llm-examples

A collection of advanced AI application examples built with the Reflex framework. It demonstrates LLM integration patterns such as RAG and AI agents using providers like Gemini 2.0 Flash, DeepSeek-r1, and local models via Ollama (Llama 3.2, Qwen 2.5). Featured examples include an Agentic RAG system with PgVector, an AI Stock Analyst Agent, Browser Use task automation, and multimodal video analysis agents.

Tokens
5.2K
Snippets
19
Records
27
Agent score
74%

What's inside reflex-llm-examples

  1. Overview of the AI Medical Agent features

    main

    The AI Medical Agent is a multi-modal application built with Reflex, Agno, and Gemini 2.0 Flash. It provides the following capabilities:

    • Medical Image Analysis: Detects potential medical conditions from uploaded images.
    • Symptom & Condition Insights: Extracts information regarding possible conditions by combining image analysis with web data retrieval.
    • Web Search & Data Aggregation: Cross-checks AI analysis with trusted medical sources for enhanced accuracy.
    • Detailed Medical Reports: Generates in-depth reports including professional insights, condition explanations, and potential next steps.
  2. Overview of the AI Stock Analyst Agent

    main

    The AI Stock Analyst Agent is an application built using Reflex, Agno, and Gemini 2.0 Flash (exp) designed for advanced financial analysis. It provides users with comprehensive insights into stock market performance by querying real-time data from sources like Yahoo Finance.

    Key Features

    • Stock Analysis: Detailed metrics including P/E ratio, market cap, EPS, and 52-week highs/lows.
    • Watchlist Management: Ability to add or remove stocks for personalized monitoring.
    • Real-Time Market Data: Access to live stock data, analyst recommendations, and company news.
    • Custom Financial Reports: Generation of executive summaries, professional insights, and risk disclosures.

    Note: This project is intended for educational purposes only.

  3. Overview of the Advanced LLM Applications Collection

    main

    The reflex-llm-examples repository is a curated collection of AI applications built using the Reflex framework. It demonstrates practical implementations of Large Language Models (LLMs) from various providers, including Google, Anthropic, OpenAI, and self-hosted open-source models.

    Key areas covered in this collection include:

    • AI Agents: Practical use cases for autonomous or semi-autonomous agents.
    • RAG (Retrieval-Augmented Generation): Implementations of RAG patterns to ground LLM responses in specific data.
    • Scalable AI Solutions: Best practices for building and scaling AI-powered applications.
  4. Overview of Chat with Excel using Docling

    main

    Chat with Excel is a Retrieval Augmented Generation (RAG) application designed for interacting with Excel documents.

    Core Workflow:

    1. Upload: Users upload Excel documents.
    2. Processing: The application uses the Docling Library to parse the Excel content.
    3. Querying: Users ask questions about the data.
    4. Generation: The app uses DeepSeek-r1 (running locally via Ollama) to provide accurate, context-aware answers based on the uploaded file.
  5. How OpenDeepResearcher's research loop works

    main

    OpenDeepResearcher follows an iterative, asynchronous research process:

    1. Query Generation: The user provides a topic, and Google Gemini generates up to four distinct search queries.
    2. Concurrent Search & Processing:
      • Search: Queries are sent to SERPAPI concurrently.
      • Deduplication: Links are aggregated and deduplicated to prevent redundant processing.
      • Extraction: Unique links are processed concurrently using Jina to fetch content and Google Gemini to evaluate relevance and extract context.
    3. Iterative Refinement: The system evaluates the gathered context. If Google Gemini determines more information is needed, it generates new queries and repeats the loop. If not, the loop terminates.
    4. Report Generation: A final comprehensive report is compiled from all gathered context using Google Gemini.
  6. How Agentic RAG workflow works

    main

    The Agentic RAG system uses a multi-step retrieval process to ensure comprehensive answers:

    1. Document Processing: When a PDF is uploaded, the app processes it and creates a searchable knowledge base in PgVector.
    2. Document Retrieval: When a question is asked, the agent first searches the uploaded document for relevant information.
    3. Web Search Fallback: If the required information is not found within the document, the agent automatically triggers a web search using DuckDuckGo.
    4. Response Generation: The agent combines information from the document (if found) or the web search results to provide a detailed response using Gemini 2.0 Flash.
  7. Install and run the AI Stock Analyst Agent

    main

    To set up the AI Stock Analyst Agent locally, follow these steps to clone the repository, install dependencies, configure your API key, and launch the Reflex application.

    1. Clone the Repository

    git clone https://github.com/reflex-dev/reflex-llm-examples.git
    cd reflex-llm-examples/ai_stock_analyst_agent

    2. Install Dependencies

    pip install -r requirements.txt

    3. Set Up Gemini API Key

    You must provide a Google API Key to use the Gemini 2.0 Flash model. Obtain a key from Google AI Studio and set it as an environment variable:

    export GOOGLE_API_KEY="your-api-key-here"

    4. Run the Reflex App

    reflex run
    git clone https://github.com/reflex-dev/reflex-llm-examples.git
    cd reflex-llm-examples/ai_stock_analyst_agent
    pip install -r requirements.txt
    export GOOGLE_API_KEY="your-api-key-here"
    reflex run
  8. Use the Multimodal AI Agent

    main

    The agent allows you to perform video analysis combined with web research via DuckDuckGo.

    Workflow

    1. Upload a Video: Use the drag-and-drop interface to upload video files (supports MP4, MOV, and AVI).
    2. Ask a Question: Enter a query about the video content in the text area.
    3. Analyze & Research: Click the "Analyze & Research" button. The agent will use Gemini Flash 2.0 to analyze the video and DuckDuckGo to gather additional web context.
    4. View Results: Review the generated insights that combine video analysis and web research.
  9. Configure API keys for OpenDeepResearcher

    main

    OpenDeepResearcher requires three specific API keys to function. These should be set as environment variables in your terminal session:

    • GOOGLE_API_KEY: For Google Gemini (e.g., Gemini 2.0 Flash).
    • SERPAPI_API_KEY: For performing Google searches.
    • JINA_API_KEY: For fetching and extracting webpage content.

    If you are using a Jupyter Notebook or Google Colab instead of the Reflex app, replace the placeholder values directly in the notebook cells.

    export GOOGLE_API_KEY="your-api-key-here"
    export SERPAPI_API_KEY="your-serpapi-api-key-here"
    export JINA_API_KEY="your-jina-api-key-here"
  10. Setup the DeepSeek-r1 Chat UI

    main

    To run the DeepSeek-r1 ChatGPT-style interface locally, follow these steps to clone the repository, install Python dependencies, set up the model via Ollama, and launch the Reflex application.

    1. Clone the Repository

    git clone https://github.com/reflex-dev/reflex-llm-examples.git
    cd reflex-llm-examples/chat_with_deepseek_r1_locally/deepseek_r1_chatui

    2. Install Dependencies

    pip install -r requirements.txt

    3. Pull and Run DeepSeek-r1 Using Ollama

    Ensure you have Ollama installed, then pull the specific model version:

    ollama pull deepseek-r1:1.5b

    4. Run the Reflex App

    Start the web application:

    reflex run
    git clone https://github.com/reflex-dev/reflex-llm-examples.git
    cd reflex-llm-examples/chat_with_deepseek_r1_locally/deepseek_r1_chatui
    pip install -r requirements.txt
    ollama pull deepseek-r1:1.5b
    reflex run
  11. Install the Multimodal AI Agent

    main

    To set up the Multimodal AI Agent, clone the repository, navigate to the specific project directory, and install the required dependencies using pip. It is recommended to use a virtual environment.

    Prerequisites

    • Python installed on your system.
    • A Google Gemini API Key.

    Steps

    1. Clone the repository and enter the project directory:
      git clone https://github.com/reflex-dev/reflex-llm-examples.git
      cd reflex-llm-examples/multi_modal_ai_agent
    2. Create and activate a virtual environment:
      python -m venv venv
      source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    3. Install dependencies:
      pip install -r requirements.txt
    git clone https://github.com/reflex-dev/reflex-llm-examples.git
    cd reflex-llm-examples/multi_modal_ai_agent
    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
  12. Install Browser Use Task Automation

    main

    To set up the Browser Use Task Automation application locally, follow these steps in order:

    1. Clone the repository and navigate to the specific directory:
      git clone https://github.com/reflex-dev/reflex-llm-examples.git
      cd reflex-llm-examples/browser_use_locally
    2. Install Python dependencies:
      pip install -r requirements.txt
    3. Install Playwright for browser automation:
      python -m playwright install
    4. Set up the local LLM using Ollama (pulling qwen2.5:latest as the model):
      ollama pull qwen2.5:latest
    5. Start the Reflex app:
      reflex run
    git clone https://github.com/reflex-dev/reflex-llm-examples.git
    cd reflex-llm-examples/browser_use_locally
    pip install -r requirements.txt
    python -m playwright install
    ollama pull qwen2.5:latest
    reflex run