diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-11-25 11:40:37 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-11-25 11:40:37 +0300 |
| commit | 01da37b3971a6aa1c3c051c34666672b339ae2b6 (patch) | |
| tree | dd5abf293104b8b3affee9195ec27a186ae9d4c5 /llm.go | |
| parent | fc963f86c94f8d96224414e409fda757f3b2d11d (diff) | |
Fix: openrouter func ctx resp
Diffstat (limited to 'llm.go')
| -rw-r--r-- | llm.go | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -160,11 +160,14 @@ func (op OpenAIer) ParseChunk(data []byte) (*models.TextChunk, error) { 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 - fname := llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Name + toolCall := llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0] + resp.ToolChunk = toolCall.Function.Arguments + fname := toolCall.Function.Name if fname != "" { resp.FuncName = fname } + // Capture the tool call ID if available + resp.ToolID = toolCall.ID } if llmchunk.Choices[len(llmchunk.Choices)-1].FinishReason == "stop" { if resp.Chunk != "" { @@ -471,11 +474,14 @@ func (or OpenRouterChat) ParseChunk(data []byte) (*models.TextChunk, error) { // Handle tool calls similar to OpenAIer if len(llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls) > 0 { - resp.ToolChunk = llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Arguments - fname := llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Name + toolCall := llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0] + resp.ToolChunk = toolCall.Function.Arguments + fname := toolCall.Function.Name if fname != "" { resp.FuncName = fname } + // Capture the tool call ID if available + resp.ToolID = toolCall.ID } if resp.ToolChunk != "" { resp.ToolResp = true |
