Browse Source

fix: update query response (#661)

master
Kelvin Chiu GitHub 2 years ago
parent
commit
bb58ebdf70
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 28 deletions
  1. +13
    -26
      controllers/util.go
  2. +2
    -2
      object/message_ai.go

+ 13
- 26
controllers/util.go View File

@@ -146,34 +146,21 @@ func (c *Cleaner) GetCleanedData() string {
}

func cleanString(data string) string {
keywords := []string{
"Answer:",
"answer:",
"A:",
"Question:",
"question:",
"Q:",
"?\n",
"?\n",
"\n?",
"\n?",
"? ",
"\n",
"回答:",
"答案:",
"答:",
"回答:",
"答案:",
"答:",
"?",
"?",
"-",
"——",
data = strings.Replace(data, "?", "", -1)
data = strings.Replace(data, "?", "", -1)

data = strings.Replace(data, "-", "", -1)
data = strings.Replace(data, "——", "", -1)

if strings.Contains(data, ":") {
parts := strings.Split(data, ":")
data = parts[len(parts)-1]
} else if strings.Contains(data, ":") {
parts := strings.Split(data, ":")
data = parts[len(parts)-1]
}

for _, keyword := range keywords {
data = strings.ReplaceAll(data, keyword, "")
}
data = strings.TrimSpace(data)

return data
}

+ 2
- 2
object/message_ai.go View File

@@ -27,7 +27,7 @@ func GetRefinedQuestion(knowledge string, question string) string {

Now, please answer the following question based on the provided information:

Question: %s (Please answer directly, without using phrases like "the answer is" or "the question is")
%s

Important Note: The content may be in a different language from the question, so make sure to understand the context and provide your response in the language of the question.`, knowledge, question)
(Please answer directly in the questioner's language without using phrases like "the answer is" or "the question is."")`, knowledge, question)
}

Loading…
Cancel
Save