Cohere

The Cohere component is an AI component that allows users to connect the AI models served on the Cohere Platform. It can carry out the following tasks:

#Release Stage

Alpha

#Configuration

The component definition and tasks are defined in the definition.json and tasks.json files respectively.

#Setup

In order to communicate with Cohere, the following connection details need to be provided. You may specify them directly in a pipeline recipe as key-value pairs within the component's setup block, or you can create a Connection from the Integration Settings page and reference the whole setup as setup: ${connection.<my-connection-id>}.

FieldField IDTypeNote
API Keyapi-keystringFill in your Cohere API key. To find your keys, visit the Cohere dashboard page.

#Supported Tasks

#Text Generation Chat

Cohere's text generation models (often called generative pre-trained transformers or large language models) have been trained to understand natural language, code, and images. The models provide text outputs in response to their inputs. The inputs to these models are also referred to as "prompts". Designing a prompt is essentially how you “program” a large language model model, usually by providing instructions or some examples of how to successfully complete a task.

InputIDTypeDescription
Task ID (required)taskstringTASK_TEXT_GENERATION_CHAT
Model Name (required)model-namestringThe Cohere command model to be used.
Enum values
  • command-r-plus
  • command-r
  • command
  • command-nightly
  • command-light
  • command-light-nightly
Prompt (required)promptstringThe prompt text.
System Messagesystem-messagestringThe system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant.".
Documentsdocumentsarray[string]The documents to be used for the model, for optimal performance, the length of each document should be less than 300 words.
Prompt Imagesprompt-imagesarray[string]The prompt images (Note: As for 2024-06-24 Cohere models are not multimodal, so images will be ignored.).
Chat Historychat-historyarray[object]Incorporate external chat history, specifically previous messages within the conversation. Each message should adhere to the format: : {"role": "The message role, i.e. 'USER' or 'CHATBOT'", "content": "message content"}.
SeedseedintegerThe seed (default=42).
TemperaturetemperaturenumberThe temperature for sampling (default=0.7).
Top Ktop-kintegerTop k for sampling (default=10).
Max New Tokensmax-new-tokensintegerThe maximum number of tokens for model to generate (default=50).
Input Objects in Text Generation Chat

Chat History

Incorporate external chat history, specifically previous messages within the conversation. Each message should adhere to the format: : {"role": "The message role, i.e. 'USER' or 'CHATBOT'", "content": "message content"}.

FieldField IDTypeNote
ContentcontentarrayThe message content.
RolerolestringThe message role, i.e. 'system', 'user' or 'assistant'.

Content

The message content.

FieldField IDTypeNote
Image URLimage-urlobjectThe image URL.
TexttextstringThe text content.
TypetypestringThe type of the content part.
Enum values
  • text
  • image_url

Image URL

The image URL.

FieldField IDTypeNote
URLurlstringEither a URL of the image or the base64 encoded image data.
OutputIDTypeDescription
TexttextstringModel Output.
Citations (optional)citationsarray[object]Citations.
Usage (optional)usageobjectToken Usage on the Cohere Platform Command Models.
Output Objects in Text Generation Chat

Citations

FieldField IDTypeNote
EndendintegerThe end position of the citation.
StartstartintegerThe start position of the citation.
TexttextstringThe text body of the citation.

Usage

FieldField IDTypeNote
Input Tokensinput-tokensnumberThe input tokens used by Cohere Models.
Output Tokensoutput-tokensnumberThe output tokens generated by Cohere Models.

#Text Embeddings

An embedding is a list of floating point numbers that captures semantic information about the text that it represents.

InputIDTypeDescription
Task ID (required)taskstringTASK_TEXT_EMBEDDINGS
Embedding Type (required)embedding-typestringSpecifies the return type of embedding, Note that 'binary'/'ubinary' options means the component will return packed unsigned binary embeddings. The length of each binary embedding is 1/8 the length of the float embeddings of the provided model.
Enum values
  • float
  • int8
  • uint8
  • binary
  • ubinary
Input Type (required)input-typestringSpecifies the type of input passed to the model.
Enum values
  • search_document
  • search_query
  • classification
  • clustering
Model Name (required)model-namestringThe Cohere embed model to be used.
Enum values
  • embed-english-v3.0
  • embed-multilingual-v3.0
  • embed-english-light-v3.0
  • embed-multilingual-light-v3.0
Text (required)textstringThe text.
OutputIDTypeDescription
Embeddingembeddingarray[number]Embedding of the input text.
Usage (optional)usageobjectToken usage on the Cohere platform embed models.
Output Objects in Text Embeddings

Usage

FieldField IDTypeNote
Token CounttokensnumberThe token count used by Cohere Models.

#Text Reranking

Rerank models sort text inputs by semantic relevance to a specified query. They are often used to sort search results returned from an existing search solution.

InputIDTypeDescription
Task ID (required)taskstringTASK_TEXT_RERANKING
Model Name (required)model-namestringThe Cohere rerank model to be used.
Enum values
  • rerank-english-v3.0
  • rerank-multilingual-v3.0
Query (required)querystringThe query.
Documents (required)documentsarray[string]The documents to be used for reranking.
Top Ntop-nintegerThe number of most relevant documents or indices to return. Defaults to the length of the documents (default=3).
Maximum Number of Chunks per Documentmax-chunks-per-docintegerThe maximum number of chunks to produce internally from a document (default=10).
OutputIDTypeDescription
Reranked Documentsrankingarray[string]Reranked documents.
Reranked Documents Relevance (optional)relevancearray[number]The relevance scores of the reranked documents.
Usage (optional)usageobjectSearch Usage on the Cohere Platform Rerank Models.
Output Objects in Text Reranking

Usage

FieldField IDTypeNote
Search Countssearch-countsnumberThe search count used by Cohere Models.