fix: 提交内容改为提示词内容拼接用户输入,不再使用system角色
This commit is contained in:
@@ -24,21 +24,20 @@ pub struct ChatCompletionResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn call_llm(settings: &AppSettings, user_input: String, selected_prompt: Option<String>) -> Result<String, String> {
|
pub fn call_llm(settings: &AppSettings, user_input: String, selected_prompt: Option<String>) -> Result<String, String> {
|
||||||
let mut messages = Vec::new();
|
let full_content = if let Some(prompt) = selected_prompt {
|
||||||
|
|
||||||
if let Some(prompt) = selected_prompt {
|
|
||||||
if !prompt.is_empty() {
|
if !prompt.is_empty() {
|
||||||
messages.push(ChatMessage {
|
format!("{}{}", prompt, user_input)
|
||||||
role: "system".to_string(),
|
} else {
|
||||||
content: prompt,
|
user_input
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
user_input
|
||||||
|
};
|
||||||
|
|
||||||
messages.push(ChatMessage {
|
let messages = vec![ChatMessage {
|
||||||
role: "user".to_string(),
|
role: "user".to_string(),
|
||||||
content: user_input,
|
content: full_content,
|
||||||
});
|
}];
|
||||||
|
|
||||||
let request = ChatCompletionRequest {
|
let request = ChatCompletionRequest {
|
||||||
model: settings.llm_config.model.clone(),
|
model: settings.llm_config.model.clone(),
|
||||||
|
|||||||
@@ -114,13 +114,20 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
sendButton.setOnClickListener {
|
sendButton.setOnClickListener {
|
||||||
Log.d("MainActivity", "Send button clicked")
|
Log.d("MainActivity", "Send button clicked")
|
||||||
// Test log
|
|
||||||
Log.e("MainActivity", "TEST ERROR LOG")
|
Log.e("MainActivity", "TEST ERROR LOG")
|
||||||
val inputText = inputEditText.text.toString()
|
val inputText = inputEditText.text.toString()
|
||||||
if (inputText.isNotEmpty()) {
|
if (inputText.isNotEmpty()) {
|
||||||
outputStatusLabel.text = "连接中…"
|
outputStatusLabel.text = "连接中…"
|
||||||
outputTextView.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 {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
try {
|
try {
|
||||||
Log.d("MainActivity", "Starting text processing")
|
Log.d("MainActivity", "Starting text processing")
|
||||||
|
|||||||
Reference in New Issue
Block a user