aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/assistant.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/core/assistant.rs')
-rw-r--r--src-tauri/src/core/assistant.rs27
1 files changed, 21 insertions, 6 deletions
diff --git a/src-tauri/src/core/assistant.rs b/src-tauri/src/core/assistant.rs
index 9a8f7bf..5663007 100644
--- a/src-tauri/src/core/assistant.rs
+++ b/src-tauri/src/core/assistant.rs
@@ -4,8 +4,11 @@ use serde::{Deserialize, Serialize};
use std::collections::VecDeque;
use std::sync::{Arc, Mutex};
use tauri::{Emitter, Window};
+use ts_rs::TS;
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "assistant.ts")]
pub struct Message {
pub role: String,
pub content: String,
@@ -51,7 +54,9 @@ pub struct OllamaTagsResponse {
}
// Simplified model info for frontend
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "assistant.ts")]
pub struct ModelInfo {
pub id: String,
pub name: String,
@@ -102,7 +107,9 @@ pub struct OpenAIModelsResponse {
}
// Streaming response structures
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "assistant.ts")]
pub struct GenerationStats {
pub total_duration: u64,
pub load_duration: u64,
@@ -112,7 +119,9 @@ pub struct GenerationStats {
pub eval_duration: u64,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "assistant.ts")]
pub struct StreamChunk {
pub content: String,
pub done: bool,
@@ -223,7 +232,10 @@ impl GameAssistant {
// Add language instruction if not auto
if config.response_language != "auto" {
- system_content = format!("{}\n\nIMPORTANT: Respond in {}. Do not include Pinyin or English translations unless explicitly requested.", system_content, config.response_language);
+ system_content = format!(
+ "{}\n\nIMPORTANT: Respond in {}. Do not include Pinyin or English translations unless explicitly requested.",
+ system_content, config.response_language
+ );
}
// Add log context if available
@@ -435,7 +447,10 @@ impl GameAssistant {
let mut system_content = config.system_prompt.clone();
if config.response_language != "auto" {
- system_content = format!("{}\n\nIMPORTANT: Respond in {}. Do not include Pinyin or English translations unless explicitly requested.", system_content, config.response_language);
+ system_content = format!(
+ "{}\n\nIMPORTANT: Respond in {}. Do not include Pinyin or English translations unless explicitly requested.",
+ system_content, config.response_language
+ );
}
if !context.is_empty() {