Browse Source

Allow no knowledge

HEAD
Yang Luo 2 years ago
parent
commit
c65baeba0b
2 changed files with 5 additions and 1 deletions
  1. +1
    -1
      controllers/message.go
  2. +4
    -0
      object/message_ai.go

+ 1
- 1
controllers/message.go View File

@@ -173,7 +173,7 @@ func (c *ApiController) GetMessageAnswer() {
var stringBuilder strings.Builder var stringBuilder strings.Builder


nearestText, err := object.GetNearestVectorText(authToken, chat.Owner, question) nearestText, err := object.GetNearestVectorText(authToken, chat.Owner, question)
if err != nil {
if err != nil && err.Error() != "no knowledge vectors found" {
c.ResponseErrorStream(err.Error()) c.ResponseErrorStream(err.Error())
return return
} }


+ 4
- 0
object/message_ai.go View File

@@ -17,6 +17,10 @@ package object
import "fmt" import "fmt"


func GetRefinedQuestion(knowledge string, question string) string { func GetRefinedQuestion(knowledge string, question string) string {
if knowledge == "" {
return question
}

return fmt.Sprintf(`paragraph: %s return fmt.Sprintf(`paragraph: %s


You are a reading comprehension expert. Please answer the following questions based on the provided content. The content may be in a different language from the questions, so you need to understand the content according to the language of the questions and ensure that your answers are translated into the same language as the questions: You are a reading comprehension expert. Please answer the following questions based on the provided content. The content may be in a different language from the questions, so you need to understand the content according to the language of the questions and ensure that your answers are translated into the same language as the questions:


Loading…
Cancel
Save