diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-02-21 16:26:13 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-02-21 16:26:13 +0300 |
| commit | 96ffbd5cf53c448bdfc0d86f1e7e866a358e01bd (patch) | |
| tree | 649e095f45a8f030a2bf209f999731a1b92921a3 /llm.go | |
| parent | 85b11fa9ffd5f72b0b76200d2fa590960273410b (diff) | |
Feat: openrouter reasoning
Diffstat (limited to 'llm.go')
| -rw-r--r-- | llm.go | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -614,12 +614,14 @@ func (or OpenRouterChat) ParseChunk(data []byte) (*models.TextChunk, error) { logger.Error("failed to decode", "error", err, "line", string(data)) return nil, err } + lastChoice := llmchunk.Choices[len(llmchunk.Choices)-1] resp := &models.TextChunk{ - Chunk: llmchunk.Choices[len(llmchunk.Choices)-1].Delta.Content, + Chunk: lastChoice.Delta.Content, + Reasoning: lastChoice.Delta.Reasoning, } // Handle tool calls similar to LCPChat - if len(llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls) > 0 { - toolCall := llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0] + if len(lastChoice.Delta.ToolCalls) > 0 { + toolCall := lastChoice.Delta.ToolCalls[0] resp.ToolChunk = toolCall.Function.Arguments fname := toolCall.Function.Name if fname != "" { @@ -631,7 +633,7 @@ func (or OpenRouterChat) ParseChunk(data []byte) (*models.TextChunk, error) { if resp.ToolChunk != "" { resp.ToolResp = true } - if llmchunk.Choices[len(llmchunk.Choices)-1].FinishReason == "stop" { + if lastChoice.FinishReason == "stop" { if resp.Chunk != "" { logger.Error("text inside of finish llmchunk", "chunk", llmchunk) } @@ -710,7 +712,7 @@ func (or OpenRouterChat) FormMsg(msg, role string, resume bool) (io.Reader, erro } // Clean null/empty messages to prevent API issues bodyCopy.Messages = consolidateAssistantMessages(bodyCopy.Messages) - orBody := models.NewOpenRouterChatReq(*bodyCopy, defaultLCPProps) + orBody := models.NewOpenRouterChatReq(*bodyCopy, defaultLCPProps, cfg.ReasoningEffort) if cfg.ToolUse && !resume && role != cfg.ToolRole { orBody.Tools = baseTools // set tools to use } |
