Pass Context from Previous LeMUR Requests
This guide will demonstrate how to use AssemblyAI’s LeMUR (Leveraging Large Language Models to Understand Recognized Speech) framework to track previous LeMUR responses and pass them as additional context for future requests to build out ability to ask “follow up” questions.
We recommend using Claude 3 Haiku to reduce costs, as this can use a lot of tokens.
Quickstart
Getting Started
Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for an AssemblyAI account and get your API key from your dashboard.
First, let’s install the AssemblyAI SDK.
Then we’ll import the SDK and set our AssemblyAI API key.
Next, we’ll use AssemblyAI to transcribe a file and save our transcript for later use.
Then we define the initial LeMUR prompt for the Task endpoint and store the first response in a list. These list values will be recalled and added to subsequent LeMUR prompts.
After the intitial prompt, the code will continuously prompt the user for new prompts until they decide to stop. Stop at any time by typing ‘end’. Each response is collected in the results_list
and added as context to the next user prompt. This enables an ability to recall past responses and allow follow up questions.
To see these results with and without the context provided from past responses, here is a comparison table.