Using the Search API with an LLM
Anthropic 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 Anthropic’s LLM with the You.com Search API and LangChain
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 ANTHROPIC_API_KEY
set to follow along with this guide.
1. Install
pip install anthropic langchain
2. Create a LangChain RetrievalQA chain using YouRetriever and Claude V2
main.py
import os
from langchain.retrievers.you import YouRetriever
from langchain.chains import RetrievalQA
from langchain.chat_models import ChatAnthropic
os.environ["YDC_API_KEY"] = "YOUR YOU.COM API KEY"
os.environ["ANTHROPIC_API_KEY"] = "YOUR ANTHROPIC API KEY"
yr = YouRetriever()
model = "claude-2"
qa = RetrievalQA.from_chain_type(llm=ChatAnthropic(model=model), chain_type="stuff", retriever=yr)
3. Now run the chain
main.py
qa.run("how was the New York City pinball ban lifted?")