Clapp
CLAPP: CLASS LLM Agent for Pair Programming
Install / Use
/learn @santiagocasas/ClappREADME
title: CLAPP emoji: 🚀 colorFrom: red colorTo: red sdk: docker app_port: 8501 tags:
- streamlit pinned: false short_description: 'CLAPP: CLASS LLM Agent for Pair Programming' license: mit
CLAPP - CLASS LLM Agent for Pair Programming
<p align="center"> <img src="images/CLAPP.png" alt="CLAPP Logo" width="400"/> </p>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.
Collaborators
- Santiago Casas
- Christian Fidler
- Julien Lesgourgues
- With contributions from: Boris Bolliet & Francisco Villaescusa-Navarro
- inspired by the CAMELS-Agent-App
Acknowledgements
<p align="center"> <img src="images/blablador-ng.svg" alt="Blablador Logo" width="220"/> </p>CLAPP acknowledges the support of the Blablador API and Helmholtz AI. Especially, the help of Alex Strube with the model support!
Features
- 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).
Setup and Installation
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
Usage
-
Activate the virtual environment:
source .venv/bin/activate -
Run the Streamlit application:
uv run streamlit run clapp/app.py
Lint & Format (Ruff)
Install dev tools:
uv sync --extra dev
Run lint:
uv run ruff check .
Auto-fix what Ruff can:
uv run ruff check . --fix
Format:
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.
Project Structure
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.
Working with CLASS
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.
Related Skills
node-connect
354.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
