Simulate User Turns
Mock user interactions with your multi-turn use cases
Overview
Simulating user turns require:
- A multi-turn dataset of conversational goldens
- A callback function that wraps around your chatbot to the next conversation turn
Each conversational golden must have a scenario before you can simulate user
turns. It is also highly recommended to provide a user description for
higher quality simulations.
How it works
- Pull your multi-turn dataset from Confident AI
- Define a callback that invokes your chatbot to generate the next conversation turn
- Run a simulation for each golden in your dataset
Run Simulations Locally
Define callback
Define a callback that wraps around your chatbot and generates the next conversation turn.
The callback should accept an input, and optionally a list of Turns and the
thread id. It should return the next Turn in the conversation.
Run simulation
Create a simulator with your callback and run simulations for the goldens in your dataset.
The conversational test cases should now contain test cases with simulated conversation turns for each golden in your dataset.
Run Simulations Remotely
Advanced Usage
Early stopping
To stop a simulation naturally before it reaches the maximum number of turns, you can provide the expected_outcome for each golden, which will end the conversation automatically after the expected outcome has been reached.
Python
Typescript
cURL
If expected_outcome is unavalaible, the max_user_simulations parameter in
the simluate method will stop simulation after a certain number of user
turns, which is defaulted to 10.
Extending existing conversations
You can extend existing conversations by providing existing Turns to each golden in your dataset. The simulator will automatically detect and continue simulating from the existing turns.