Bring Your Own LLM
What is a Custom LLM?
A Custom LLM (Language Model) allows you to tailor the language processing capabilities of your voice bot to better fit specific use cases or requirements.
By integrating a custom LLM, you can control the behavior, responses, and interactions of your voice bot more precisely, ensuring it aligns with your application’s goals.
Make sure you have gone over QuickStart before trying this example.
Integrating a Custom LLM in 4 Steps!
This guide will walk you through creating a custom LLM node and integrating it into a voice bot application using Outspeed.
- The full code is available here.
Install Dependencies
Create CustomLLM Application
To create a custom LLM, let’s set up a file voice_bot.py
.
This CustomLLM
class extends sp.CustomLLMNode to integrate a custom language model.
It initializes with a system prompt and manages the chat history to maintain conversational context.
Next, we’ll integrate this custom LLM into the VoiceBot
application.
Next, we’ll add the run
and teardown
methods to the VoiceBot
class.
By integrating the CustomLLM
, the VoiceBot
now utilizes a tailored language model for generating responses, providing greater control over the conversational behavior.
Setup API Keys and Run
To run this example locally, you’ll need API keys set up in the environment variables for the following services:
- Deepgram - For transcription. Sign up and navigate to https://console.deepgram.com/ to get the API key.
- OpenAI - For the custom LLM. Sign up and navigate to https://platform.openai.com/account/api-keys to get the API key.
- Cartesia - For text-to-speech. Sign up and navigate to https://play.cartesia.ai/keys to get the API key.
All of these providers have a free tier. Once you have your keys, create a .env
file in the same directory as voice_bot.py
and add the following:
Finally, run the following command to start the server:
The console will output the URL you can use to connect to the (default is http://localhost:8080).
Try it Out
You can use our playground to interact with the customized voice bot.
- Navigate to playground and select “Voice Bot”
- Paste the link you received from the previous step into the URL field.
- Select Audio device. Leave Video device blank. Click Run to begin.
The playground is built using our React SDK. You can use it to build your own frontends or integrate with an existing one!
Support
For any assistance or questions, feel free to join our Discord community. We’re excited to see how you enhance your voice bots with custom LLMs!
Was this page helpful?