Feat (pull/18994): llama.cpp reasoning
This commit is contained in:
1
bot.go
1
bot.go
@@ -653,7 +653,6 @@ func sendMsgToLLM(body io.Reader) {
|
||||
reasoningText := "<think>" + reasoningBuffer.String() + "</think>"
|
||||
answerText = strings.ReplaceAll(reasoningText, "\n\n", "\n")
|
||||
chunkChan <- answerText
|
||||
reasoningSent = true
|
||||
}
|
||||
if chunk.Chunk != "" {
|
||||
logger.Warn("text inside of finish llmchunk", "chunk", chunk, "counter", counter)
|
||||
|
||||
6
llm.go
6
llm.go
@@ -237,8 +237,10 @@ func (op LCPChat) ParseChunk(data []byte) (*models.TextChunk, error) {
|
||||
return &models.TextChunk{Finished: true}, nil
|
||||
}
|
||||
|
||||
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.ReasoningContent,
|
||||
}
|
||||
|
||||
// Check for tool calls in all choices, not just the last one
|
||||
@@ -256,7 +258,7 @@ func (op LCPChat) ParseChunk(data []byte) (*models.TextChunk, error) {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -64,8 +64,9 @@ type LLMRespChunk struct {
|
||||
FinishReason string `json:"finish_reason"`
|
||||
Index int `json:"index"`
|
||||
Delta struct {
|
||||
Content string `json:"content"`
|
||||
ToolCalls []ToolDeltaResp `json:"tool_calls"`
|
||||
Content string `json:"content"`
|
||||
ReasoningContent string `json:"reasoning_content"`
|
||||
ToolCalls []ToolDeltaResp `json:"tool_calls"`
|
||||
} `json:"delta"`
|
||||
} `json:"choices"`
|
||||
Created int `json:"created"`
|
||||
|
||||
@@ -149,6 +149,11 @@ func makePropsTable(props map[string]float32) *tview.Table {
|
||||
addListPopupRow("Set log level", logLevels, GetLogLevel(), func(option string) {
|
||||
setLogLevel(option)
|
||||
})
|
||||
// Add reasoning effort dropdown (for OpenRouter and supported APIs)
|
||||
reasoningEfforts := []string{"", "none", "minimal", "low", "medium", "high", "xhigh"}
|
||||
addListPopupRow("Reasoning effort (OR)", reasoningEfforts, cfg.ReasoningEffort, func(option string) {
|
||||
cfg.ReasoningEffort = option
|
||||
})
|
||||
// Helper function to get model list for a given API
|
||||
getModelListForAPI := func(api string) []string {
|
||||
if strings.Contains(api, "api.deepseek.com/") {
|
||||
|
||||
Reference in New Issue
Block a user