From 571c501300baabf017668ddbd4dce1ca7c26c9e1 Mon Sep 17 00:00:00 2001 From: xiaji Date: Sun, 5 Apr 2026 20:27:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=90=E4=BA=A4=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=8F=90=E7=A4=BA=E8=AF=8D=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E7=94=A8=E6=88=B7=E8=BE=93=E5=85=A5=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E4=BD=BF=E7=94=A8system=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flomo-ai-desktop/src/api/llm_client.rs | 21 +++++++++---------- .../java/com/example/flomo_ai/MainActivity.kt | 9 +++++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/flomo-ai-desktop/src/api/llm_client.rs b/flomo-ai-desktop/src/api/llm_client.rs index f85d922..31bd603 100644 --- a/flomo-ai-desktop/src/api/llm_client.rs +++ b/flomo-ai-desktop/src/api/llm_client.rs @@ -24,21 +24,20 @@ pub struct ChatCompletionResponse { } pub fn call_llm(settings: &AppSettings, user_input: String, selected_prompt: Option) -> Result { - let mut messages = Vec::new(); - - if let Some(prompt) = selected_prompt { + let full_content = if let Some(prompt) = selected_prompt { if !prompt.is_empty() { - messages.push(ChatMessage { - role: "system".to_string(), - content: prompt, - }); + format!("{}{}", prompt, user_input) + } else { + user_input } - } + } else { + user_input + }; - messages.push(ChatMessage { + let messages = vec![ChatMessage { role: "user".to_string(), - content: user_input, - }); + content: full_content, + }]; let request = ChatCompletionRequest { model: settings.llm_config.model.clone(), diff --git a/flomo-ai/app/src/main/java/com/example/flomo_ai/MainActivity.kt b/flomo-ai/app/src/main/java/com/example/flomo_ai/MainActivity.kt index cd0b714..44a1d6f 100644 --- a/flomo-ai/app/src/main/java/com/example/flomo_ai/MainActivity.kt +++ b/flomo-ai/app/src/main/java/com/example/flomo_ai/MainActivity.kt @@ -114,13 +114,20 @@ class MainActivity : AppCompatActivity() { sendButton.setOnClickListener { Log.d("MainActivity", "Send button clicked") - // Test log Log.e("MainActivity", "TEST ERROR LOG") val inputText = inputEditText.text.toString() if (inputText.isNotEmpty()) { outputStatusLabel.text = "连接中…" outputTextView.text = "正在生成..." + val promptContent = promptContentText.text.toString() + val fullContent = if (promptContent.isNotEmpty() && promptContent != "无特殊指令") { + "$promptContent$inputText" + } else { + inputText + } + Log.d("MainActivity", "Full content to send: $fullContent") + CoroutineScope(Dispatchers.Main).launch { try { Log.d("MainActivity", "Starting text processing")