Skip to content

jschroeder-mips/CHIP_chatbot

Repository files navigation

Chip Performance Analyzer Chatbot

A specialized AI assistant for chip design and performance analysis, focusing on RISC-V and MIPS architectures.

Features

  • 🤖 Specialized AI Assistant: Expert-level chip design analysis using Google's Gemini AI
  • 📊 File Upload Support: Upload CSV, JSON, and text files for performance data analysis
  • 📝 Text File Analysis: Support for instruction traces, logs, and other text-based data files
  • 🔬 Performance Focus: Optimized for IPC analysis, cache performance, and architectural bottlenecks
  • Modern Setup: Uses uv for fast dependency management with pip fallback
  • 🔧 Environment Management: Uses python-dotenv for secure API key management

Quick Start

Option 1: Using uv (Recommended)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Run the installation script
./install.sh

# Start the chatbot
uv run python app.py

Option 2: Using pip

# Run the installation script (will use pip automatically)
./install.sh

# Activate virtual environment and start
source venv/bin/activate
python app.py

Option 3: Manual setup

# Install dependencies
pip install -r requirements.txt

# Configure environment (copies .env.example to .env)
cp .env.example .env
# Edit .env with your Google API key

# Test the setup
python test_setup.py

# Run the chatbot
python app.py

Testing

Run the test script to verify your setup:

uv run python test_setup.py
# or
python test_setup.py

This will check:

  • Python version compatibility
  • Required dependencies
  • Environment configuration
  • Sample file availability
  • Basic functionality

Configuration

  1. Copy .env.example to .env
  2. Get your Gemini API key from Google AI Studio
  3. Set your API key in the .env file:
    GEMINI_API_KEY=your_actual_api_key_here
    GEMINI_MODEL=gemini-2.5-flash
    

Usage

Interactive Commands

  • /csv <filepath> - Load CSV file for analysis
  • /json <filepath> - Load JSON file for analysis
  • /txt <filepath> - Load text file for analysis (e.g., traces, logs)
  • /files - List uploaded files
  • /clear - Clear all uploaded files
  • /help - Show available commands
  • /quit - Exit the chatbot

Sample Files

The project includes sample files to test the functionality:

  • sample_performance.csv - Processor performance metrics
  • sample_benchmark.json - Detailed benchmark results
  • inst_trace.txt - RISC-V instruction trace example

Example Sessions

CSV Analysis

🔬 You: /csv sample_performance.csv
✅ Successfully loaded CSV: sample_performance.csv (6 rows, 8 columns)

🔬 You: Analyze the IPC performance across different architectures
🤖 Assistant: Based on the uploaded performance data, I can see significant 
variations in IPC across architectures...

Text File Analysis

🔬 You: /txt inst_trace.txt
✅ Successfully loaded text file: inst_trace.txt (149 lines, 892 words)

🔬 You: What RISC-V instructions are most frequent in this trace?
🤖 Assistant: Analyzing the instruction trace, I can see several patterns...
The most frequent instructions are memory operations (sd) and arithmetic...

System Prompt

The chatbot uses a specialized system prompt (system_prompt.md) that configures it as:

  • Senior chip design engineer with 15+ years experience
  • Expert in RISC-V and MIPS architectures
  • Specialist in performance optimization and EDA workflows
  • Focused on quantitative analysis and actionable recommendations

Development

Dependencies

  • Python 3.9+
  • google-genai[aiohttp] - Google Generative AI SDK
  • python-dotenv - Environment variable management
  • Standard library modules (json, csv, asyncio, pathlib)

Project Structure

├── app.py                    # Main chatbot application
├── system_prompt.md          # AI assistant configuration
├── requirements.txt          # pip dependencies
├── pyproject.toml           # Modern Python project config
├── install.sh               # Installation script
├── setup.py                 # Python setup script (legacy)
├── test_setup.py            # Environment test script
├── env-example              # Environment template
├── sample_performance.csv   # Sample CSV data
└── sample_benchmark.json    # Sample JSON data

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published