Cohere
Cohere is a component that lets you generate natural‑language text with the Cohere AI service. It connects to Cohere’s API, sends your prompt, and returns the model’s response. You can use it to create summaries, answer questions, or generate any kind of text you need in your workflow.
How it Works
When you add the Cohere component to a workflow, it first looks for a Cohere API credential that you have set up in Nappai’s credentials section. The component then builds a connection to Cohere’s chat endpoint using the API key you selected.
You provide a prompt (the Input field) and optional settings such as a system message, temperature, or streaming. The component sends this data to Cohere, receives the generated text, and outputs it as a Message. The component also exposes the underlying language model object so you can use it in other parts of your workflow if needed.
Inputs
Mapping Mode
This component has a special mode called Mapping Mode. When you enable this mode using the toggle switch, an additional input called Mapping Data is activated, and each input field offers you three different ways to provide data:
- Fixed: You type the value directly into the field.
- Mapped: You connect the output of another component to use its result as the value.
- Javascript: You write Javascript code to dynamically calculate the value.
This flexibility allows you to create more dynamic and connected workflows.
Input Fields
The following fields are available to configure this component. Each field may be visible in different operations:
- Input: The main text prompt you want the model to process.
- Mapping Mode: Toggle to enable batch processing of multiple records.
- Stream: Enable streaming of the model’s response. Streaming works only in chat mode.
- System Message: A message that sets the behavior or context for the model.
- Temperature: Controls the randomness of the output; higher values produce more varied responses.
Note:
This component requires a Cohere API credential.
- First, configure the Cohere API credential in the Credentials section of Nappai.
- Then, select that credential in the Credential field of this component.
Outputs
- Text: The generated text from Cohere, returned as a Message (method:
text_response
). - Model: The underlying language model object (type:
LanguageModel
, method:build_model
). This can be used by other components that accept a language model.
Usage Example
- Add the Cohere component to your workflow.
- Select the Cohere API credential you created earlier.
- In the Input field, type:
Summarize the following paragraph: "Nappai is an automation and AI assistant system that allows users to automate tasks and processes in their data management systems and applications."
- Set Temperature to
0.5
for a more deterministic summary. - (Optional) Enable Stream if you want to see the text as it is generated.
- Connect the Text output to a Display component to show the summary in your dashboard.
The workflow will send the prompt to Cohere, receive the summary, and display it to the user.
Related Components
- OpenAI – Generate text using OpenAI’s GPT models.
- Gemini – Generate text using Google Gemini models.
- Anthropic – Generate text using Anthropic’s Claude models.
- Prompt – Create and manage prompts that can be fed into any LLM component.
Tips and Best Practices
- Use a system message to set a consistent tone or style for the model.
- Adjust temperature: Lower values (e.g., 0.2) give more focused responses; higher values (e.g., 0.8) produce more creative output.
- Enable Mapping Mode when you need to process a list of prompts in a single run.
- Stream responses for long outputs to improve user experience.
- Keep your API key secure by storing it in Nappai’s credential manager and never hard‑coding it in your workflow.
Security Considerations
- Store the Cohere API key in Nappai’s credential manager; it will never be exposed in the workflow UI.
- The component transmits data over HTTPS to Cohere’s servers, ensuring encryption in transit.
- Review your data privacy policy to ensure that sending prompts to an external service complies with your organization’s regulations.