use std::sync::Arc;
use crate::core::language_models::BaseChatModel;
pub(crate) const DEFAULT_SUMMARY_PROMPT: &str = "\
Summarize the following conversation concisely, preserving key facts, \
decisions, and context. Write the summary in the same language as the conversation.
Conversation:
{conversation}
Summary:";
#[derive(Debug)]
pub enum Strategy<M: BaseChatModel = crate::language_models::OpenAIChat> {
Truncate,
Summarize {
llm: Arc<M>,
summary_prompt: String,
},
}
impl<M: BaseChatModel> Strategy<M> {
pub fn summarize(llm: M) -> Self {
Strategy::Summarize {
llm: Arc::new(llm),
summary_prompt: DEFAULT_SUMMARY_PROMPT.to_string(),
}
}
pub fn summarize_with_prompt(llm: M, prompt: impl Into<String>) -> Self {
Strategy::Summarize {
llm: Arc::new(llm),
summary_prompt: prompt.into(),
}
}
}