From fc963f86c94f8d96224414e409fda757f3b2d11d Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Mon, 24 Nov 2025 19:08:34 +0300 Subject: Feat: parse func call from or --- llm.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llm.go') diff --git a/llm.go b/llm.go index 55051bd..47a1d46 100644 --- a/llm.go +++ b/llm.go @@ -468,6 +468,19 @@ func (or OpenRouterChat) ParseChunk(data []byte) (*models.TextChunk, error) { resp := &models.TextChunk{ Chunk: llmchunk.Choices[len(llmchunk.Choices)-1].Delta.Content, } + + // 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 + if fname != "" { + resp.FuncName = fname + } + } + if resp.ToolChunk != "" { + resp.ToolResp = true + } + if llmchunk.Choices[len(llmchunk.Choices)-1].FinishReason == "stop" { if resp.Chunk != "" { logger.Error("text inside of finish llmchunk", "chunk", llmchunk) -- cgit v1.2.3