aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/assistant.rs
diff options
context:
space:
mode:
author苏向夜 <46275354+fu050409@users.noreply.github.com>2026-02-25 02:06:07 +0800
committerGitHub <noreply@github.com>2026-02-25 02:06:07 +0800
commit78ac61904d78d558d092eff08c9f261cbdb187e8 (patch)
tree96f68d1f1554ee3a0532793afaaa52b0c73dcbec /src-tauri/src/core/assistant.rs
parent8ff3af6cb908fd824b512379dd21ed4f595ab6bb (diff)
parent329734b23957b84cde2af459fa61c7385fb5b5f1 (diff)
downloadDropOut-78ac61904d78d558d092eff08c9f261cbdb187e8.tar.gz
DropOut-78ac61904d78d558d092eff08c9f261cbdb187e8.zip
feat(ui): partial react rewrite (#77)
## Summary by Sourcery Export backend data structures to TypeScript for the new React-based UI and update CI to build additional targets. New Features: - Generate TypeScript definitions for core backend structs and enums used by the UI. - Now use our own Azure app(_DropOut_) to finish the authorize process. Enhancements: - Annotate existing Rust models with ts-rs metadata to control exported TypeScript shapes, including tagged enums and opaque JSON fields. Build: - Add ts-rs as a dependency for generating TypeScript bindings from Rust types. CI: - Extend the Semifold CI workflow to run on the dev branch and build additional Linux musl and Windows GNU targets using cross where needed.
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() {