Skip to content

Commit e08d456

Browse files
committed
feat: share history in different sessions & (Start separating the record function)
1 parent 4ba5d7c commit e08d456

File tree

4 files changed

+266
-129
lines changed

4 files changed

+266
-129
lines changed

src/ai/mod.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,46 @@ impl ChatSession {
566566
}
567567
}
568568

569+
pub fn create_from_config(
570+
config: &crate::config::AIConfig,
571+
tools: ToolSet<McpToolAdapter>,
572+
) -> Self {
573+
match config {
574+
crate::config::AIConfig::Stable { llm, .. } => {
575+
let mut session = ChatSession::new(
576+
llm.llm_chat_url.clone(),
577+
llm.api_key.clone().unwrap_or_default(),
578+
llm.model.clone(),
579+
None,
580+
llm.history,
581+
tools,
582+
);
583+
584+
session.system_prompts = llm.sys_prompts.clone();
585+
session.messages = llm.dynamic_prompts.clone();
586+
587+
session
588+
}
589+
crate::config::AIConfig::GeminiAndTTS { gemini, .. }
590+
| crate::config::AIConfig::Gemini { gemini } => {
591+
let mut session = ChatSession::new(
592+
String::new(),
593+
gemini.api_key.clone(),
594+
gemini
595+
.model
596+
.clone()
597+
.unwrap_or("models/gemini-2.0-flash-live-001".to_string()),
598+
None,
599+
20,
600+
tools,
601+
);
602+
603+
session.system_prompts = gemini.sys_prompts.clone();
604+
session
605+
}
606+
}
607+
}
608+
569609
pub fn add_user_message(&mut self, message: String) {
570610
self.messages.push_back(llm::Content {
571611
role: llm::Role::User,

src/services/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod file;
22
pub mod realtime_ws;
33
pub mod ws;
4+
pub mod ws_record;

0 commit comments

Comments
 (0)