Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

app/ui: do not send to prevent errors with cloud provider

Eva Ho2aaf29acb5ca
diff --git a/app/ui/ui.go b/app/ui/ui.go
index fce588953..4cacc3c20 100644
--- a/app/ui/ui.go
+++ b/app/ui/ui.go
@@ -782,6 +782,25 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error {
var thinkValue any
if req.Think != nil {
+ // Validate that the model supports thinking if requested
+ thinkRequested := false
+ switch v := req.Think.(type) {
+ case bool:
+ thinkRequested = v
+ case string:
+ thinkRequested = v != "" && v != "none"
+ }
+
+ if thinkRequested && !think {
+ errorEvent := responses.ErrorEvent{
+ EventName: "error",
+ Error: fmt.Sprintf("Model %q does not support thinking/reasoning", req.Model),
+ Code: "model_capability_error",
+ }
+ json.NewEncoder(w).Encode(errorEvent)
+ flusher.Flush()
+ return nil
+ }
thinkValue = req.Think
} else {
thinkValue = think
@@ -866,6 +885,9 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error {
return err
}
+ // Debug: Log what we're sending
+ s.log().Debug("sending chat request", "model", chatReq.Model, "think", chatReq.Think, "num_messages", len(chatReq.Messages))
+
err = c.Chat(ctx, chatReq, func(res api.ChatResponse) error {
if loading {
// Remove the loading indicator on first token
@@ -1794,13 +1816,14 @@ func (s *Server) buildChatRequest(chat *store.Chat, model string, think any, ava
var thinkValue *api.ThinkValue
if think != nil {
+ // Only set Think if it's actually requesting thinking
if boolValue, ok := think.(bool); ok {
- thinkValue = &api.ThinkValue{
- Value: boolValue,
+ if boolValue {
+ thinkValue = &api.ThinkValue{Value: boolValue}
}
} else if stringValue, ok := think.(string); ok {
- thinkValue = &api.ThinkValue{
- Value: stringValue,
+ if stringValue != "" && stringValue != "none" {
+ thinkValue = &api.ThinkValue{Value: stringValue}
}
}
}