Skip to content

Maimuzamilhu/TradeBrain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-AI Finance Agent

A sophisticated multi-agent AI system that leverages Groq's LLM models and Tavily search capabilities to provide intelligent financial analysis and responses through a modern web interface.

🚀 Features

  • Multi-Model Support: Choose from different Groq LLM models including Llama3 variants
  • Web Search Integration: Powered by Tavily for real-time information retrieval
  • Customizable AI Agents: Define your own system prompts for specialized financial analysis
  • Modern Web Interface: Built with Streamlit for an intuitive user experience
  • RESTful API: FastAPI backend for seamless integration and scalability
  • Real-time Logging: Comprehensive logging system for monitoring and debugging

️ Architecture

The project follows a modular architecture with clear separation of concerns:

app/
├── backend/          # FastAPI REST API server
├── frontend/         # Streamlit web interface
├── core/            # AI agent logic and LLM integration
├── config/          # Configuration and environment settings
└── common/          # Shared utilities and logging

This comprehensive README.md includes:

  1. Project Overview: Clear description of what the project does
  2. Features: Key capabilities and highlights
  3. Architecture: Project structure and design
  4. Technology Stack: All major dependencies and frameworks
  5. Installation: Step-by-step setup instructions
  6. Usage: How to run and use the application
  7. Configuration: Environment variables and settings
  8. API Documentation: Endpoint details and examples
  9. Development Guide: How to contribute and extend the project
  10. Support: Troubleshooting and help resources

The README is now much more informative and professional, providing users and developers with everything they need to understand, install, and use your Multi-AI Finance Agent project.

🛠️ Technology Stack

  • Backend: FastAPI, Uvicorn
  • Frontend: Streamlit
  • AI/LLM: LangChain, Groq API, LangGraph
  • Search: Tavily Search API
  • Python: 3.8+
  • Package Management: uv

📋 Prerequisites

  • Python 3.8 or higher
  • Groq API key
  • Tavily API key (optional, for web search functionality)

🚀 Installation

  1. Clone the repository

    git clone <repository-url>
    cd Multi-AI-Finance-Agent
  2. Create and activate virtual environment

    python -m venv .venv
    # On Windows
    .venv\Scripts\activate
    # On macOS/Linux
    source .venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables Create a .env file in the project root:

    GROQ_API_KEY=your_groq_api_key_here
    TAVILY_API_KEY=your_tavily_api_key_here

Usage

Running the Application

The simplest way to run the application:

python -m app.main

This command will:

  • Start the FastAPI backend server on http://127.0.0.1:9999
  • Launch the Streamlit frontend interface
  • Automatically open your default web browser

Manual Startup

You can also run the services separately:

Backend (FastAPI)

uvicorn app.backend.api:app --host 127.0.0.1 --port 9999

Frontend (Streamlit)

streamlit run app/frontend/ui.py

Configuration

Supported Models

The system currently supports the following Groq models:

  • llama3-70b-8192
  • llama-3.3-70b-versatile

Environment Variables

Variable Description Required
GROQ_API_KEY Your Groq API key for LLM access Yes
TAVILY_API_KEY Your Tavily API key for web search No (but required for search functionality)

Web Interface

The Streamlit interface provides:

  • System Prompt Configuration: Define custom AI agent behavior
  • Model Selection: Choose from available Groq models
  • Web Search Toggle: Enable/disable real-time information retrieval
  • Query Input: Large text area for detailed financial questions
  • Real-time Responses: Instant AI-generated responses with markdown support

API Endpoints

POST /chat

Send queries to the AI agent:

{
  "model_name": "llama3-70b-8192",
  "system_prompt": "You are a financial analyst expert...",
  "messages": ["What are the current market trends?"],
  "allow_search": true
}

🚀 Development

Project Structure

  • app/main.py: Main entry point and service orchestration
  • app/backend/api.py: FastAPI application and endpoints
  • app/frontend/ui.py: Streamlit user interface
  • app/core/ai_agent.py: AI agent logic and LLM integration
  • app/config/settings.py: Configuration management
  • app/common/: Shared utilities, logging, and exception handling

Adding New Features

  1. New Models: Add to ALLOWED_MODEL_NAMES in settings.py
  2. New Tools: Extend the tools list in ai_agent.py
  3. New Endpoints: Add routes in api.py
  4. UI Components: Extend the Streamlit interface in ui.py

📊 Logging

The application includes comprehensive logging:

  • Log files are stored in the logs/ directory
  • Automatic log rotation with date-based naming
  • Different log levels for development and production

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

For issues and questions:

  • Check the logs in the logs/ directory
  • Verify your API keys are correctly set
  • Ensure all dependencies are installed
  • Check the FastAPI docs at http://127.0.0.1:9999/docs

🔮 Future Enhancements

  • Additional LLM providers (OpenAI, Anthropic, etc.)
  • Advanced financial analysis tools
  • Real-time market data integration
  • Multi-user support and authentication
  • API rate limiting and usage analytics
  • Docker containerization
  • Kubernetes deployment support

Built with ❤️ using FastAPI, Streamlit, and LangChain

About

AI-powered financial analysis platform using FastAPI + Streamlit + LangChain + Groq API. Features multi-LLM support, web search integration, and modern web interface for intelligent financial insights.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages