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).
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:
- Input prompt
- LLM response
- Search results snippets
- Classification labels
<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>
- Build and start the Machine Learning backend on
http://localhost:9090
:
docker-compose up
- Validate that the backend is running:
$ curl http://localhost:9090/health
{"status":"UP"}
- Create a project in Label Studio. Then from the Model page in the project settings, connect the model. The default URL is
http://localhost:9090
.