Enha: /chat /completions tool calls to live in peace

This commit is contained in:
Grail Finder
2025-08-08 13:03:37 +03:00
parent 589dfdda3f
commit d7d432b8a1
5 changed files with 59 additions and 34 deletions

6
llm.go
View File

@@ -142,8 +142,10 @@ func (op OpenAIer) ParseChunk(data []byte) (*models.TextChunk, error) {
return nil, err
}
resp := &models.TextChunk{
Chunk: llmchunk.Choices[len(llmchunk.Choices)-1].Delta.Content,
ToolChunk: llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Arguments,
Chunk: llmchunk.Choices[len(llmchunk.Choices)-1].Delta.Content,
}
if len(llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls) > 0 {
resp.ToolChunk = llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Arguments
}
if llmchunk.Choices[len(llmchunk.Choices)-1].FinishReason == "stop" {
if resp.Chunk != "" {