### Download .env Configuration (Mac/Linux) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Downloads the example .env configuration file from GitHub using curl for BambooAI setup on Mac and Linux. Users should edit this file with their specific settings. ```bash curl -o web_app/.env https://raw.githubusercontent.com/pgalko/BambooAI/main/.env.example ``` -------------------------------- ### Download .env Configuration (Windows PowerShell) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Downloads the example .env configuration file from GitHub using Invoke-WebRequest for BambooAI setup on Windows. Users should edit this file with their specific settings. ```powershell Invoke-WebRequest -Uri https://raw.githubusercontent.com/pgalko/BambooAI/main/.env.example -OutFile web_app\.env ``` -------------------------------- ### Download LLM_CONFIG Configuration (Windows PowerShell) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Downloads the example LLM_CONFIG.json configuration file from GitHub using Invoke-WebRequest for BambooAI setup on Windows. Users should edit this file with their specific settings. ```powershell Invoke-WebRequest -Uri https://raw.githubusercontent.com/pgalko/BambooAI/main/LLM_CONFIG_sample.json -OutFile web_app\LLM_CONFIG.json ``` -------------------------------- ### Configure Environment Variables (Bash/PowerShell) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Copies the example environment file and instructs the user to edit it with their specific settings. Supports both Mac/Linux (bash) and Windows (PowerShell). ```bash cp .env.example web_app/.env # Edit .env with your settings ``` ```powershell Copy-Item -Path .env.example -Destination web_app/.env # Edit .env with your settings ``` -------------------------------- ### Download LLM_CONFIG Configuration (Mac/Linux) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Downloads the example LLM_CONFIG.json configuration file from GitHub using curl for BambooAI setup on Mac and Linux. Users should edit this file with their specific settings. ```bash curl -o web_app/LLM_CONFIG.json https://raw.githubusercontent.com/pgalko/BambooAI/main/LLM_CONFIG_sample.json ``` -------------------------------- ### Install BambooAI using pip or from repository Source: https://github.com/pgalko/bambooai/blob/main/README.md This snippet shows how to install the BambooAI library. You can either install it directly using pip or clone the repository and install the requirements from the provided file. ```bash pip install bambooai ``` ```bash git clone https://github.com/pgalko/BambooAI.git pip install -r requirements.txt ``` -------------------------------- ### Configure LLM Settings (Bash/PowerShell) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Copies the sample LLM configuration file and prompts the user to customize it. Supports both Mac/Linux (bash) and Windows (PowerShell). ```bash cp LLM_CONFIG_sample.json web_app/LLM_CONFIG.json # Edit LLM_CONFIG.json with your settings ``` ```powershell Copy-Item -Path LLM_CONFIG_sample.json -Destination web_app\LLM_CONFIG.json # Edit LLM_CONFIG.json with your settings ``` -------------------------------- ### LLM Configuration Example (JSON) Source: https://github.com/pgalko/bambooai/blob/main/README.md This JSON snippet shows an example of an LLM configuration for the 'Planner' agent using Ollama. It specifies the model, provider, maximum tokens, and temperature settings. ```json { "agent": "Planner", "details": { "model": "llama3:70b", "provider": "ollama", "max_tokens": 2000, "temperature": 0 } } ``` -------------------------------- ### Pinecone Wrapper (Python SDK) Source: https://context7.com/pgalko/bambooai/llms.txt Python code example for initializing and using the Pinecone vector database wrapper. ```APIDOC ## PineconeWrapper Initialization ### Description This section provides a Python code example for initializing the `PineconeWrapper` to interact with the Pinecone vector database. ### Method N/A (Python SDK) ### Endpoint N/A (Python SDK) ### Parameters #### Environment Variables - **PINECONE_API_KEY** (string) - Required - Your Pinecone API key. - **EMBEDDING_PLATFORM** (string) - Required - The embedding platform to use ('openai' or 'hf_sentence_transformers'). ### Request Example ```python from bambooai.qa_retrieval import PineconeWrapper import os # Environment setup os.environ['PINECONE_API_KEY'] = 'your-api-key' os.environ['EMBEDDING_PLATFORM'] = 'openai' # or 'hf_sentence_transformers' # Initialize wrapper pinecone_wrapper = PineconeWrapper() print("PineconeWrapper initialized successfully.") ``` ### Response N/A (This is a client-side SDK example) ### Notes Ensure you have the necessary API keys and environment variables configured before running this code. ``` -------------------------------- ### Create BambooAI Directory (Mac/Linux) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Creates a new directory named 'bambooai' and navigates into it for setting up the BambooAI project on Mac and Linux systems. ```bash mkdir bambooai cd bambooai ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pgalko/bambooai/blob/main/README.md Installs all necessary Python dependencies for the BambooAI project using pip. This command reads the requirements from the 'requirements.txt' file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Configure Application Environment Source: https://github.com/pgalko/bambooai/blob/main/README.md Copies the example environment file and prompts the user to edit it with their specific settings. This file typically contains API keys and other sensitive configuration details. ```bash cp .env.example web_app/.env # Edit .env with your settings ``` -------------------------------- ### Install BambooAI via pip (Bash) Source: https://github.com/pgalko/bambooai/blob/main/README.md Installs the BambooAI package using pip, the standard Python package installer. This is one of the methods to set up BambooAI for use. ```bash pip install bambooai ``` -------------------------------- ### Docker Compose Configuration for BambooAI Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Defines the Docker Compose setup for BambooAI, specifying the image, container name, volume mounts for configuration and data, port mapping, and restart policy. ```yaml services: bambooai-webapp: image: pgalko/bambooai:latest container_name: bambooai volumes: # Mount configuration files - ./web_app/.env:/app/web_app/.env - ./web_app/LLM_CONFIG.json:/app/web_app/LLM_CONFIG.json # Mount persistent storage directories - ./web_app/storage:/app/web_app/storage - ./web_app/temp:/app/web_app/temp - ./web_app/logs:/app/web_app/logs ports: - "5000:5000" restart: unless-stopped ``` -------------------------------- ### Clone BambooAI Repository (Bash) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Clones the BambooAI repository from GitHub and navigates into the project directory. This is the first step in building a custom Docker image. ```bash git clone https://github.com/pgalko/BambooAI.git cd BambooAI ``` -------------------------------- ### Run BambooAI Application Source: https://github.com/pgalko/bambooai/blob/main/README.md Navigates to the 'web_app' directory and starts the BambooAI application using Python. The web interface will be accessible at http://localhost:5000. ```bash cd web_app python app.py ``` -------------------------------- ### Configure BambooAI Environment (Bash) Source: https://github.com/pgalko/bambooai/blob/main/README.md Copies the example environment file and instructs the user to edit it with their specific settings. This is a crucial step for configuring BambooAI, especially for web application deployment. ```bash cp .env.example /.env # Edit .env with your settings ``` -------------------------------- ### Run Docker Container Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Starts the BambooAI Docker container in detached mode using Docker Compose. This command should be run from the directory containing the docker-compose.yml file. ```bash docker-compose up -d ``` -------------------------------- ### Basic BambooAI Usage Example in Python Source: https://github.com/pgalko/bambooai/blob/main/README.md This Python code demonstrates a basic usage of the BambooAI library. It involves reading a CSV file into a pandas DataFrame, initializing the BambooAI agent with specific configurations (planning, vector_db, search_tool), and then initiating a conversational analysis. ```python import pandas as pd from bambooai import BambooAI import plotly.io as pio pio.renderers.default = 'jupyterlab' df = pd.read_csv('titanic.csv') bamboo = BambooAI(df=df, planning=True, vector_db=False, search_tool=True) bamboo.pd_agent_converse() ``` -------------------------------- ### Create docker-compose.yml file (Mac/Linux) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Creates an empty docker-compose.yml file using the 'touch' command on Mac and Linux systems, which will be populated with the Docker Compose configuration for BambooAI. ```bash touch docker-compose.yml ``` -------------------------------- ### Run BambooAI Web Application (Bash) Source: https://github.com/pgalko/bambooai/blob/main/README.md Command to run the BambooAI web application after setup. It requires navigating to the web_app directory and executing the app.py script. ```bash cd python app.py ``` -------------------------------- ### LLM Configuration Example (VLLM - JSON) Source: https://github.com/pgalko/bambooai/blob/main/README.md This JSON snippet demonstrates an LLM configuration for the 'Code Generator' agent using VLLM. It includes the model path, provider, maximum tokens, and temperature. ```json { "agent": "Code Generator", "details": { "model": "/path/to/model/DeepSeek-R1-Distill-14B", "provider": "vllm", "max_tokens": 2000, "temperature": 0 } } ``` -------------------------------- ### Create docker-compose.yml file (Windows PowerShell) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Creates an empty docker-compose.yml file using 'New-Item' on Windows PowerShell, which will be populated with the Docker Compose configuration for BambooAI. ```powershell New-Item -Path . -Name "docker-compose.yml" -ItemType "file" ``` -------------------------------- ### Create Subdirectories for BambooAI (Mac/Linux) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Creates essential subdirectories within the 'web_app' directory for storing BambooAI data, temporary files, and logs on Mac and Linux systems. ```bash mkdir -p web_app/storage/favourites web_app/storage/threads web_app/temp web_app/logs ``` -------------------------------- ### Get Current Planning State via Curl Source: https://context7.com/pgalko/bambooai/llms.txt Retrieves the current status of the planning agent. Returns a JSON object indicating whether planning is enabled. ```bash curl -X GET http://localhost:5000/get_planning_state ``` -------------------------------- ### Create Subdirectories for BambooAI (Windows PowerShell) Source: https://github.com/pgalko/bambooai/wiki/Docker-Installation-Guide-for-BambooAI Creates essential subdirectories within the 'web_app' directory for storing BambooAI data, temporary files, and logs on Windows using PowerShell. ```powershell mkdir web_app\storage\favourites, web_app\storage\threads, web_app\temp, web_app\logs ``` -------------------------------- ### Get Ontology State via Curl Source: https://context7.com/pgalko/bambooai/llms.txt Retrieves the current status and path of the loaded ontology. Returns a JSON object indicating if the ontology is enabled and its file path. ```bash curl -X GET http://localhost:5000/get_ontology_state ``` -------------------------------- ### Initialize BambooAI Instance Source: https://context7.com/pgalko/bambooai/llms.txt Initializes the BambooAI class, the main entry point for the library. This instance can be configured with various features for data analysis, including auxiliary datasets, conversation context limits, search tools, planning agents, web UI, vector database integration, custom ontologies, and custom prompt files. ```python import pandas as pd from bambooai import BambooAI # Load your dataset df = pd.read_csv('training_data.csv') # Basic initialization with default settings bamboo = BambooAI(df=df) # Full initialization with all features enabled bamboo = BambooAI( df=df, # Primary DataFrame to analyze auxiliary_datasets=[ 'path/to/wellness_data.csv', 'path/to/nutrition_data.parquet' ], max_conversations=4, # Conversation pairs to keep in context search_tool=True, # Enable internet search capability planning=True, # Enable planning agent for complex tasks webui=False, # CLI/Jupyter mode (set True for web app) vector_db=True, # Enable vector DB for knowledge storage df_ontology='path/to/ontology.ttl', # Custom RDF/OWL ontology for domain grounding exploratory=True, # Enable expert routing for queries custom_prompt_file='prompts.yaml' # Custom prompt templates ) ``` -------------------------------- ### Add, Retrieve, and Search Records with Qdrant Wrapper Source: https://context7.com/pgalko/bambooai/llms.txt Illustrates adding records, retrieving matches, and searching for results using the Qdrant vector database wrapper. It requires the qdrant-client and necessary environment variables for connection. ```python from bambooai.qa_retrieval import QdrantWrapper import os os.environ['QDRANT_URL'] = 'http://localhost:6333' # or Qdrant Cloud URL os.environ['QDRANT_API_KEY'] = 'optional-api-key' os.environ['EMBEDDING_PLATFORM'] = 'openai' qdrant_wrapper = QdrantWrapper() qdrant_wrapper.add_record( chain_id="analysis_002", intent_text="Find correlation between variables", plan="1. Select numeric columns 2. Calculate correlation matrix", data_descr="Dataset with multiple numeric features", data_model="features: age, income, score", code="df[['age', 'income', 'score']].corr()", new_rank=9, similarity_threshold_for_semantic_match=0.80 ) match = qdrant_wrapper.retrieve_matching_record( intent_text="correlation analysis", data_descr="numeric data", similarity_threshold=0.80 ) results = qdrant_wrapper.search_for_results("variable correlation", top_k=5) ``` -------------------------------- ### Initialize BambooAI with Default Parameters (Python) Source: https://github.com/pgalko/bambooai/blob/main/README.md Demonstrates how to initialize the BambooAI with its default parameters. This includes setting up dataframes, auxiliary datasets, conversation memory, and enabling/disabling features like search, planning, web UI, and vector database. ```python from bambooai import BambooAI bamboo = BambooAI( df=None, # DataFrame to analyze auxiliary_datasets=None, # List of paths to auxiliary datasets max_conversations=4, # Number of conversation pairs to keep in memory search_tool=False, # Enable internet search capability planning=False, # Enable planning agent for complex tasks webui=False, # Run as web application vector_db=False, # Enable vector database for knowledge storage df_ontology=False, # Use custom dataframe ontology exploratory=True, # Enable expert selection for query handling custom_prompt_file=None # Enable the use of custom/modified prompt templates ) ``` -------------------------------- ### Get All Saved Threads via Curl Source: https://context7.com/pgalko/bambooai/llms.txt Retrieves a list of all saved analysis threads. The response includes thread IDs, newest timestamps, and details about the chains within each thread. ```bash curl -X GET http://localhost:5000/get_threads ``` -------------------------------- ### Initialize BambooAI with Dataframe Ontology (Python) Source: https://github.com/pgalko/bambooai/blob/main/README.md This Python code shows how to initialize BambooAI with a primary dataframe and a custom ontology file. The ontology, typically in TTL format, helps ground the AI agents within a specific domain. ```python from bambooai import BambooAI import pandas as pd # Initialize with ontology file path bamboo = BambooAI( df=your_dataframe, df_ontology="path/to/ontology.ttl" ) ``` -------------------------------- ### Configure Qdrant for BambooAI (Environment Variables) Source: https://github.com/pgalko/bambooai/blob/main/README.md Configures environment variables for Qdrant vector database integration with BambooAI. This allows for either a local Qdrant instance or Qdrant Cloud. The URL and API key (optional for local) need to be specified. ```dotenv VECTOR_DB_TYPE=qdrant QDRANT_URL=http://localhost:6333 # For local Qdrant QDRANT_API_KEY= # Optional for local, required for cloud ``` -------------------------------- ### Deploy BambooAI with Docker Compose Source: https://context7.com/pgalko/bambooai/llms.txt Provides a docker-compose.yaml file and commands to deploy BambooAI as a containerized web application. It configures environment variables for API keys and services. ```yaml version: '3.8' services: bambooai: build: . ports: - "5001:5000" environment: - OPENAI_API_KEY=${OPENAI_API_KEY} - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} - GEMINI_API_KEY=${GEMINI_API_KEY} - FLASK_SECRET=${FLASK_SECRET} - EXECUTION_MODE=local - VECTOR_DB_TYPE=pinecone - PINECONE_API_KEY=${PINECONE_API_KEY} volumes: - ./LLM_CONFIG.json:/app/web_app/LLM_CONFIG.json - ./ontologies:/app/web_app/ontologies - bamboo_data:/app/web_app/storage restart: unless-stopped volumes: bamboo_data: ``` ```bash docker-compose up -d docker-compose logs -f bambooai open http://localhost:5001 ``` -------------------------------- ### Initialize BambooAI with Auxiliary Datasets (Python) Source: https://github.com/pgalko/bambooai/blob/main/README.md This Python code demonstrates how to initialize the BambooAI class with a primary dataset and multiple auxiliary datasets. It uses pandas for data loading and specifies paths for CSV and Parquet files. ```python from bambooai import BambooAI import pandas as pd # Load primary dataset main_df = pd.read_csv('main_data.csv') # Specify paths to auxiliary datasets auxiliary_paths = [ 'path/to/supporting_data1.csv', 'path/to/supporting_data2.parquet', 'path/to/reference_data.csv' ] # Initialize BambooAI with auxiliary datasets bamboo = BambooAI( df=main_df, auxiliary_datasets=auxiliary_paths, ) ``` -------------------------------- ### Interactive BambooAI Usage (Python) Source: https://github.com/pgalko/bambooai/blob/main/README.md Demonstrates how to initialize and use BambooAI in an interactive mode, suitable for Jupyter Notebooks or CLI. It loads data from a CSV, sets up search and planning tools, and initiates a conversational agent. ```python import pandas as pd from bambooai import BambooAI import plotly.io as pio pio.renderers.default = 'jupyterlab' df = pd.read_csv('training_activity_data.csv') aux_data = [ 'path/to/wellness_data.csv', 'path/to/nutrition_data.parquet', ] bamboo = BambooAI(df=df, search_tool=True, planning=True) bamboo.pd_agent_converse() ``` -------------------------------- ### Initialize BambooAI with Vector DB Support (Python) Source: https://github.com/pgalko/bambooai/blob/main/README.md Initializes the BambooAI agent, enabling vector database integration for storing and retrieving analysis results. This allows the system to learn and evolve over time. It requires the pandas library for data manipulation. ```python from bambooai import BambooAI import pandas as pd # Initialize with ontology file path bamboo = BambooAI( df=your_dataframe, vector_db=True ) ``` -------------------------------- ### Add, Retrieve, and Delete Records with Pinecone Wrapper Source: https://context7.com/pgalko/bambooai/llms.txt Demonstrates how to add records with a rank threshold, retrieve matching records based on intent, and delete records using the Pinecone wrapper. It requires the pinecone-client library. ```python pinecone_wrapper.add_record( chain_id="analysis_001", intent_text="Calculate monthly revenue trends", plan="1. Parse dates 2. Group by month 3. Sum revenue", data_descr="Sales transaction data with dates and amounts", data_model="transactions: date, amount, product_id", code="df.groupby(df['date'].dt.to_period('M'))['amount'].sum()", new_rank=8, similarity_threshold_for_semantic_match=0.80 ) match = pinecone_wrapper.retrieve_matching_record( intent_text="Show me revenue by month", data_descr="Sales data with transaction dates", similarity_threshold=0.80 ) if match: print(f"Match ID: {match['id']}") print(f"Similarity: {match['score']:.2%}") print(f"Stored code: {match['metadata']['code']}") print(f"Stored plan: {match['metadata']['plan']}") results = pinecone_wrapper.search_for_results( query_text="revenue analysis", top_k=5 ) for result in results: print(f"ID: {result['id']}, Score: {result['score']:.2f}") pinecone_wrapper.delete_record("analysis_001") ``` -------------------------------- ### Environment Variables Configuration Source: https://context7.com/pgalko/bambooai/llms.txt Configure required and optional environment variables for API keys, vector database, and execution settings by creating a `.env` file in your working directory. ```APIDOC ## Environment Variables Configuration Required and optional environment variables for API keys, vector database, and execution settings. Create a `.env` file in your working directory. ### Required Variables - **OPENAI_API_KEY**: Your OpenAI API key. ### Optional Variables - **ANTHROPIC_API_KEY**: Your Anthropic API key. - **GEMINI_API_KEY**: Your Gemini API key. - **GROQ_API_KEY**: Your Groq API key. - **MISTRAL_API_KEY**: Your Mistral API key. - **DEEPSEEK_API_KEY**: Your Deepseek API key. ### Vector Database Configuration - **VECTOR_DB_TYPE**: Type of vector database ('pinecone' or 'qdrant'). #### Pinecone Configuration - **PINECONE_API_KEY**: Your Pinecone API key. - **PINECONE_CLOUD**: The cloud provider for Pinecone (e.g., 'aws'). - **PINECONE_REGION**: The region for Pinecone. #### Qdrant Configuration - **QDRANT_URL**: The URL for your Qdrant instance. - **QDRANT_API_KEY**: Your Qdrant API key (optional for local). ### Embedding Platform - **EMBEDDING_PLATFORM**: The platform for embeddings ('openai' or 'hf_sentence_transformers'). ### Web Search Configuration - **WEB_SEARCH_MODE**: The mode for web search ('google_ai' or 'selenium'). - **SERPER_API_KEY**: Your Serper API key (required for 'selenium' mode). ### Code Execution Configuration - **EXECUTION_MODE**: The mode for code execution ('local' or 'api'). - **EXECUTOR_API_BASE_URL**: The base URL for the executor API (required for 'api' mode). ### Web Application Configuration - **FLASK_SECRET**: A secret key for Flask sessions. ### Plot Format - **BAMBOO_PLOT_FORMAT**: The format for plots ('json' or 'html'). ### Example `.env` file: ```bash OPENAI_API_KEY=sk-your-openai-api-key ANTHROPIC_API_KEY=your-anthropic-api-key VECTOR_DB_TYPE=pinecone PINECONE_API_KEY=your-pinecone-api-key PINECONE_CLOUD=aws PINECONE_REGION=us-east-1 EMBEDDING_PLATFORM=openai WEB_SEARCH_MODE=google_ai EXECUTION_MODE=local FLASK_SECRET=your-secret-key-for-sessions BAMBOO_PLOT_FORMAT=json ``` ``` -------------------------------- ### Configure Pinecone for BambooAI (Environment Variables) Source: https://github.com/pgalko/bambooai/blob/main/README.md Sets up environment variables for Pinecone integration with BambooAI. This includes specifying the vector database type, API key, cloud provider, and region. Pinecone offers a free tier for usage. ```dotenv VECTOR_DB_TYPE=pinecone PINECONE_API_KEY= PINECONE_CLOUD=aws PINECONE_REGION=us-east-1 ``` -------------------------------- ### Initialize Pinecone Wrapper in Python Source: https://context7.com/pgalko/bambooai/llms.txt Initializes the PineconeWrapper for interacting with the Pinecone vector database. Requires setting environment variables for API key and embedding platform. ```python from bambooai.qa_retrieval import PineconeWrapper import os # Environment setup os.environ['PINECONE_API_KEY'] = 'your-api-key' os.environ['EMBEDDING_PLATFORM'] = 'openai' # or 'hf_sentence_transformers' # Initialize wrapper pinecone_wrapper = PineconeWrapper() ``` -------------------------------- ### Configure Environment Variables with .env Source: https://context7.com/pgalko/bambooai/llms.txt Sets up required and optional environment variables for API keys, vector database connections, and execution settings. This `.env` file is crucial for authenticating with various LLM providers and configuring data storage and operational modes. ```bash # Required: At minimum one LLM provider API key OPENAI_API_KEY=sk-your-openai-api-key # Optional: Additional LLM providers ANTHROPIC_API_KEY=your-anthropic-api-key GEMINI_API_KEY=your-gemini-api-key GROQ_API_KEY=your-groq-api-key MISTRAL_API_KEY=your-mistral-api-key DEEPSEEK_API_KEY=your-deepseek-api-key # Vector Database (choose one) VECTOR_DB_TYPE=pinecone # or 'qdrant' # Pinecone configuration PINECONE_API_KEY=your-pinecone-api-key PINECONE_CLOUD=aws PINECONE_REGION=us-east-1 # Qdrant configuration QDRANT_URL=http://localhost:6333 QDRANT_API_KEY=your-qdrant-api-key # optional for local # Embedding platform for vector DB EMBEDDING_PLATFORM=openai # or 'hf_sentence_transformers' # Web search configuration WEB_SEARCH_MODE=google_ai # or 'selenium' SERPER_API_KEY=your-serper-api-key # required for selenium mode # Code execution mode EXECUTION_MODE=local # or 'api' for remote sandboxed execution EXECUTOR_API_BASE_URL=http://192.168.1.201:5000 # for api mode # Web application FLASK_SECRET=your-secret-key-for-sessions # Plot format BAMBOO_PLOT_FORMAT=json # or 'html' ``` -------------------------------- ### LLM Configuration File Source: https://context7.com/pgalko/bambooai/llms.txt Configure LLM models for specialized agents by creating a `LLM_CONFIG.json` file. This file specifies the agent, the model to use, its provider, and other details like max tokens and temperature. ```APIDOC ## LLM Configuration File Configure which LLM models to use for each specialized agent. Create a `LLM_CONFIG.json` file in your working directory with agent configurations and model properties. ### Request Body - **agent_configs** (array) - Required - An array of agent configurations. - **agent** (string) - Required - The name of the agent. - **details** (object) - Required - Details about the LLM model for the agent. - **model** (string) - Required - The name of the LLM model. - **provider** (string) - Required - The provider of the LLM model (e.g., 'openai', 'anthropic', 'gemini'). - **max_tokens** (integer) - Optional - The maximum number of tokens for the model. - **temperature** (number) - Optional - The temperature setting for the model. - **model_properties** (object) - Optional - Properties for different LLM models. - **[model_name]** (object) - Properties for a specific model. - **capability** (string) - Optional - The capability of the model. - **multimodal** (string) - Optional - Whether the model is multimodal ('true' or 'false'). - **templ_formating** (string) - Optional - The template formatting type. - **prompt_tokens** (number) - Optional - Cost per prompt token. - **completion_tokens** (number) - Optional - Cost per completion token. ### Request Example ```json { "agent_configs": [ { "agent": "Expert Selector", "details": { "model": "gpt-4.1", "provider": "openai", "max_tokens": 2000, "temperature": 0 } }, { "agent": "Analyst Selector", "details": { "model": "claude-sonnet-4-20250514", "provider": "anthropic", "max_tokens": 2000, "temperature": 0 } } ], "model_properties": { "gpt-4.1": { "capability": "base", "multimodal": "true", "templ_formating": "text", "prompt_tokens": 0.002, "completion_tokens": 0.008 } } } ``` ``` -------------------------------- ### Upload Ontology File via Curl Source: https://context7.com/pgalko/bambooai/llms.txt Uploads a custom RDF/OWL ontology file (e.g., .ttl format) to enhance domain-specific knowledge grounding for analysis. The file is sent as form data. ```bash curl -X POST http://localhost:5000/update_ontology \ -F "ontology_file=@/path/to/Sports_Data_Ontology.ttl" ``` -------------------------------- ### POST /query Source: https://context7.com/pgalko/bambooai/llms.txt The main query endpoint for the Flask web application. Accepts natural language queries and streams back analysis results including generated code, visualizations, and summaries. ```APIDOC ## POST /query ### Description The main query endpoint for the Flask web application. Accepts natural language queries and streams back analysis results including generated code, visualizations, and summaries. ### Method POST ### Endpoint `/query` ### Parameters #### Request Body - **query** (string) - Required - The natural language query. - **thread_id** (string) - Optional - The ID of the conversation thread. If `None`, a new thread will be auto-generated. - **chain_id** (string) - Optional - For conversation branching. - **image** (string) - Optional - Base64 encoded image for multimodal queries. - **user_code** (string) - Optional - Custom code to execute. ### Request Example ```python import requests import json response = requests.post( 'http://localhost:5000/query', json={ 'query': 'What is the average age by survival status?', 'thread_id': None, 'chain_id': None, 'image': None, 'user_code': None }, stream=True ) for line in response.iter_lines(): if line: data = json.loads(line.decode('utf-8')) # Process data... ``` ### Response The response is streamed line by line. Each line is a JSON object representing a part of the analysis result. #### Success Response (200 OK) Each streamed JSON object may contain one or more of the following fields: - **chain_id** (string) - The ID of the conversation chain. - **code** (string) - Generated code. - **answer** (string) - A summary or answer to the query. - **plot** (object) - Plot data in JSON or HTML format. - **id** (string) - Identifier for the plot. #### Response Example (streamed JSON objects) ```json {"chain_id": "some_chain_id"} {"code": "import pandas as pd\nprint(df.groupby('Survived')['Age'].mean())"} {"answer": "The average age by survival status is..."} {"plot": {"id": "plot_123", "data": "..."}} ``` ``` -------------------------------- ### Enable Planning Mode via Curl Source: https://context7.com/pgalko/bambooai/llms.txt Enables the planning agent, which breaks down complex tasks into step-by-step analysis plans before code generation. This is controlled via a POST request with a JSON body. ```bash curl -X POST http://localhost:5000/update_planning \ -H "Content-Type: application/json" \ -d '{"planning": true}' ``` -------------------------------- ### LLM Configuration Structure in JSON Source: https://github.com/pgalko/bambooai/blob/main/README.md This JSON structure defines the configuration for Large Language Models (LLMs) used in the project. It includes a list of agent configurations, each specifying an agent name and its detailed settings like model, provider, max tokens, and temperature. It also includes model properties, detailing capabilities, multimodality, templating format, and token pricing for various models. ```json { "agent_configs": [ {"agent": "Expert Selector", "details": {"model": "gpt-4.1", "provider":"openai","max_tokens": 2000, "temperature": 0}}, {"agent": "Analyst Selector", "details": {"model": "claude-3-7-sonnet-20250219", "provider":"anthropic","max_tokens": 2000, "temperature": 0}}, {"agent": "Theorist", "details": {"model": "gemini-2.5-pro-preview-03-25", "provider":"gemini","max_tokens": 4000, "temperature": 0}}, {"agent": "Dataframe Inspector", "details": {"model": "gemini-2.0-flash", "provider":"gemini","max_tokens": 8000, "temperature": 0}}, {"agent": "Planner", "details": {"model": "gemini-2.5-pro-preview-03-25", "provider":"gemini","max_tokens": 8000, "temperature": 0}}, {"agent": "Code Generator", "details": {"model": "claude-3-5-sonnet-20241022", "provider":"anthropic","max_tokens": 8000, "temperature": 0}}, {"agent": "Error Corrector", "details": {"model": "claude-3-5-sonnet-20241022", "provider":"anthropic","max_tokens": 8000, "temperature": 0}}, {"agent": "Reviewer", "details": {"model": "gemini-2.5-pro-preview-03-25", "provider":"gemini","max_tokens": 8000, "temperature": 0}}, {"agent": "Solution Summarizer", "details": {"model": "gemini-2.5-flash-preview-04-17", "provider":"gemini","max_tokens": 4000, "temperature": 0}}, {"agent": "Google Search Executor", "details": {"model": "gemini-2.5-flash-preview-04-17", "provider":"gemini","max_tokens": 4000, "temperature": 0}}, {"agent": "Google Search Summarizer", "details": {"model": "gemini-2.5-flash-preview-04-17", "provider":"gemini","max_tokens": 4000, "temperature": 0}} ], "model_properties": { "gpt-4o": {"capability":"base","multimodal":"true", "templ_formating":"text", "prompt_tokens": 0.0025, "completion_tokens": 0.010}, "gpt-4.1": {"capability":"base","multimodal":"true", "templ_formating":"text", "prompt_tokens": 0.002, "completion_tokens": 0.008}, "gpt-4o-mini": {"capability":"base", "multimodal":"true","templ_formating":"text", "prompt_tokens": 0.00015, "completion_tokens": 0.0006}, "gpt-4.1-mini": {"capability":"base", "multimodal":"true","templ_formating":"text", "prompt_tokens": 0.0004, "completion_tokens": 0.0016}, "o1-mini": {"capability":"reasoning", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.003, "completion_tokens": 0.012}, "o3-mini": {"capability":"reasoning", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.0011, "completion_tokens": 0.0044}, "o1": {"capability":"reasoning", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.015, "completion_tokens": 0.06}, "gemini-2.0-flash": {"capability":"base", "multimodal":"true","templ_formating":"text", "prompt_tokens": 0.0001, "completion_tokens": 0.0004}, "gemini-2.5-flash-preview-04-17": {"capability":"reasoning", "multimodal":"true","templ_formating":"text", "prompt_tokens": 0.00015, "completion_tokens": 0.0035}, "gemini-2.0-flash-thinking-exp-01-21": {"capability":"reasoning", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.0, "completion_tokens": 0.0}, "gemini-2.5-pro-exp-03-25": {"capability":"reasoning", "multimodal":"true","templ_formating":"text", "prompt_tokens": 0.0, "completion_tokens": 0.0}, "gemini-2.5-pro-preview-03-25": {"capability":"reasoning", "multimodal":"true","templ_formating":"text", "prompt_tokens": 0.00125, "completion_tokens": 0.01}, "claude-3-5-haiku-20241022": {"capability":"base", "multimodal":"true","templ_formating":"xml", "prompt_tokens": 0.0008, "completion_tokens": 0.004}, "claude-3-5-sonnet-20241022": {"capability":"base", "multimodal":"true","templ_formating":"xml", "prompt_tokens": 0.003, "completion_tokens": 0.015}, "claude-3-7-sonnet-20250219": {"capability":"base", "multimodal":"true","templ_formating":"xml", "prompt_tokens": 0.003, "completion_tokens": 0.015}, "open-mixtral-8x7b": {"capability":"base", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.0007, "completion_tokens": 0.0007}, "mistral-small-latest": {"capability":"base", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.001, "completion_tokens": 0.003}, "codestral-latest": {"capability":"base", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.001, "completion_tokens": 0.003}, "open-mixtral-8x22b": {"capability":"base", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.002, "completion_tokens": 0.006}, "mistral-large-2407": {"capability":"base", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.003, "completion_tokens": 0.009}, "deepseek-chat": {"capability":"base", "multimodal":"false","templ_formating":"text", "prompt_tokens": 0.00014, "completion_tokens": 0.00028} } } ``` -------------------------------- ### Configure LLM Agents for BambooAI (JSON) Source: https://github.com/pgalko/bambooai/blob/main/README.md Provides a sample JSON structure for configuring Large Language Model (LLM) agents within BambooAI. This allows customization of models, providers, and parameters for different agents, which is essential for the web application. ```json { "agent_configs": [ { "agent": "Code Generator", "details": { "model": "your-preferred-model", "provider": "provider-name", "max_tokens": 4000, "temperature": 0 } } ] } ``` -------------------------------- ### Execute Python Code Locally with CodeExecutor Source: https://context7.com/pgalko/bambooai/llms.txt Shows how to use the CodeExecutor to run Python code locally, including DataFrame manipulation, plot generation with Plotly, and error handling. It requires pandas and plotly. ```python from bambooai.code_executor import CodeExecutor import pandas as pd executor = CodeExecutor( webui=True, mode='local', user_id='demo_user' ) df = pd.DataFrame({ 'date': pd.date_range('2024-01-01', periods=100), 'value': range(100), 'category': ['A', 'B'] * 50 }) code = """ import plotly.express as px # Calculate statistics summary = df.groupby('category')['value'].agg(['mean', 'std', 'count']) print("Category Statistics:") print(summary) # Create visualization fig = px.line(df, x='date', y='value', color='category', title='Values Over Time') fig.show() """ result_df, results, error, plot_images, generated_datasets = executor.execute( code=code, df=df, df_id='dataset_001', generated_datasets_path='datasets/generated/001' ) if error: print(f"Execution error:\n{error}") else: print(f"Output:\n{results}") print(f"Number of plots: {len(plot_images)}") for plot in plot_images: print(f"Plot format: {plot['format']}") ``` -------------------------------- ### Dataframe Inspector Extraction Prompt Logic (YAML) Source: https://github.com/pgalko/bambooai/wiki/Grounding-Data-Analysis-with-Domain‐Specific-Ontologies An illustrative snippet of the prompt logic used by the Dataframe Inspector agent. It dictates strict rules for extracting functions from an ontology, emphasizing verbatim extraction of only task-relevant functions and prohibiting any modifications or invented functions. ```yaml # ... (metadata, data_hierarchy) ... functions: REQUIREMENTS: - ONLY extract functions defined in the ontology. - ONLY include functions needed for this task. - Extract VERBATIM from the ontology. - NO modifications or additions. - NO invented functions. # ... (relationships) ... ``` -------------------------------- ### Upload Datasets to BambooAI Web App API Source: https://context7.com/pgalko/bambooai/llms.txt Describes the process for uploading datasets, such as CSV or Parquet files, to the BambooAI web application. This functionality is essential for providing the primary data source for analysis and works with both local and remote execution modes. ```bash # The specific command or method for uploading datasets via the API is not provided in the text. # This section typically involves a POST request with file data, potentially using 'curl' or a Python library like 'requests'. ``` -------------------------------- ### Query BambooAI Web App API Endpoint (Python) Source: https://context7.com/pgalko/bambooai/llms.txt Demonstrates how to send natural language queries to the BambooAI web application's query endpoint using Python's `requests` library. This endpoint streams back analysis results, including generated code, visualizations, and summaries. It supports optional parameters for thread and chain IDs, and multimodal inputs. ```python # Server-side: Start the Flask web application # cd web_app && python app.py # Client-side: Query the API import requests import json # Stream query results response = requests.post( 'http://localhost:5000/query', json={ 'query': 'What is the average age by survival status?', 'thread_id': None, # Auto-generated if None 'chain_id': None, # For conversation branching 'image': None, # Base64 encoded image for multimodal 'user_code': None # Custom code to execute }, stream=True ) # Process streamed responses for line in response.iter_lines(): if line: data = json.loads(line.decode('utf-8')) # Handle different response types if 'chain_id' in data: print(f"Chain ID: {data['chain_id']}") if 'code' in data: print(f"Generated code:\n{data['code']}") if 'answer' in data: print(f"Summary: {data['answer']}") if 'plot' in data: # Plot data in JSON or HTML format print(f"Plot generated: {data['id']}") ``` -------------------------------- ### Single Query BambooAI Usage (Python) Source: https://github.com/pgalko/bambooai/blob/main/README.md Shows how to perform a single, specific data analysis query using BambooAI's conversational agent. This method is useful for direct requests without initiating a full interactive session. ```python bamboo.pd_agent_converse("Calculate 30, 50, 75 and 90 percentiles of the heart rate column") ``` -------------------------------- ### Custom Function Definition in Sports Data Ontology (Python) Source: https://github.com/pgalko/bambooai/wiki/Grounding-Data-Analysis-with-Domain‐Specific-Ontologies This snippet illustrates how custom Python functions can be embedded within an RDFS ontology. It specifies the function's purpose, its implementation code, and expected inputs, ensuring the LLM uses validated, domain-specific calculations. ```python rdfs:comment "This function is used to measure cardiovascular drift..." . ``` -------------------------------- ### Configure LLM Models with LLM_CONFIG.json Source: https://context7.com/pgalko/bambooai/llms.txt Defines the LLM models to be used by specialized agents within the BambooAI project. This JSON file specifies agent configurations, including the model name, provider, maximum tokens, and temperature. It also includes model properties detailing capabilities, multimodal support, and token costs. ```json { "agent_configs": [ { "agent": "Expert Selector", "details": { "model": "gpt-4.1", "provider": "openai", "max_tokens": 2000, "temperature": 0 } }, { "agent": "Analyst Selector", "details": { "model": "claude-sonnet-4-20250514", "provider": "anthropic", "max_tokens": 2000, "temperature": 0 } }, { "agent": "Planner", "details": { "model": "gemini-2.5-pro", "provider": "gemini", "max_tokens": 15000, "temperature": 0 } }, { "agent": "Code Generator", "details": { "model": "claude-sonnet-4-20250514", "provider": "anthropic", "max_tokens": 8000, "temperature": 0 } }, { "agent": "Error Corrector", "details": { "model": "claude-sonnet-4-20250514", "provider": "anthropic", "max_tokens": 8000, "temperature": 0 } }, { "agent": "Solution Summarizer", "details": { "model": "gemini-2.5-flash", "provider": "gemini", "max_tokens": 4000, "temperature": 0 } } ], "model_properties": { "gpt-4.1": { "capability": "base", "multimodal": "true", "templ_formating": "text", "prompt_tokens": 0.002, "completion_tokens": 0.008 }, "claude-sonnet-4-20250514": { "capability": "base", "multimodal": "true", "templ_formating": "xml", "prompt_tokens": 0.003, "completion_tokens": 0.015 }, "gemini-2.5-pro": { "capability": "reasoning", "multimodal": "true", "templ_formating": "text", "prompt_tokens": 0.00125, "completion_tokens": 0.01 } } } ```