LlamaIndex
Prerequisite
To use LlamaIndex and Cohere, you will need:
- LlamaIndex Package. To install it, run
pip install llama-index
. - Cohere’s SDK. To install it, run
pip install cohere
. If you run into any issues or want more details on Cohere’s SDK, see this wiki. - A Cohere API Key. For more details on pricing see this page. When you create an account with Cohere, we automatically create a trial API key for you. This key will be available on the dashboard where you can copy it, and it’s in the dashboard section called “API Keys” as well.
Cohere Chat with LlamaIndex
To use Cohere’s chat functionality with LlamaIndex create a Cohere model object and call the chat
function.
PYTHON
Cohere Embeddings with LlamaIndex
To use Cohere’s embeddings with LlamaIndex create a Cohere Embeddings object with an embedding model from this list and call get_text_embedding
.
PYTHON
Cohere Rerank with LlamaIndex
To use Cohere’s rerank functionality with LlamaIndex create a Cohere Rerank object and use as a node post processor.
PYTHON
Cohere Pipeline with LlamaIndex
The following example uses Cohere’s chat model, embeddings and rerank functionality to generate a response based on your data.
PYTHON