Honegumi RAG Assistant: Agentic Code Generation for Bayesian Optimizationο
Figure: Schematic of the Honegumi RAG Assistant agentic pipeline for generating Bayesian optimization code from natural language.
An intelligent AI assistant that converts natural language problem descriptions into ready-to-run Bayesian optimization code using Metaβs Ax Platform
Overviewο
Honegumi RAG Assistant is an advanced agentic AI system that automatically generates high-quality, executable Python code for Bayesian optimization experiments. Built on top of Honegumi, it uses LangGraph and OpenAI GPT models to orchestrate multiple specialized agents that collaborate to understand your optimization problem, retrieve relevant documentation, and generate production-ready code using the Ax Platform.
Honegumi provides deterministic skeleton code generation based on problem parameters, and this RAG Assistant enhances it by retrieving relevant Ax Platform documentation to help the LLM transform the skeleton into complete, domain-specific code tailored to your problem.
Simply describe your optimization problem in plain English, and the assistant produces complete, runnable code tailored to your specific requirements.
Key Capabilitiesο
Natural language to code: Describe optimization problems conversationally
Intelligent RAG: Parallel retrieval of relevant Ax documentation to supplement skeleton code
Built on Honegumi: Leverages Honegumi for deterministic skeleton generation
Multi-agent architecture: Specialized agents for parameter extraction, retrieval planning, and code writing
Flexible model selection: Mix GPT-5 and GPT-4o models for cost-performance optimization
Key Featuresο
Multi-Agent Architectureο
Intelligent Parameter Detection: Two-stage extraction process with chain-of-thought reasoning for accurate grid parameter selection
Skeleton Generator: Uses Honegumi to create deterministic code templates
Retrieval Planner: Intelligently generates retrieval queries based on problem complexity
Parallel Retrievers: For efficient documentation retrieval - multiple queries executed concurrently to minimize latency
Code Writer: GPT-5 powered code generation with streaming output
Reviewer (optional): Quality assessment and revision requests (disabled by default for speed)
Advanced Featuresο
LangSmith Integration: Full tracing support for debugging and monitoring
π οΈ Prerequisitesο
Conda (Miniconda or Anaconda)
Python 3.11+
LangSmith API key (optional)
π Google Colab Tutorialο
To help you get started quickly, weβve prepared an interactive Google Colab tutorial:
Google Colab Tutorial: Getting Started with Honegumi RAG Assistant
In this tutorial, youβll learn how to:
Install Honegumi RAG Assistant and all necessary dependencies on Colab
Set up API keys using Colab Secrets
Build a vector store from Ax Platform documentation
Describe your optimization problem and generate code
View the generated code in your Google Drive
The tutorial runs entirely in Colabβno local setup required. All you need is access to your Google Drive and valid OpenAI/LangSmith API keys.
Installationο
Quick Install via pipο
Create & activate a conda environment
conda create -n honegumi_rag python=3.11 -y conda activate honegumi_rag
Install via pip
pip install honegumi-rag-assistant
Configure your API keys
Honegumi RAG Assistant will automatically look for a file named
.envin your current working directory (or any parent) and load any keys it finds.In the folder where youβll run the CLI (or in any ancestor), create a file called
.envcontaining:OPENAI_API_KEY=sk-... LANGCHAIN_API_KEY=lsv2_...
Build vector store (one-time setup)
For best results with documentation retrieval, build the vector store:
# Run the build script from the package python -m honegumi_rag_assistant.build_vector_store
Note: By default, this uses Ax v0.4.3 (matching honegumi). To use a different version:
python -m honegumi_rag_assistant.build_vector_store --ax-version 0.4.0
Run the assistant
honegumi-rag
From Source: Clone & Runο
Clone the Repository:
git clone https://github.com/hasan-sayeed/honegumi_rag_assistant.git cd honegumi_rag_assistant
Create Conda Environment (recommended):
conda env create -f environment.yml conda activate honegumi_rag_assistant
Install in editable mode:
pip install -e .
Configure API Keys:
In the project root directory, create a file called
.envcontaining:# Required: OpenAI API Key for LLM and embeddings OPENAI_API_KEY=sk-your-actual-openai-api-key-here # Optional: LangChain for tracing (recommended for debugging) LANGCHAIN_API_KEY=your-langchain-api-key-here LANGCHAIN_TRACING_V2=true LANGCHAIN_PROJECT=Honegumi RAG Assistant # Optional: Path to FAISS vector store (if using RAG) AX_DOCS_VECTORSTORE_PATH=data/processed/ax_docs_vectorstore RETRIEVAL_TOP_K=5
Build Vector Store for RAG:
For best results with documentation retrieval, run:
# Build vector store (one-time setup, defaults to Ax v0.4.3) python -m honegumi_rag_assistant.build_vector_store # Or specify a different Ax version python -m honegumi_rag_assistant.build_vector_store --ax-version 0.4.0
The vector store will be saved to
data/processed/ax_docs_vectorstore/and automatically loaded if present.Verify Installation:
honegumi-rag --help # Or: python -m honegumi_rag_assistant --help
Usageο
Run the assistant:
honegumi-rag # if you installed via pip
# Or: python -m honegumi_rag_assistant
The assistant will prompt you to describe your Bayesian optimization problem in natural language:
Your problem:
Optimize temperature (50-200Β°C) and pressure (1-10 bar) for maximum yield in a chemical reaction.
After typing your problem description, press Enter. The assistant will process your problem and generate code in real-time (streaming), displaying it as itβs created.
By default, code is only printed to the console (not saved). To save the generated script to a file, use --output-dir:
honegumi-rag --output-dir ./my_experiments
Optional: Enable debug mode to see detailed agent decisions:
honegumi-rag --debug
Command Line Argumentsο
Argument |
Description |
Default |
|---|---|---|
|
Save generated script to specified directory (if omitted, code is only printed, not saved) |
|
|
Enable debug mode with detailed logging |
|
|
Enable Reviewer agent (slower, more accurate) |
|
|
Model for Parameter Selector |
|
|
Model for Retrieval Planner |
|
|
Model for Code Writer agent |
|
|
Model for Reviewer agent |
|
Model Selection Guideο
Recommended (Best Quality):
--param-selector-model gpt-5 \
--code-writer-model gpt-5 \
--retrieval-planner-model gpt-5
Budget (Faster, Lower Cost, Lower Accuracy):
--param-selector-model gpt-5-mini \
--code-writer-model gpt-4o \
--retrieval-planner-model gpt-5-mini
Project Organizationο
βββ AUTHORS.md <- List of developers and maintainers
βββ CHANGELOG.md <- Changelog to keep track of new features and fixes
βββ CONTRIBUTING.md <- Guidelines for contributing to this project
βββ LICENSE.txt <- MIT License
βββ README.md <- This file
βββ environment.yml <- Conda environment specification
βββ .env.example <- Example environment variables (COPY TO .env)
β
βββ configs/ <- Configuration files
β
βββ data/
β βββ raw/ <- Original, immutable data
β βββ processed/ <- Processed data (vector stores)
β βββ ax_docs_vectorstore/ <- FAISS vector store for Ax docs
β
βββ src/
β βββ honegumi_rag_assistant/
β βββ __init__.py
β βββ __main__.py <- CLI entry point
β βββ orchestrator.py <- LangGraph pipeline orchestration
β βββ app_config.py <- Settings and configuration
β βββ states.py <- State definitions with custom reducers
β βββ extractors.py <- Pydantic schemas for structured extraction
β βββ build_vector_store.py <- Build FAISS vector store
β βββ nodes/ <- Agent implementations
β βββ parameter_selector.py <- Parameter extraction
β βββ skeleton_generator.py <- Honegumi skeleton generation
β βββ retrieval_planner.py <- Retrieval query generation
β βββ retriever.py <- Parallel FAISS retrieval
β βββ code_writer.py <- GPT-5 code generation
β βββ reviewer.py <- Code quality review
β
βββ scripts/
β βββ batch_process.py <- Batch processing utility
β βββ test_vector_store.py <- Vector store testing
β
βββ tests/ <- Unit tests (pytest)
βββ docs/ <- Documentation
Advanced Topicsο
LangSmith Tracingο
Enable comprehensive debugging:
Get API key from https://smith.langchain.com/
Add to
.env:LANGCHAIN_API_KEY=your-key LANGCHAIN_TRACING_V2=true LANGCHAIN_PROJECT=Honegumi RAG Assistant
View all LLM calls, agent decisions, and timing in LangSmith dashboard
Citationο
If you use Honegumi RAG Assistant in your research, please cite:
@software{honegumi_rag_assistant2025,
title = {Honegumi RAG Assistant: Agentic Code Generation for Bayesian Optimization},
author = {Sayeed, Hasan Muhammad},
year = {2025},
url = {https://github.com/hasan-sayeed/honegumi_rag_assistant}
}
Contributingο
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
How to contribute:
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Licenseο
This project is licensed under the MIT License - see LICENSE.txt for details.
Acknowledgmentsο
Built with PyScaffold
Skeleton generation by Honegumi
Uses Metaβs Ax Platform for Bayesian optimization
Feedback & Feature Requestsο
This project demonstrates a proof of concept of whatβs possible with agentic systems for Bayesian optimization code generation. While Honegumi RAG Assistant works out-of-the-box for many scenarios, your use case may involve more complex pipelines, custom constraints, multi-objective optimization, or specific modeling needs.
Have something bigger in mind? Want Honegumi RAG Assistant to handle advanced features, integrate with your workflow, or adapt to your domain?
Weβd love to hear from you!
Open a GitHub issue
Start a GitHub discussion
Or reach out directly at hasan.sayeed@utah.edu
Supportο
For questions, bug reports, or feature requests:
GitHub Issues: https://github.com/hasan-sayeed/honegumi_rag_assistant/issues
Email: hasan.sayeed@utah.edu
Noteο
This project has been set up using PyScaffold 4.6 and the dsproject extension 0.7.2.