summaryrefslogtreecommitdiff
path: root/llm.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-11-25 11:40:37 +0300
committerGrail Finder <wohilas@gmail.com>2025-11-25 11:40:37 +0300
commit01da37b3971a6aa1c3c051c34666672b339ae2b6 (patch)
treedd5abf293104b8b3affee9195ec27a186ae9d4c5 /llm.go
parentfc963f86c94f8d96224414e409fda757f3b2d11d (diff)
Fix: openrouter func ctx resp
Diffstat (limited to 'llm.go')
-rw-r--r--llm.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/llm.go b/llm.go
index 47a1d46..e7245ce 100644
--- a/llm.go
+++ b/llm.go
@@ -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