### Install Dependencies with uv Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/readme.md Installs project dependencies using 'uv'. Supports installation from a 'pyproject.toml' file or a 'requirements.txt' file. ```bash uv pip install . ``` ```bash uv pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies with pip Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/readme.md Installs project dependencies using 'pip' after activating the virtual environment. Requires a 'requirements.txt' file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Launch Project Server Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/readme.md Starts the LemonAI project server. Ensure the virtual environment is activated and you are in the correct directory before running. ```python # activate virtual environment python src/server.py ``` -------------------------------- ### Install Browser Plugin Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/readme.md Installs the 'patchright' browser plugin for Chromium. This command should be run after activating the virtual environment. ```bash # before this step, you need to activate virtual environment patchright install chromium --with-deps --no-shell ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/readme.md Changes the current directory to the specified project path. This is a prerequisite for most installation and launch commands. ```bash cd /path/to/browserUse ``` ```bash cd /path/to/browser_server ``` -------------------------------- ### Create Virtual Environment with uv Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/readme.md Creates a new Python virtual environment using the 'uv' package manager. This helps isolate project dependencies. ```bash uv venv ``` -------------------------------- ### Activate Virtual Environment Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/readme.md Activates the created virtual environment. This ensures that subsequent commands use the environment's Python interpreter and packages. ```bash source .venv/bin/activate ``` ```bash .venv\Scripts\activate ``` -------------------------------- ### Install Chromium for Playwright Source: https://github.com/hexdocom/lemonai/blob/main/resources/browser/install.md Installs the Chromium browser required by Playwright for browser automation. This command should be run in the project's root directory before packaging. ```bash npx playwright install chromium ``` -------------------------------- ### Docker Deployment and Configuration (Bash) Source: https://context7.com/hexdocom/lemonai/llms.txt Provides commands to deploy Lemon AI using Docker. Includes pulling the runtime sandbox image, running the container with specific environment variables and volume mounts, and starting the application. It also shows how to use docker-compose for deployment. ```bash # Pull the runtime sandbox image docker pull hexdolemonai/lemon-runtime-sandbox:latest # Run Lemon AI with Docker docker run -it --rm --pull=always \ --name lemon-app \ --env DOCKER_HOST_ADDR=host.docker.internal \ --env ACTUAL_HOST_WORKSPACE_PATH=${WORKSPACE_BASE:-$PWD/workspace} \ --publish 5005:5005 \ --add-host host.docker.internal:host-gateway \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume ~/.cache:/.cache \ --volume ${WORKSPACE_BASE:-$PWD/workspace}:/workspace \ --volume ${WORKSPACE_BASE:-$PWD/data}:/app/data \ --interactive \ --tty \ hexdolemonai/lemon:latest make run ``` ```yaml services: lemon: image: hexdolemonai/lemon:latest container_name: lemon-app environment: - DOCKER_HOST_ADDR=host.docker.internal - ACTUAL_HOST_WORKSPACE_PATH=${WORKSPACE_BASE:-$PWD/workspace} ports: - "5005:5005" extra_hosts: - "host.docker.internal:host-gateway" volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/.cache:/.cache - ${WORKSPACE_BASE:-$PWD/workspace}:/app/workspace - ${WORKSPACE_BASE:-$PWD/data}:/app/data stdin_open: true tty: true command: make run # Start with docker-compose docker-compose up -d ``` -------------------------------- ### Common Action Sequences for AI Agent Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/browser_use/agent/prompt/base_system_prompt.md Provides examples of common action sequences, such as form filling and navigation/extraction. These sequences illustrate how to chain actions for specific tasks. ```json [ {"input_text": {"index": 1, "text": "username"}}, {"input_text": {"index": 2, "text": "password"}}, {"click_element": {"index": 3}} ] ``` ```json [ {"go_to_url": {"url": "https://example.com"}}, {"extract_content": {"goal": "extract the names"}} ] ``` -------------------------------- ### Run Lemon AI Editor with Docker Source: https://github.com/hexdocom/lemonai/blob/main/README.md This command pulls the latest Lemon AI runtime sandbox image and runs it as a container. It configures necessary environment variables, port mappings, and volume mounts for persistent storage and Docker socket integration. The container runs the 'make run' command to start the Lemon AI application. ```bash docker pull hexdolemonai/lemon-runtime-sandbox:latest docker run -it --rm --pull=always \ --name lemon-app \ --env DOCKER_HOST_ADDR=host.docker.internal \ --env ACTUAL_HOST_WORKSPACE_PATH=${WORKSPACE_BASE:-$PWD/workspace} \ --publish 5005:5005 \ --add-host host.docker.internal:host-gateway \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume ~/.cache:/.cache \ --volume ${WORKSPACE_BASE:-$PWD/workspace}:/workspace \ --volume ${WORKSPACE_BASE:-$PWD/data}:/app/data \ --interactive \ --tty \ hexdolemonai/lemon:latest make run ``` -------------------------------- ### Get All Agents - Agent Management API - API Source: https://context7.com/hexdocom/lemonai/llms.txt Retrieves a list of all available AI agents. Requires an authorization token. ```bash curl -X GET http://localhost:5005/api/agent \ -H "Authorization: Bearer " ``` -------------------------------- ### Start Chat Conversation with cURL Source: https://context7.com/hexdocom/lemonai/llms.txt This snippet demonstrates initiating a chat conversation using cURL. It's designed for Q&A and general conversation, supporting conversation threading and context maintenance. Requires a bearer token. ```bash curl -X POST http://localhost:5005/api/agent/chat \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "question": "What are the benefits of using Docker for development?", "conversation_id": "550e8400-e29b-41d4-a716-446655440000", "pid": -1, "model_id": 48 }' ``` -------------------------------- ### Get VSCode URL for Conversation Workspace (API) Source: https://context7.com/hexdocom/lemonai/llms.txt Retrieves the VSCode URL for a specific conversation workspace using a GET request to the runtime API. Requires a conversation ID and an authorization token. Returns a JSON object containing the workspace URL. ```bash curl -X GET "http://localhost:5005/api/runtime/vscode-url?conversation_id=550e8400-e29b-41d4-a716-446655440000" \ -H "Authorization: Bearer " ``` -------------------------------- ### Configure LLM Platforms and Models (POST, GET, PUT) Source: https://context7.com/hexdocom/lemonai/llms.txt API for managing LLM platforms (e.g., OpenAI, Anthropic) and their associated models. Supports creating, retrieving, updating platforms, and checking API availability. Also allows creating and listing models under specific platforms. ```bash # Create a new platform curl -X POST http://localhost:5005/api/platform \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "OpenAI", "logo_url": "https://example.com/openai.png", "source_type": "api" }' # Get all platforms curl -X GET http://localhost:5005/api/platform \ -H "Authorization: Bearer " # Update platform with API credentials curl -X PUT http://localhost:5005/api/platform/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "OpenAI", "api_key": "sk-...", "api_url": "https://api.openai.com/v1", "is_enabled": true }' # Check API availability curl -X POST http://localhost:5005/api/platform/check_api_availability \ -H "Content-Type: application/json" \ -d '{ "base_url": "https://api.openai.com/v1", "api_key": "sk-...", "model": "gpt-4" }' # Create a model under a platform curl -X POST http://localhost:5005/api/model \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "platform_id": 1, "model_id": "gpt-4-turbo", "model_name": "GPT-4 Turbo", "group_name": "GPT-4", "model_types": ["chat", "code"] }' # Get enabled models across all platforms curl -X GET http://localhost:5005/api/model/enabled \ -H "Authorization: Bearer " # Get models for a specific platform curl -X GET http://localhost:5005/api/model/list/1 \ -H "Authorization: Bearer " ``` -------------------------------- ### Manage Knowledge Base Entries (POST, GET, PUT, DELETE) Source: https://context7.com/hexdocom/lemonai/llms.txt API for managing agent knowledge entries, enabling self-evolving learning. Supports creating, retrieving (all for agent, specific entry), updating, and deleting knowledge. Requires authorization and agent ID for some operations. ```bash # Create a knowledge entry curl -X POST http://localhost:5005/api/knowledge \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "content": "When creating charts, always use responsive designs", "category": "best_practices", "agent_id": 1 }' # Get all knowledge for an agent curl -X GET "http://localhost:5005/api/knowledge?agent_id=1" \ -H "Authorization: Bearer " # Response: # { # "code": 0, # "data": { # "personal": [{"id": 1, "content": "Custom knowledge..."}], # "system": [{"id": 2, "content": "Learned from conversations...", "is_learned": true}] # } # } # Get a specific knowledge entry curl -X GET http://localhost:5005/api/knowledge/detail/1 \ -H "Authorization: Bearer " # Update a knowledge entry curl -X PUT http://localhost:5005/api/knowledge/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "content": "Updated best practice for chart creation", "category": "visualization" }' # Delete a knowledge entry curl -X DELETE http://localhost:5005/api/knowledge/1 \ -H "Authorization: Bearer " ``` -------------------------------- ### Manage MCP Servers (POST, GET, PUT, DELETE) Source: https://context7.com/hexdocom/lemonai/llms.txt Endpoints for managing Model Context Protocol (MCP) servers, which extend agent capabilities. Supports creating, retrieving (all, active), updating, and deleting MCP server connections. Requires authorization. ```bash # Create an MCP server connection curl -X POST http://localhost:5005/api/mcp_server \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "GitHub Integration", "url": "https://mcp.github.com", "description": "GitHub repository operations", "activate": true, "type": "stdio", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": {"GITHUB_TOKEN": "ghp_..."} }' # Get all MCP servers curl -X GET http://localhost:5005/api/mcp_server \ -H "Authorization: Bearer " # Get active MCP servers only curl -X GET http://localhost:5005/api/mcp_server/active \ -H "Authorization: Bearer " # Update an MCP server curl -X PUT http://localhost:5005/api/mcp_server/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "GitHub Integration v2", "activate": true }' # Delete an MCP server curl -X DELETE http://localhost:5005/api/mcp_server/1 \ -H "Authorization: Bearer " ``` -------------------------------- ### Get VSCode URL for a conversation workspace Source: https://context7.com/hexdocom/lemonai/llms.txt Retrieves the VSCode URL for a given conversation ID, allowing direct access to the workspace in a VSCode environment. ```APIDOC ## GET /api/runtime/vscode-url ### Description Get the VSCode URL for a conversation workspace. ### Method GET ### Endpoint /api/runtime/vscode-url ### Parameters #### Query Parameters - **conversation_id** (string) - Required - The ID of the conversation workspace. #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Response #### Success Response (200) - **code** (integer) - Response code, 0 indicates success. - **data** (object) - Contains the URL for the VSCode workspace. - **url** (string) - The URL to access the VSCode workspace. ``` -------------------------------- ### Copy Chromium Browser Binaries to Resources (Mac) Source: https://github.com/hexdocom/lemonai/blob/main/resources/browser/install.md Copies the installed Chromium browser binaries from the Playwright cache to the project's resources directory. This is a necessary step for the search functionality to work on Mac systems. ```bash cp -r ~/Library/Caches/ms-playwright/chromium_headless_shell-*/* resources/browser/chromium/ ``` -------------------------------- ### Docker Deployment Source: https://context7.com/hexdocom/lemonai/llms.txt Instructions for deploying Lemon AI using Docker, including pulling the image, running the container, and using docker-compose. ```APIDOC ## Docker Deployment Deploy Lemon AI using Docker for quick setup with a sandboxed execution environment. ### Pulling the Image ```bash docker pull hexdolemonai/lemon-runtime-sandbox:latest ``` ### Running Lemon AI with Docker ```bash docker run -it --rm --pull=always \ --name lemon-app \ --env DOCKER_HOST_ADDR=host.docker.internal \ --env ACTUAL_HOST_WORKSPACE_PATH=${WORKSPACE_BASE:-$PWD/workspace} \ --publish 5005:5005 \ --add-host host.docker.internal:host-gateway \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume ~/.cache:/.cache \ --volume ${WORKSPACE_BASE:-$PWD/workspace}:/workspace \ --volume ${WORKSPACE_BASE:-$PWD/data}:/app/data \ --interactive \ --tty \ hexdolemonai/lemon:latest make run ``` ### Using Docker Compose #### `docker-compose.yml` ```yaml services: lemon: image: hexdolemonai/lemon:latest container_name: lemon-app environment: - DOCKER_HOST_ADDR=host.docker.internal - ACTUAL_HOST_WORKSPACE_PATH=${WORKSPACE_BASE:-$PWD/workspace} ports: - "5005:5005" extra_hosts: - "host.docker.internal:host-gateway" volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/.cache:/.cache - ${WORKSPACE_BASE:-$PWD/workspace}:/app/workspace - ${WORKSPACE_BASE:-$PWD/data}:/app/data stdin_open: true tty: true command: make run ``` #### Starting with Docker Compose ```bash docker-compose up -d ``` ``` -------------------------------- ### HTML Structure for Application Initialization Progress Source: https://github.com/hexdocom/lemonai/blob/main/setup.html This HTML snippet defines the structure for displaying the initialization steps and progress of the LemonAI application. It includes elements for step indicators, status messages, and a progress bar. The styling is handled by CSS. ```html
1
Check if Docker is Installed
2
Check if Docker is Start
3
Check if image exists
Initializing...
0%
``` -------------------------------- ### CSS Styling for Application Initialization UI Source: https://github.com/hexdocom/lemonai/blob/main/setup.html This CSS code provides styling for the LemonAI application initialization interface. It defines the layout, appearance of steps, progress bar, and status messages to create a user-friendly progress indicator. ```css body { font-family: Arial, sans-serif; text-align: center; padding-top: 50px; background-color: #f9f9f9; } .container { max-width: 600px; margin: 0 auto; } .steps-container { display: flex; justify-content: space-between; align-items: flex-start; } .step-item { width: calc(33.33% - 20px); position: relative; display: flex; flex-direction: column; align-content: center; align-items: center; } #progress-bar-container { display: none; width: 80%; margin: 20px auto; background-color: #f3f3f3; border-radius: 5px; } #progress-bar { width: 0%; height: 25px; background-color: #4CAF50; border-radius: 5px; text-align: center; line-height: 25px; color: white; } .step-number { font-size: 1em; font-weight: bold; color: #fff; width: 32px; height: 32px; margin-top: 10px; margin-bottom: 10px; border-radius: 100px; background: #d9d9d9; display: flex; justify-content: center; align-items: center; } #status-message { margin-top: 30px; } .step-number.active { background: #1677ff; } /* .step-number.success { color: #52c41a; } .step-number.failed { color: #f5222d; } */ .step-title { font-size: 16px; margin-bottom: 5px; color: #333; text-align: center; } .status-message { color: #777; text-align: center; } .progress-bar-container { width: 100%; background-color: #e0e0e0; border-radius: 5px; overflow: hidden; display: none; margin-top: 10px; } .progress-bar { height: 25px; background-color: #1890ff; border-radius: 5px; text-align: center; line-height: 25px; color: white; transition: width 1s ease-in-out; } .progress-bar.failed { background-color: #f5222d; } .arrow { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 2em; color: #aaa; } .last-step .arrow { display: none; } #error-message { color: red; margin-top: 20px; display: none; font-size: 1.1em; } ``` -------------------------------- ### Get All Conversations with cURL Source: https://context7.com/hexdocom/lemonai/llms.txt This snippet demonstrates how to retrieve all conversations associated with a specific agent using cURL. It requires the agent ID as a query parameter and a bearer token for authorization. ```bash curl -X GET "http://localhost:5005/api/conversation?agent_id=1" \ -H "Authorization: Bearer " ``` -------------------------------- ### Manage Agents (GET, PUT, DELETE) Source: https://context7.com/hexdocom/lemonai/llms.txt Endpoints for retrieving, updating, and deleting specific agents. Requires an authorization token. The update endpoint accepts JSON payload for agent modifications. ```bash curl -X GET http://localhost:5005/api/agent/1 \ -H "Authorization: Bearer " curl -X PUT http://localhost:5005/api/agent/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "Advanced Data Agent", "describe": "Enhanced data analysis capabilities", "mcp_server_ids": [1, 2, 3] }' curl -X DELETE http://localhost:5005/api/agent/1 \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Specific Conversation with cURL Source: https://context7.com/hexdocom/lemonai/llms.txt This snippet shows how to retrieve details for a specific conversation using its ID via cURL. It requires the conversation ID in the URL path and a bearer token for authentication. ```bash curl -X GET http://localhost:5005/api/conversation/550e8400-e29b-41d4-a716-446655440000 \ -H "Authorization: Bearer " ``` -------------------------------- ### Environment Configuration Source: https://context7.com/hexdocom/lemonai/llms.txt Details on configuring Lemon AI's behavior using environment variables, covering storage, workspace, runtime, knowledge base, and platform API keys. ```APIDOC ## Environment Configuration Configure Lemon AI behavior through environment variables. ### `.env` Configuration File Examples #### Core Settings - **STORAGE_PATH** (string) - SQLite database location (e.g., `data/database.sqlite`). - **WORKSPACE_DIR** (string) - Workspace directory for conversations (e.g., `workspace`). - **RUNTIME_TYPE** (string) - Specifies the runtime environment: `local`, `docker`, or `local-docker`. - **ENABLE_KNOWLEDGE** (string) - Enables or disables the self-learning knowledge base (e.g., `ON` or `OFF`). #### Platform API Configuration (Optional) - **OPENAI_API_KEY** (string) - Your OpenAI API key. - **ANTHROPIC_API_KEY** (string) - Your Anthropic API key. #### Static File Serving (for Docker runtime) - **STATIC_DOMAIN** (string) - Domain for serving static files (e.g., `static.lemonai.ai`). - **STATIC_PROTOCOL** (string) - Protocol for static file serving (e.g., `https`). ### Example `.env` file: ```dotenv STORAGE_PATH=data/database.sqlite WORKSPACE_DIR=workspace RUNTIME_TYPE=local-docker ENABLE_KNOWLEDGE=ON # Platform API configuration (optional) OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... # Static file serving (for docker runtime) STATIC_DOMAIN=static.lemonai.ai STATIC_PROTOCOL=https ``` ``` -------------------------------- ### Get File Version History - File Editor API - API Source: https://context7.com/hexdocom/lemonai/llms.txt Retrieves the version history for a specific file within a conversation. Requires the conversation ID and file path in JSON format. Requires an authorization token. ```bash curl -X POST http://localhost:5005/api/file/editor/versions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "conversation_id": "550e8400-e29b-41d4-a716-446655440000", "filepath": "Conversation_550e84/dashboard.html" }' ``` -------------------------------- ### Platform and Model Configuration API Source: https://context7.com/hexdocom/lemonai/llms.txt Configure LLM platforms and manage models, including API key management and availability checks. ```APIDOC ## POST /api/platform ### Description Creates a new LLM platform configuration. ### Method POST ### Endpoint /api/platform ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (string) - Required - The name of the platform (e.g., "OpenAI"). - **logo_url** (string) - Optional - URL for the platform's logo. - **source_type** (string) - Required - The type of source (e.g., "api", "local"). ### Request Example ```bash curl -X POST http://localhost:5005/api/platform \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "OpenAI", "logo_url": "https://example.com/openai.png", "source_type": "api" }' ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the created platform. - **message** (string) - Confirmation message. #### Response Example ```json { "id": 1, "message": "Platform created successfully" } ``` ## GET /api/platform ### Description Retrieves a list of all configured LLM platforms. ### Method GET ### Endpoint /api/platform ### Parameters None ### Request Example ```bash curl -X GET http://localhost:5005/api/platform \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **platforms** (array of objects) - A list of platform configurations. #### Response Example ```json [ { "id": 1, "name": "OpenAI", "logo_url": "https://example.com/openai.png", "source_type": "api" } ] ``` ## PUT /api/platform/{id} ### Description Updates an existing platform configuration, potentially adding API credentials. ### Method PUT ### Endpoint /api/platform/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the platform to update. #### Query Parameters None #### Request Body - **name** (string) - Optional - The new name for the platform. - **api_key** (string) - Optional - The API key for the platform. - **api_url** (string) - Optional - The API endpoint URL. - **is_enabled** (boolean) - Optional - Whether the platform is enabled. ### Request Example ```bash curl -X PUT http://localhost:5005/api/platform/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "OpenAI", "api_key": "sk-...", "api_url": "https://api.openai.com/v1", "is_enabled": true }' ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of the update. #### Response Example ```json { "message": "Platform updated successfully" } ``` ## POST /api/platform/check_api_availability ### Description Checks the availability of an LLM API endpoint with provided credentials and model. ### Method POST ### Endpoint /api/platform/check_api_availability ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **base_url** (string) - Required - The base URL of the API. - **api_key** (string) - Required - The API key for authentication. - **model** (string) - Required - The model to check availability for. ### Request Example ```bash curl -X POST http://localhost:5005/api/platform/check_api_availability \ -H "Content-Type: application/json" \ -d '{ "base_url": "https://api.openai.com/v1", "api_key": "sk-...", "model": "gpt-4" }' ``` ### Response #### Success Response (200) - **available** (boolean) - Indicates if the API is available. - **message** (string) - Status message. #### Response Example ```json { "available": true, "message": "API is available" } ``` ## POST /api/model ### Description Creates a new model configuration under a specific platform. ### Method POST ### Endpoint /api/model ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **platform_id** (integer) - Required - The ID of the platform this model belongs to. - **model_id** (string) - Required - The unique identifier for the model. - **model_name** (string) - Required - The human-readable name of the model. - **group_name** (string) - Optional - The group the model belongs to. - **model_types** (array of strings) - Optional - Types of the model (e.g., "chat", "code"). ### Request Example ```bash curl -X POST http://localhost:5005/api/model \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "platform_id": 1, "model_id": "gpt-4-turbo", "model_name": "GPT-4 Turbo", "group_name": "GPT-4", "model_types": ["chat", "code"] }' ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the created model. - **message** (string) - Confirmation message. #### Response Example ```json { "id": 1, "message": "Model created successfully" } ``` ## GET /api/model/enabled ### Description Retrieves a list of all enabled models across all platforms. ### Method GET ### Endpoint /api/model/enabled ### Parameters None ### Request Example ```bash curl -X GET http://localhost:5005/api/model/enabled \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **models** (array of objects) - A list of enabled model configurations. #### Response Example ```json [ { "id": 1, "platform_id": 1, "model_id": "gpt-4", "model_name": "GPT-4" } ] ``` ## GET /api/model/list/{platform_id} ### Description Retrieves a list of models available for a specific platform. ### Method GET ### Endpoint /api/model/list/{platform_id} ### Parameters #### Path Parameters - **platform_id** (integer) - Required - The ID of the platform whose models to retrieve. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET http://localhost:5005/api/model/list/1 \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **models** (array of objects) - A list of model configurations for the specified platform. #### Response Example ```json [ { "id": 1, "model_id": "gpt-4", "model_name": "GPT-4" } ] ``` ``` -------------------------------- ### Create a New Agent - Agent Management API - API Source: https://context7.com/hexdocom/lemonai/llms.txt Creates a new AI agent with specified name, description, MCP server IDs, and public status. Requires an authorization token. ```bash curl -X POST http://localhost:5005/api/agent \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "Data Analysis Agent", "describe": "Specialized in data visualization and analysis", "mcp_server_ids": [1, 2], "is_public": true }' ``` -------------------------------- ### Task Completion and 'Done' Action Source: https://github.com/hexdocom/lemonai/blob/main/browser_server/browser_use/agent/prompt/base_system_prompt.md Explains the usage of the 'done' action for task completion, including conditions for its use and how to include gathered information. It also covers handling partial completion and success status. ```json // Example of 'done' action when task is fully completed { "action": [ { "done": { "success": true, "text": "All requested information gathered." } } ] } // Example of 'done' action when task is partially completed (e.g., reached max steps) { "action": [ { "done": { "success": false, "text": "Reached max steps. Gathered partial information: ..." } } ] } ``` -------------------------------- ### List All Uploaded Files - API Source: https://context7.com/hexdocom/lemonai/llms.txt Retrieves a list of all files that have been uploaded. Requires an authorization token. ```bash curl -X GET http://localhost:5005/api/file/list \ -H "Authorization: Bearer " ``` -------------------------------- ### File Editor and Version Control API Source: https://context7.com/hexdocom/lemonai/llms.txt APIs for editing files, managing versions, and reading file content. ```APIDOC ## PUT /api/file/editor ### Description Updates the content of a file, creating a new version. ### Method PUT ### Endpoint `/api/file/editor` ### Parameters #### Request Body - **path** (string) - Required - The path to the file. - **content** (string) - Required - The new content for the file. - **conversation_id** (string) - Required - The ID of the conversation the file belongs to. ### Request Example ```json { "path": "Conversation_550e84/dashboard.html", "content": "Updated content", "conversation_id": "550e8400-e29b-41d4-a716-446655440000" } ``` ### Response #### Success Response (200) - **data** (object) - Information about the updated file version. - **data.id** (integer) - The ID of the file. - **data.version** (integer) - The new version number of the file. - **data.filepath** (string) - The path of the file. #### Response Example ```json { "code": 0, "data": {"id": 5, "version": 3, "filepath": "Conversation_550e84/dashboard.html"} } ``` ## POST /api/file/editor/read ### Description Reads the content of a file. ### Method POST ### Endpoint `/api/file/editor/read` ### Parameters #### Request Body - **path** (string) - Required - The path to the file. ### Request Example ```json { "path": "Conversation_550e84/dashboard.html" } ``` ## POST /api/file/editor/versions ### Description Retrieves the version history for a specific file. ### Method POST ### Endpoint `/api/file/editor/versions` ### Parameters #### Request Body - **conversation_id** (string) - Required - The ID of the conversation the file belongs to. - **filepath** (string) - Required - The path of the file. ### Request Example ```json { "conversation_id": "550e8400-e29b-41d4-a716-446655440000", "filepath": "Conversation_550e84/dashboard.html" } ``` ## POST /api/file/editor/switch-version ### Description Switches a file to a specific version. ### Method POST ### Endpoint `/api/file/editor/switch-version` ### Parameters #### Request Body - **version_id** (integer) - Required - The ID of the version to switch to. - **conversation_id** (string) - Required - The ID of the conversation the file belongs to. - **filepath** (string) - Required - The path of the file. ### Request Example ```json { "version_id": 2, "conversation_id": "550e8400-e29b-41d4-a716-446655440000", "filepath": "Conversation_550e84/dashboard.html" } ``` ``` -------------------------------- ### MCP Server Integration API Source: https://context7.com/hexdocom/lemonai/llms.txt Manage Model Context Protocol (MCP) servers for extending agent capabilities. ```APIDOC ## POST /api/mcp_server ### Description Creates a new MCP server connection. ### Method POST ### Endpoint /api/mcp_server ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (string) - Required - The name of the MCP server. - **url** (string) - Optional - The URL of the MCP server. - **description** (string) - Optional - A description of the server. - **activate** (boolean) - Optional - Whether to activate the server upon creation. - **type** (string) - Optional - The type of server (e.g., "stdio"). - **command** (string) - Optional - The command to run the server. - **args** (array of strings) - Optional - Arguments for the command. - **env** (object) - Optional - Environment variables for the server process. ### Request Example ```bash curl -X POST http://localhost:5005/api/mcp_server \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "GitHub Integration", "url": "https://mcp.github.com", "description": "GitHub repository operations", "activate": true, "type": "stdio", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": {"GITHUB_TOKEN": "ghp_..."} }' ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the created MCP server. - **message** (string) - Confirmation message. #### Response Example ```json { "id": 1, "message": "MCP server created successfully" } ``` ## GET /api/mcp_server ### Description Retrieves a list of all configured MCP servers. ### Method GET ### Endpoint /api/mcp_server ### Parameters None ### Request Example ```bash curl -X GET http://localhost:5005/api/mcp_server \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **servers** (array of objects) - A list of MCP server configurations. #### Response Example ```json [ { "id": 1, "name": "GitHub Integration", "url": "https://mcp.github.com" } ] ``` ## GET /api/mcp_server/active ### Description Retrieves a list of only the active MCP servers. ### Method GET ### Endpoint /api/mcp_server/active ### Parameters None ### Request Example ```bash curl -X GET http://localhost:5005/api/mcp_server/active \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **servers** (array of objects) - A list of active MCP server configurations. #### Response Example ```json [ { "id": 1, "name": "GitHub Integration", "url": "https://mcp.github.com" } ] ``` ## PUT /api/mcp_server/{id} ### Description Updates an existing MCP server configuration. ### Method PUT ### Endpoint /api/mcp_server/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the MCP server to update. #### Query Parameters None #### Request Body - **name** (string) - Optional - The new name for the MCP server. - **activate** (boolean) - Optional - Whether to activate or deactivate the server. ### Request Example ```bash curl -X PUT http://localhost:5005/api/mcp_server/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "GitHub Integration v2", "activate": true }' ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of the update. #### Response Example ```json { "message": "MCP server updated successfully" } ``` ## DELETE /api/mcp_server/{id} ### Description Deletes a specific MCP server configuration. ### Method DELETE ### Endpoint /api/mcp_server/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the MCP server to delete. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X DELETE http://localhost:5005/api/mcp_server/1 \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of the deletion. #### Response Example ```json { "message": "MCP server deleted successfully" } ``` ``` -------------------------------- ### Environment Configuration (.env) Source: https://context7.com/hexdocom/lemonai/llms.txt Defines environment variables for configuring Lemon AI. Includes settings for storage path, workspace directory, runtime type, knowledge base enablement, platform API keys, and static file serving. ```dotenv # .env configuration file STORAGE_PATH=data/database.sqlite # SQLite database location WORKSPACE_DIR=workspace # Workspace directory for conversations RUNTIME_TYPE=local-docker # Runtime: local, docker, local-docker ENABLE_KNOWLEDGE=ON # Enable self-learning knowledge base # Platform API configuration (optional) OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... # Static file serving (for docker runtime) STATIC_DOMAIN=static.lemonai.ai STATIC_PROTOCOL=https ```