ds_api/conversation/mod.rs
1/*
2ds-api-workspace/ds-api/src/conversation/mod.rs
3
4Conversation module (refactored):
5
6This module now delegates implementations to submodules:
7- `summarizer` contains `Summarizer` and `TokenBasedSummarizer`.
8- `deepseek` contains `DeepseekConversation` and related implementations.
9
10Public re-exports are preserved so the crate-level API remains stable.
11*/
12
13pub mod deepseek;
14pub mod summarizer;
15
16pub use deepseek::DeepseekConversation;
17pub use summarizer::{Summarizer, TokenBasedSummarizer};
18
19use std::future::Future;
20use std::pin::Pin;
21
22use crate::raw::request::message::Message;
23
24/// Conversation trait: async-friendly via boxed futures so implementors can perform network calls.
25///
26/// Implementations live in the `deepseek` submodule.
27pub trait Conversation {
28 /// Get a reference to the conversation history.
29 fn history(&self) -> &Vec<Message>;
30
31 /// Add an arbitrary message to the history (any role).
32 fn add_message(&mut self, message: Message);
33
34 /// Push a user input into history (convenience for typical flows).
35 fn push_user_input(&mut self, text: String);
36
37 /// Optionally trigger summarization immediately.
38 fn maybe_summarize(&mut self);
39
40 /// Send the current history as a single request and return the assistant's content (if any).
41 /// This returns a boxed future so the trait remains object-safe without additional crates.
42 fn send_once<'a>(
43 &'a mut self,
44 ) -> Pin<Box<dyn Future<Output = crate::error::Result<Option<String>>> + Send + 'a>>;
45}
46
47// Note: DeepseekConversation implementation, helper methods and tests are now located in
48// `ds-api-workspace/ds-api/src/conversation/deepseek.rs`.