add function to remove history from AgentChat

This commit is contained in:
2026-07-22 19:46:43 +02:00
parent 5548dc60cc
commit e1087c2ce5
3 changed files with 15 additions and 5 deletions
+1 -3
View File
@@ -85,9 +85,7 @@ fn start_recording_blocking_with_parameters(
should_stop: Arc<Mutex<bool>>, should_stop: Arc<Mutex<bool>>,
) -> Result<(), RecordingError> { ) -> Result<(), RecordingError> {
let stream = match sample_format { let stream = match sample_format {
SampleFormat::I8 => { SampleFormat::I8 => build_stream::<i8>(mic, device_config, samples.clone(), sample_format)?,
build_stream::<i8>(mic, device_config, samples.clone(), sample_format)?
}
SampleFormat::I16 => { SampleFormat::I16 => {
build_stream::<i16>(mic, device_config, samples.clone(), sample_format)? build_stream::<i16>(mic, device_config, samples.clone(), sample_format)?
} }
+13 -1
View File
@@ -212,7 +212,6 @@ impl AgentChat {
Ok(()) Ok(())
} }
// TODO: ChatMessage only returns last tool usage, which is always empty. instead the tool usages should be collected and returned in total
pub async fn message<C: Future<Output = PermissionAnswer>>( pub async fn message<C: Future<Output = PermissionAnswer>>(
&mut self, &mut self,
user_message: String, user_message: String,
@@ -373,6 +372,19 @@ impl AgentChat {
mcp_server_data.client.call_tool(request_params).await?, mcp_server_data.client.call_tool(request_params).await?,
)) ))
} }
pub fn without_history(self) -> Self {
Self {
ollama_client: self.ollama_client,
model: self.model,
mcp_servers: self.mcp_servers,
message_history: vec![],
}
}
pub fn remove_history(&mut self) {
self.message_history = vec![];
}
} }
#[cfg(test)] #[cfg(test)]