Files
picoclaw/web/backend/api/ui.go
T
SiYue-ZO 2784223ad5 Make web search auto-switch with UI language
Default the sample web search provider to auto, route Sogou vs DuckDuckGo dynamically based on query/UI language, and sync frontend language changes back to the backend so Current Service and runtime selection stay aligned.
2026-04-15 18:45:28 +08:00

28 lines
624 B
Go

package api
import (
"encoding/json"
"net/http"
"github.com/sipeed/picoclaw/pkg/tools"
)
type uiLanguageRequest struct {
Language string `json:"language"`
}
func (h *Handler) registerUIRoutes(mux *http.ServeMux) {
mux.HandleFunc("POST /api/ui/language", h.handleSetUILanguage)
}
func (h *Handler) handleSetUILanguage(w http.ResponseWriter, r *http.Request) {
var req uiLanguageRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, "invalid request body", http.StatusBadRequest)
return
}
tools.SetPreferredWebSearchLanguage(req.Language)
w.WriteHeader(http.StatusNoContent)
}