mirror of
https://github.com/likelovewant/ollama-for-amd.git
synced 2025-12-21 22:33:56 +00:00
routes: add logprobs in tool calls (#13238)
This commit is contained in:
@@ -2195,7 +2195,7 @@ func (s *Server) ChatHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if res.Message.Content != "" || res.Message.Thinking != "" || len(res.Message.ToolCalls) > 0 || r.Done {
|
||||
if res.Message.Content != "" || res.Message.Thinking != "" || len(res.Message.ToolCalls) > 0 || r.Done || len(res.Logprobs) > 0 {
|
||||
slog.Log(context.TODO(), logutil.LevelTrace, "builtin parser output", "parser", m.Config.Parser, "content", content, "thinking", thinking, "toolCalls", toolCalls, "done", r.Done)
|
||||
ch <- res
|
||||
} else {
|
||||
@@ -2235,8 +2235,16 @@ func (s *Server) ChatHandler(c *gin.Context) {
|
||||
res.Message.ToolCalls = toolCalls
|
||||
res.Message.Content = ""
|
||||
} else if res.Message.Thinking != "" {
|
||||
// don't return
|
||||
// don't return, fall through to send
|
||||
} else {
|
||||
// Send logprobs while content is being buffered by the parser for tool calls
|
||||
if len(res.Logprobs) > 0 && !r.Done {
|
||||
logprobRes := res
|
||||
logprobRes.Message.Content = ""
|
||||
logprobRes.Message.ToolCalls = nil
|
||||
ch <- logprobRes
|
||||
}
|
||||
|
||||
if r.Done {
|
||||
res.Message.Content = toolParser.Content()
|
||||
ch <- res
|
||||
|
||||
Reference in New Issue
Block a user