diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-11-24 19:08:34 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-11-24 19:08:34 +0300 |
| commit | fc963f86c94f8d96224414e409fda757f3b2d11d (patch) | |
| tree | b770f6e73ead85563d73c2afa4b2e39499c8d6ca /llm.go | |
| parent | adfa6bd78389e01e2b5a6a6d71a718a2c9f10298 (diff) | |
Feat: parse func call from or
Diffstat (limited to 'llm.go')
| -rw-r--r-- | llm.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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) |
