Session manager (#4648)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -3,11 +3,12 @@ use rmcp::model::Role;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
use thiserror::Error;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
pub mod message;
|
||||
mod tool_result_serde;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq)]
|
||||
pub struct Conversation(Vec<Message>);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
@@ -122,6 +123,23 @@ impl Default for Conversation {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoIterator for Conversation {
|
||||
type Item = Message;
|
||||
type IntoIter = std::vec::IntoIter<Message>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.into_iter()
|
||||
}
|
||||
}
|
||||
impl<'a> IntoIterator for &'a Conversation {
|
||||
type Item = &'a Message;
|
||||
type IntoIter = std::slice::Iter<'a, Message>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
/// Fix a conversation that we're about to send to an LLM. So the last and first
|
||||
/// messages should always be from the user.
|
||||
pub fn fix_conversation(conversation: Conversation) -> (Conversation, Vec<String>) {
|
||||
|
||||
Reference in New Issue
Block a user