Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 84afdb4

Browse files
committed
fix(desktop/chat): remove unused parameter
Signed-off-by: Dorin Geman <[email protected]>
1 parent 01623ea commit 84afdb4

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

commands/run.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ func chatWithMarkdown(cmd *cobra.Command, client *desktop.Client, backend, model
269269

270270
if !useMarkdown {
271271
// Simple case: just stream as plain text
272-
return client.ChatStreaming(backend, model, prompt, apiKey, func(content string) {
272+
return client.Chat(backend, model, prompt, apiKey, func(content string) {
273273
cmd.Print(content)
274-
}, false)
274+
})
275275
}
276276

277277
// For markdown: use streaming buffer to render code blocks as they complete
278278
markdownBuffer := NewStreamingMarkdownBuffer()
279279

280-
err := client.ChatStreaming(backend, model, prompt, apiKey, func(content string) {
280+
err := client.Chat(backend, model, prompt, apiKey, func(content string) {
281281
// Use the streaming markdown buffer to intelligently render content
282282
rendered, err := markdownBuffer.AddContent(content, true)
283283
if err != nil {
@@ -289,8 +289,7 @@ func chatWithMarkdown(cmd *cobra.Command, client *desktop.Client, backend, model
289289
} else if rendered != "" {
290290
cmd.Print(rendered)
291291
}
292-
}, false)
293-
292+
})
294293
if err != nil {
295294
return err
296295
}

desktop/desktop.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func (c *Client) fullModelID(id string) (string, error) {
365365
}
366366

367367
// Chat performs a chat request and streams the response content with selective markdown rendering.
368-
func (c *Client) ChatStreaming(backend, model, prompt, apiKey string, outputFunc func(string), shouldUseMarkdown bool) error {
368+
func (c *Client) Chat(backend, model, prompt, apiKey string, outputFunc func(string)) error {
369369
model = normalizeHuggingFaceModelName(model)
370370
if !strings.Contains(strings.Trim(model, "/"), "/") {
371371
// Do an extra API call to check if the model parameter isn't a model ID.
@@ -452,10 +452,19 @@ func (c *Client) ChatStreaming(backend, model, prompt, apiKey string, outputFunc
452452
outputFunc("\n\n")
453453
}
454454
if printerState != chatPrinterReasoning {
455-
reasoningFmt.Println("Thinking:")
455+
const thinkingHeader = "Thinking:\n"
456+
if reasoningFmt != nil {
457+
outputFunc(reasoningFmt.Sprint(thinkingHeader))
458+
} else {
459+
outputFunc(thinkingHeader)
460+
}
456461
}
457462
printerState = chatPrinterReasoning
458-
reasoningFmt.Print(chunk)
463+
if reasoningFmt != nil {
464+
outputFunc(reasoningFmt.Sprint(chunk))
465+
} else {
466+
outputFunc(chunk)
467+
}
459468
}
460469
if streamResp.Choices[0].Delta.Content != "" {
461470
chunk := streamResp.Choices[0].Delta.Content
@@ -475,15 +484,6 @@ func (c *Client) ChatStreaming(backend, model, prompt, apiKey string, outputFunc
475484
return nil
476485
}
477486

478-
// Chat performs a chat request and returns the response content (backwards compatibility).
479-
func (c *Client) Chat(backend, model, prompt, apiKey string) (string, error) {
480-
var result strings.Builder
481-
err := c.ChatStreaming(backend, model, prompt, apiKey, func(content string) {
482-
result.WriteString(content)
483-
}, false) // Use false to maintain backwards compatibility
484-
return result.String(), err
485-
}
486-
487487
func (c *Client) Remove(models []string, force bool) (string, error) {
488488
modelRemoved := ""
489489
for _, model := range models {

desktop/desktop_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestChatHuggingFaceModel(t *testing.T) {
6363
Body: io.NopCloser(bytes.NewBufferString("data: {\"choices\":[{\"delta\":{\"content\":\"Hello there!\"}}]}\n")),
6464
}, nil)
6565

66-
_, err := client.Chat("", modelName, prompt, "")
66+
err := client.Chat("", modelName, prompt, "", func(s string) {})
6767
assert.NoError(t, err)
6868
}
6969

0 commit comments

Comments
 (0)