Cohere Toolkit Documentation

repository·main·Indexed 25 days ago

https://github.com/cohere-ai/cohere-toolkit

An all-in-one deployable RAG (Retrieval-Augmented Generation) application for building LLM-based products. It features a customizable backend API supporting multiple model providers (Cohere, Sagemaker, Azure, Bedrock, HuggingFace), a Next.js web interface, and a Command Slack Bot. The toolkit supports local development via Makefile, Docker Compose, and Minikube with Helm.

Tokens
29.8K
Snippets
64
Records
220
Agent score
85%

What's inside Cohere Toolkit

  1. Overview of Cohere Toolkit architecture

    main

    Cohere Toolkit is an all-in-one RAG (Retrieval-Augmented Generation) application consisting of several layers:

    • Interfaces: Client-side UIs. The default is a Next.js web app located at src/interfaces/assistants_web which includes a SQL database for conversation history. Other interfaces include a Slack bot implementation.
    • Backend API: Located in src/backend, this follows a structure similar to the Cohere Chat API but allows for customization of:
      • Model: Choose between providers like Cohere's Platform, Sagemaker, Azure, Bedrock, HuggingFace, or local models.
      • Retrieval: Customize tools and data sources.
    • Deployment: Supports production deployment on AWS, GCP, and Azure.
  2. Deploy Cohere Toolkit using gcloud CLI and cloudbuild.yaml

    main

    To deploy the toolkit, configure the substitutions section in the cloudbuild.yaml file located in the project root and use the gcloud CLI.

    1. Configure cloudbuild.yaml substitutions

    Fill in the following variables:

    • _GCP_PROJECT_ID: Your GCP project ID.
    • _GCP_REGION: The target region (e.g., us-central1).
    • _DATABASE_URL: A connection string in the format postgresql://USERNAME:PASSWORD@HOST:PORT/DB_NAME.
      • Example: postgresql://myuser:mypassword@<your-db-public-ip-address>:5432/toolkit.
    • _COHERE_API_KEY: Your Cohere API key from the Cohere Dashboard.

    2. Execute Deployment

    Run the following commands in your terminal:

    # Authenticate with GCP
    gcloud auth login
    
    # Submit the build to Cloud Build
    gcloud builds submit --region=<YOUR_GCP_REGION>
    gcloud auth login
    
    gcloud builds submit --region=<YOUR_GCP_REGION>
  3. Enable the Gmail Tool in the Frontend

    main

    To make the Gmail tool available in the frontend, modify src/interfaces/assistants_web/src/constants/tools.ts:

    1. Add to available tools: Add TOOL_GMAIL_ID to the AGENT_SETTINGS_TOOLS array.
    2. Enable for Base Agent: By default, the Gmail tool is excluded from the Base Agent. To enable it, remove TOOL_GMAIL_ID from the BASE_AGENT_EXCLUDED_TOOLS list (ensure the list is empty or does not contain the ID).
    export const AGENT_SETTINGS_TOOLS = [
      TOOL_HYBRID_WEB_SEARCH_ID,
      TOOL_PYTHON_INTERPRETER_ID,
      TOOL_WEB_SCRAPE_ID,
      TOOL_GMAIL_ID,
    ];
    
    export const BASE_AGENT_EXCLUDED_TOOLS = [];
  4. Add a custom model provider

    main

    Model providers allow the toolkit to connect to various model services, including Cohere's platform, Azure, AWS (Bedrock/Sagemaker), Hugging Face, or local models. To add a custom provider:

    1. Add a new file at src/backend/model_deployments/{custom_provider}.
    2. Implement the required invoke functions, such as invoke_chat_stream.
    3. Add your model configuration to src/backend/config/deployments.py.
  5. Change the Color Scheme, Font, and Other Styles

    main

    You can customize the visual appearance of the toolkit by either modifying the existing theme or adding a new one.

    Modify Existing Theme

    Update the color scheme values in src/interfaces/coral_web/src/themes/cohereTheme.js.

    Add a New Theme

    1. Create a new theme file in the src/interfaces/coral_web/src/themes directory.
    2. Register the new theme in src/interfaces/coral_web/tailwind.config.js by adding it to the presets array.

    Apply Changes

    After modifying theme files, you must rebuild the frontend to apply the updates.

    // Example: Updating colors in src/interfaces/coral_web/src/themes/cohereTheme.js
    primary: {
      ... 
      600: '#E25D41',
      500: '#AE4359', 
      400: '#FF967E',
      ... 
    }
    
    // Example: Registering a new theme in src/interfaces/coral_web/tailwind.config.js
    module.exports = {
      presets: [require('./src/themes/yourTheme')],
      ... 
    }
  6. Deploy Cohere's Toolkit to AWS using Copilot

    main

    To deploy the toolkit using the provided AWS Copilot deployment script:

    1. Navigate to the root directory of the cloned repository.
    2. Execute the deployment script:
      ./aws_copilot_deploy/aws_deploy.sh
    3. Wait for the process to finish. The script will print the application's URL upon successful deployment.
    ./aws_copilot_deploy/aws_deploy.sh