Cohere LLM Integration
Before You Get Started
To use the You.com Search API, you will need an API key. Please visit api.you.com for more details.
Enriching Cohere’s LLM with the You.com Search API
Follow these steps to query You.com’s Search API and enrich LLM responses with our snippets.
You will need to have the environment variables AUTH_KEY
and COHERE_API_KEY
set to follow along with this guide.
This example uses the requests
library, you can alternatively look at using our LangChain retriever.
1. Install
2. Create the Cohere Client
3. Create a function to call You.com’s Search API
This function will be used to augment Cohere’s LLM generations.
4. Calling Cohere’s API to generate LLM responses
Here, we’ll define two functions. get_cohere_prompt
takes a query and context (provided by You.com’s Search API) to create an enriched prompt.
ask_cohere
uses the prompt to call the Cohere API.
5. Putting it all together
Now that we are able to call You.com’s Search API and Cohere’s LLM, we want to pass the Search API’s rich snippets into the prompt.
Now, you’ll be able to leverage You.com’s powerful Search API to enrich your LLM responses!