fix: 提交内容改为提示词内容拼接用户输入,不再使用system角色

This commit is contained in:
xiaji
2026-04-05 20:27:05 +08:00
parent 1f44325d7f
commit 571c501300
2 changed files with 18 additions and 12 deletions

View File

@@ -24,21 +24,20 @@ pub struct ChatCompletionResponse {
}
pub fn call_llm(settings: &AppSettings, user_input: String, selected_prompt: Option<String>) -> Result<String, String> {
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(),

View File

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