UPDATE: Fix chatbot
All checks were successful
Build and Release / release (push) Successful in 1m25s
All checks were successful
Build and Release / release (push) Successful in 1m25s
This commit is contained in:
@@ -99,15 +99,14 @@ func (u *RagUtils) GenerateResponse(ctx context.Context, prompt string) (string,
|
|||||||
func stripThinking(raw string) string {
|
func stripThinking(raw string) string {
|
||||||
startTag := "<answer>"
|
startTag := "<answer>"
|
||||||
endTag := "</answer>"
|
endTag := "</answer>"
|
||||||
startIdx := strings.Index(raw, startTag)
|
|
||||||
endIdx := strings.LastIndex(raw, endTag)
|
|
||||||
|
|
||||||
if startIdx != -1 && endIdx != -1 && endIdx > startIdx {
|
lastStart := strings.LastIndex(raw, startTag)
|
||||||
return strings.TrimSpace(raw[startIdx+len(startTag) : endIdx])
|
if lastStart != -1 {
|
||||||
}
|
content := raw[lastStart+len(startTag):]
|
||||||
|
if endIdx := strings.Index(content, endTag); endIdx != -1 {
|
||||||
if startIdx != -1 {
|
return strings.TrimSpace(content[:endIdx])
|
||||||
return strings.TrimSpace(raw[startIdx+len(startTag):])
|
}
|
||||||
|
return strings.TrimSpace(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(raw, "* ") {
|
if !strings.Contains(raw, "* ") {
|
||||||
|
|||||||
Reference in New Issue
Block a user