diff options
author | Grail Finder <wohilas@gmail.com> | 2025-08-08 13:03:37 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2025-08-08 13:03:37 +0300 |
commit | d7d432b8a1dbea9e18f78d835112fa074051f587 (patch) | |
tree | 517a6e057aaf3fb5fd418690bfff1941d55c45bb /llm.go | |
parent | 589dfdda3fa89ecc984530ce3bfcc58ee2fd851d (diff) |
Enha: /chat /completions tool calls to live in peace
Diffstat (limited to 'llm.go')
-rw-r--r-- | llm.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 != "" { |