---
title: RAG with a Langchain search agent
type: guide
tier: all
order: 45
hide_menu: true
hide_frontmatter_title: true
meta_title: RAG with a Langchain search agent
meta_description: Use Langchain, OpenAI, and Google to generate responses based on Google search results.
categories:
- Generative AI
- Retrieval Augmented Generation
- Google
- OpenAI
- Langchain
This example demonstrates how to use Label Studio with a custom Machine Learning backend.
It uses a Langchain-based agent that accepts a text input, searches for Google,
and returns the answer based on the search results (a.k.a Retrieval Augmented Generation).
Before you begin, you must install the Label Studio ML backend.
This tutorial uses the langchain_search_agent example.
To use the Google search engine, you need to have a Google Custom Search Engine (CSE) API key and a search engine ID.
GOOGLE_API_KEY=<your_google_api_key>
GOOGLE_CSE_ID=<your_google_search_engine_id>
For more information, see Programmable Search Engine ID.
To use OpenAI, you need to have an OpenAI API key.
OPENAI_API_KEY=<your_openai_api_key>
For more information, see Where do I find my OpenAI API Key?.
The labeling interface must include:
<View>
<Style>
.lsf-main-content.lsf-requesting .prompt::before { content: ' loading...'; color: #808080; }
</Style>
<Text name="input" value="$text"/>
<View className="prompt">
<TextArea name="prompt" toName="input" maxSubmissions="1" editable="true"/>
</View>
<TextArea name="response" toName="input" maxSubmissions="1" editable="true"/>
<TextArea name="snippets" toName="input"/>
<Choices name="classification" toName="input" choice="single" showInLine="true">
<Choice value="Good"/>
<Choice value="Bad"/>
</Choices>
</View>
http://localhost:9090:docker-compose up
$ curl http://localhost:9090/health
{"status":"UP"}
http://localhost:9090.