
Cohere Toolkit is an open-source, production-ready repository for developing generative AI applications. It provides UI components for knowledge assistants, supports models from Cohere Platform, Bedrock, and SageMaker, and connects to enterprise data sources. Install Cohere Toolkit to build and deploy Retrieval Augmented Generation (RAG) applications that are conversational, customizable, and grounded in domain-specific knowledge sources.
This article explains how to install Cohere Toolkit on Ubuntu 24.04.
Before you begin, you need to:
Poetry is a dependency management tool for Python you can use to create a dedicated environment for the Cohere Toolkit. Follow the steps to install Poetry and Python3.11 to use with the Cohere Toolkit on Ubuntu 24.04.
Add the deadsnakes PPA to your APT repository sources.
The deadsnakes PPA provides access to multiple Python versions that may not be available in the default APT repository sources.
Update the APT package index to apply the repository changes.
Install Python 3.11.
Cohere Toolkit requires Python 3.11 to run. If the build process displays warnings about an unsupported Python version, it automatically detects and uses Python 3.11 if it's available.
Install Poetry.
Verify the installed Poetry version.
Your output should be similar to the one below.
Initialize a project and create a new pyproject.toml configuration.
^3.11 when prompted and press Enter after each option to save the project configuration.Your project configuration should be similar to the one below when successful.
Activate a new virtual environment using Python 3.11.
Your output should be similar to the one below:
Cohere Toolkit includes two configuration templates, configuration.template.yaml and secrets.template.yaml you can use to create new configurations. Follow the steps below to clone the Cohere Toolkit GitHub repository and create a new configuration using a template.
Switch to your user's home directory.
Clone the Cohere Toolkit repository using Git.
Switch to the cohere-toolkit directory.
Copy the secrets.template.yaml file and save it as secrets.yaml.
Open the secrets.yaml file using a text editor such as nano.
Add your Cohere API key to the api_key field. Ensure there is a single space after : before the key. Replace hMtMgJGNbtymq-example with your actual key.
Save and close the file.
Copy the configuration.template.yaml file and save it as configuration.yaml.
Cohere Toolkit includes a Makefile to automate the compilation, setup, testing, and environment configurations. Follow the steps below to configure the Cohere Toolkit, including the backend and frontend.
Navigate to the cohere-toolkit directory.
Run the first-run target using make.
The above command may terminate with an error due to psycopg2 (2.9.10) not supporting PEP 517 builds. The issue originates from the build backend and is not related to Poetry. Refer to common issue # 3 for more information.
Your error should be similar to the one below.
Open the pyproject.toml file.
Find the psycopg2 = "^2.9.9" field within the [tool.poetry.dependencies] section and comment it using the # symbol.
The updated section should look like the one below.
Comment the following psycopg2 = "^2.9.9" within the [tool.poetry.group.setup.dependencies] section, and add psycopg2-binary = "^2.9.9" on a new line.
The updated [tool.poetry.group.setup.dependencies] section should look like the one below.
Save and close the file.
Lock the new project dependencies.
Run the first-run target again.
Press Enter when prompted to accept the default public backend API hostname.
Press Enter to select the default dev build target.
Press Enter to disable the Python Interpreter. Enabling it requires additional secrets.
Press Enter to disable Tavily Internet Search. Enabling it requires a TAVILY_API_KEY.
Select Cohere Platform as the deployment platform and press Enter to apply the changes.
Press Enter to review the configuration variables and accept the project settings.
The Cohere Toolkit also integrates with PostgreSQL and Redis databases. Your output should be similar to the one below when successful.
Cohere Toolkit setup completes with the following application endpoints.
http://localhost:4000http://localhost:8000Allow network connections ot the Cohere Toolkit backend port 8000 if you need to remotely access the application.
Run the following command to install UFW if it's unavailable and allow SSH connections.
Reload UFW to apply the firewall configuration changes.
The Cohere Platform model uses two endpoints for API calls.
http://localhost:8000/v1/chathttp://localhost:8000/v1/chat-streamFollow the steps below to make an API call to the Cohere backend.
Send a request to the non-streaming endpoint using a prompt, instruction, or question. For example, run the following command to send a What is Vultr? prompt.
Your output should be similar to the one below:
You have installed Cohere Toolkit on Ubuntu 24.04 and made an API call to the Cohere backend. You can use the toolkit to access Cohere's Command, Embed, and Rerank models and integrate them with third-party frameworks such as LangChain and LlamaIndex to develop applications using Large Language Models (LLMs). For more information and configuration options, visit the Cohere Toolkit documentation.
0 Comments
Be the first to comment and share your perspective with the community.