Skip to content

Commit

Permalink
fix: 正则标记异常处理
Browse files Browse the repository at this point in the history
  • Loading branch information
bincooo committed Jun 23, 2024
1 parent 0784877 commit d869907
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions internal/common/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,16 @@ func XmlFlags(ctx *gin.Context, req *pkg.ChatCompletion) []Matcher {
pos = len(req.Messages)
}

c := regexp.MustCompile(cmp, regexp.Compiled)
c, err := regexp.Compile(cmp, regexp.Compiled)
if err != nil {
logger.Warn("compile failed: "+cmp, err)
continue
}
for idx, message := range req.Messages {
if idx < pos && !message.Is("role", "system") {
replace, err := c.Replace(message.GetString("content"), value, -1, -1)
if err != nil {
logger.Warn("compile failed: "+cmp, err)
replace, e := c.Replace(message.GetString("content"), value, -1, -1)
if e != nil {
logger.Warn("compile failed: "+cmp, e)
continue
}
message["content"] = replace
Expand Down
3 changes: 1 addition & 2 deletions internal/plugin/llm/you/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func mergeMessages(completion pkg.ChatCompletion) (pMessages []you.Message, text
return
}

text = "continue"
text = "Please review the attached prompt"

// 获取最后一条用户消息
if is32 {
Expand Down Expand Up @@ -218,7 +218,6 @@ func mergeMessages(completion pkg.ChatCompletion) (pMessages []you.Message, text
}
pMessages = append(pMessages, newMessage)
pos++
break
}
return
}

0 comments on commit d869907

Please sign in to comment.