feat: integrate the output language to the system/user prompt

This commit is contained in:
Eugen Eisler 2024-09-19 22:41:05 +02:00 committed by GitHub
parent 2b79a058de
commit 26fccfe18e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -257,6 +257,9 @@ func (o *Chat) BuildChatSession(raw bool) (ret *db.Session, err error) {
}
systemMessage := strings.TrimSpace(o.Context) + strings.TrimSpace(o.Pattern)
if o.Language != "" {
systemMessage = fmt.Sprintf("%s. Please use the language '%s' for the output.", systemMessage, o.Language)
}
userMessage := strings.TrimSpace(o.Message)
if raw {
@ -274,10 +277,6 @@ func (o *Chat) BuildChatSession(raw bool) (ret *db.Session, err error) {
}
}
if o.Language != "" {
ret.Append(&common.Message{Role: "system", Content: "please use " + o.Language + " language"})
}
if ret.IsEmpty() {
ret = nil
err = fmt.Errorf("no session, pattern or user messages provided")