| title | emoji | colorFrom | colorTo | sdk | app_port | tags | pinned | short_description | license | |
|---|---|---|---|---|---|---|---|---|---|---|
CLAPP |
🚀 |
red |
red |
docker |
8501 |
|
false |
CLAPP: CLASS LLM Agent for Pair Programming |
mit |
CLAPP is a Streamlit application that provides an AI pair programming assistant specialized in the CLASS cosmology code. It uses LangChain and OpenAI models, leveraging Retrieval-Augmented Generation (RAG) with CLASS documentation and code examples to provide informed responses and assist with coding tasks.
- Santiago Casas
- Christian Fidler
- Julien Lesgourgues
- With contributions from: Boris Bolliet & Francisco Villaescusa-Navarro
- inspired by the CAMELS-Agent-App
CLAPP acknowledges the support of the Blablador API and Helmholtz AI. Especially, the help of Alex Strube with the model support!
- Conversational AI: Interact with an AI assistant knowledgeable about CLASS and cosmology.
- CLASS Integration: Built-in tools to test and use the CLASS cosmological code.
- Code Execution: Executes Python code snippets in real-time, with automatic error detection and correction.
- Plotting Support: Generates and displays cosmological plots from CLASS outputs.
- RAG Integration: Retrieves relevant information from CLASS documentation and code (
./class-data/) to answer questions accurately. - Multiple Response Modes:
- Fast Mode: Quick responses with good quality (recommended for most uses)
- Swarm Mode: Multi-agent refined responses for more complex questions (takes longer)
- Real-time Feedback: Streams execution progress in real-time.
- Model Selection: Choose between Blablador, OpenAI, and Gemini models (depending on which keys are available).
This project uses pyproject.toml (PEP 621) with uv. CLASS (classy) does not install reliably with conda.
-
Clone the repository:
git clone https://github.com/santiagocasas/clapp.git cd clapp -
Create a virtual environment and install dependencies:
uv venv .venv --python 3.11 source .venv/bin/activate uv sync -
API Keys:
- The app starts without any keys, but you need at least one provider key to get model responses.
- Streamlit Community Cloud: set secrets in the app settings (no file needed in the repo).
- Local: either create
.streamlit/secrets.tomlor paste keys in the sidebar UI. - Supported entries:
BLABLADOR_API_KEY,BLABLADOR_BASE_URL,OPENAI_API_KEY,GEMINI_API_KEY. - Gemini keys: https://aistudio.google.com/app/apikey
-
CLASS Installation:
- Install CLASS with
pip install classyand verify it using the built-in test tool.
- Install CLASS with
-
CLASS Data:
- Ensure the
class-datadirectory contains the necessary CLASS documentation, code files (.py, .ini, .txt), and potentially PDF documents for the RAG system.
- Ensure the
-
System Prompts:
- Ensure the
prompts/directory contains the necessary instruction files (class_instructions.txt,review_instructions.txt, etc.).
- Ensure the
-
Activate the virtual environment:
source .venv/bin/activate -
Run the Streamlit application:
uv run streamlit run clapp/app.py
Install dev tools:
uv sync --extra devRun lint:
uv run ruff check .Auto-fix what Ruff can:
uv run ruff check . --fixFormat:
uv run ruff format .-
Setup process:
- If needed, provide API keys via Streamlit secrets (Cloud) or
.streamlit/secrets.toml/ sidebar inputs (local). - Initialize the application by clicking "Initialize with Selected Model".
- Check if CLASS is installed using the provided test button.
- Start chatting with the assistant about CLASS-related questions or cosmology code.
- If needed, provide API keys via Streamlit secrets (Cloud) or
-
Code execution:
- When the assistant provides code, you can execute it by typing "execute!" in the chat.
- The system will run the code, display the output, and show any generated plots.
- If errors occur, the system will automatically attempt to fix them.
clapp/app.py: The main Streamlit application script..streamlit/secrets.toml: Local secrets file for API keys.test_classy.py: Script to test CLASS installation and functionality.pyproject.toml: Project dependencies (used byuv sync).class-data/: Directory containing data for the RAG system (CLASS code, docs, etc.).prompts/: Directory containing system prompts for the AI agents.images/: Contains images used in the app interface, including the CLAPP logo.
CLAPP allows you to:
- Learn about CLASS: Ask questions about CLASS cosmology code features, parameters, and usage.
- Develop cosmology code: Get help writing code that uses CLASS for cosmological calculations.
- Debug and fix errors: Get assistance with error messages and issues in your CLASS code.
- Visualize results: Generate and view plots of cosmological data.
