pub struct UserSimulator { /* private fields */ }Expand description
Drives multi-turn evaluation conversations by generating user messages
according to a PersonaProfile.
The simulator uses a configurable LLM to produce messages that reflect the persona’s behavioral traits, pursue the persona’s goals, and respect the persona’s constraints.
§Example
ⓘ
use adk_eval::personas::{UserSimulator, PersonaProfile, PersonaTraits, Verbosity, ExpertiseLevel};
use std::sync::Arc;
let persona = PersonaProfile {
name: "impatient-dev".to_string(),
description: "A senior developer who wants quick answers".to_string(),
traits: PersonaTraits {
communication_style: "direct and terse".to_string(),
verbosity: Verbosity::Terse,
expertise_level: ExpertiseLevel::Expert,
},
goals: vec!["Get a working code example".to_string()],
constraints: vec!["Never ask for basic explanations".to_string()],
};
let simulator = UserSimulator::new(llm, persona);
let message = simulator.generate_message(&[]).await?;Implementations§
Source§impl UserSimulator
impl UserSimulator
Sourcepub fn new(llm: Arc<dyn Llm>, persona: PersonaProfile) -> Self
pub fn new(llm: Arc<dyn Llm>, persona: PersonaProfile) -> Self
Create a new simulator with the given LLM and persona.
Sourcepub fn persona(&self) -> &PersonaProfile
pub fn persona(&self) -> &PersonaProfile
Returns a reference to the persona profile.
Sourcepub async fn generate_message(&self, history: &[Content]) -> Result<Content>
pub async fn generate_message(&self, history: &[Content]) -> Result<Content>
Generate the next user message given conversation history.
Builds a system prompt from the persona definition and sends the conversation history to the configured LLM to produce a message that reflects the persona’s traits, goals, and constraints.
Auto Trait Implementations§
impl !RefUnwindSafe for UserSimulator
impl !UnwindSafe for UserSimulator
impl Forget for UserSimulator
impl Freeze for UserSimulatorwhere
*const ArcInner<dyn Llm> is !null: Freeze,
PhantomData<ArcInner<dyn Llm>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
impl Move for UserSimulator
impl Send for UserSimulator
impl Sync for UserSimulator
impl Unpin for UserSimulator
impl UnsafeUnpin for UserSimulatorwhere
*const ArcInner<dyn Llm> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Llm>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more