mirror of
https://github.com/likelovewant/ollama-for-amd.git
synced 2025-12-21 22:33:56 +00:00
app/ui: do not send to prevent errors with cloud provider
This commit is contained in:
31
app/ui/ui.go
31
app/ui/ui.go
@@ -782,6 +782,25 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error {
|
|||||||
var thinkValue any
|
var thinkValue any
|
||||||
|
|
||||||
if req.Think != nil {
|
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
|
thinkValue = req.Think
|
||||||
} else {
|
} else {
|
||||||
thinkValue = think
|
thinkValue = think
|
||||||
@@ -866,6 +885,9 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error {
|
|||||||
return err
|
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 {
|
err = c.Chat(ctx, chatReq, func(res api.ChatResponse) error {
|
||||||
if loading {
|
if loading {
|
||||||
// Remove the loading indicator on first token
|
// 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
|
var thinkValue *api.ThinkValue
|
||||||
if think != nil {
|
if think != nil {
|
||||||
|
// Only set Think if it's actually requesting thinking
|
||||||
if boolValue, ok := think.(bool); ok {
|
if boolValue, ok := think.(bool); ok {
|
||||||
thinkValue = &api.ThinkValue{
|
if boolValue {
|
||||||
Value: boolValue,
|
thinkValue = &api.ThinkValue{Value: boolValue}
|
||||||
}
|
}
|
||||||
} else if stringValue, ok := think.(string); ok {
|
} else if stringValue, ok := think.(string); ok {
|
||||||
thinkValue = &api.ThinkValue{
|
if stringValue != "" && stringValue != "none" {
|
||||||
Value: stringValue,
|
thinkValue = &api.ThinkValue{Value: stringValue}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user