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")