Orchestrate Multi-Turn Conversations
Config Multi Turn is a multi-step prompt workflow example that demonstrates how to configure and run conversational AI chains with multiple interaction turns.
Why it matters
Automate complex, multi-turn conversational interactions with AI. This asset manages sequential prompts and responses to achieve sophisticated dialogue flows.
Outcomes
What it gets done
Manage multi-turn chatbot interactions
Process and summarize sequential AI outputs
Extract key information from extended dialogues
Automate complex prompt chaining
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/pfoo-config-multi-turn | bash Capabilities
What this chain does
Handles multi-turn conversations within a defined domain.
Condenses long documents or threads into key takeaways.
Pulls structured data fields from unstructured text.
Overview
Config Multi Turn
What it does
Config Multi Turn is a workflow example from the promptfoo library that demonstrates how to set up and execute multi-turn conversational prompt chains. It provides a configuration pattern for testing AI interactions that span multiple dialogue turns rather than single prompts.
How it connects
Use this when you need to test or validate conversational AI behavior across multiple interaction turns, such as chatbots, dialogue systems, or any AI application where context must be maintained across a sequence of prompts and responses.
Source README
config-multi-turn (Multiple Turn Conversation)
You can run this example with:
npx promptfoo@latest init --example config-multi-turn
cd config-multi-turn
Usage
To get started, set your OPENAI_API_KEY environment variable.
Next, have a look at prompt.json and edit promptfooconfig.yaml. The prompt uses a special built-in variable _conversation that has the following signature:
type Completion = {
prompt: string | object;
input: string;
output: string;
};
type Conversation = Completion[];
When looping through _conversation, use completion.prompt in the Nunjucks prompt template to use the previous outputs. For example, completion.prompt[completion.prompt.length - 1].content is the last user message sent in a chat-formatted prompt.
completion.input is the last part of the prompt. In a chat-formatted conversation, it will be equal to completion.prompt[completion.prompt.length - 1].content. In other conversations, it will be equal to completion.prompt[completion.prompt.length - 1].
Use completion.output to get the assistant's response to that message.
Then run:
promptfoo eval
Afterwards, you can view the results by running promptfoo view
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.