feat: fetch for the assistant with Поиск on - a page's main text for the model, the server's own network out of reach; shorter words in Настройки and the chat; the + menu's roots a step left. Also files from panes into the chat, docview and drag fixes (by the user)
This commit is contained in:
1 parent
84b42c5369
commit
ae8fffe7d8
17 files changed
+712
-102
No files matched your search
@@ -154,8 +154,8 @@ func TestAIAnthropic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The chat route: only for a user who turned the assistant on.
|
||||
func TestAIChatNeedsUserOn(t *testing.T) {
|
||||
// The chat is on by default, and an explicit user preference can still turn it off.
|
||||
func TestAIChatDefaultOnAndCanBeDisabled(t *testing.T) {
|
||||
s, c := newTestServer(t)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, "data: {\"choices\":[{\"delta\":{\"content\":\"ok\"}}]}\n\ndata: [DONE]\n\n")
|
||||
@@ -170,11 +170,17 @@ func TestAIChatNeedsUserOn(t *testing.T) {
|
||||
s.Handler().ServeHTTP(w, req)
|
||||
return w
|
||||
}
|
||||
if w := post(); w.Code != http.StatusForbidden {
|
||||
t.Fatalf("off: %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
a, _ := s.db.AdminByUsername("adm")
|
||||
_ = s.db.SetConfig(aiUserKey(a.ID), "1")
|
||||
state := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/panel/ai", nil)
|
||||
req.AddCookie(c)
|
||||
s.handleAIState(state, req)
|
||||
var got struct {
|
||||
On bool `json:"on"`
|
||||
}
|
||||
if err := json.Unmarshal(state.Body.Bytes(), &got); err != nil || !got.On {
|
||||
t.Fatalf("default state: %s (%v)", state.Body.String(), err)
|
||||
}
|
||||
w := post()
|
||||
b, _ := io.ReadAll(w.Body)
|
||||
if w.Code != 200 || string(b) != "ok" {
|
||||
@@ -189,6 +195,23 @@ func TestAIChatNeedsUserOn(t *testing.T) {
|
||||
if h := s.aiHistoryOf(a.ID, cs[0].ID, 10); len(h) != 2 || h[0].Content != "hi" || h[1].Content != "ok" {
|
||||
t.Fatalf("history: %+v", h)
|
||||
}
|
||||
off := httptest.NewRecorder()
|
||||
req = httptest.NewRequest(http.MethodPost, "/api/panel/ai/toggle", strings.NewReader(`{"on":false}`))
|
||||
req.AddCookie(c)
|
||||
s.handleAIToggle(off, req)
|
||||
state = httptest.NewRecorder()
|
||||
req = httptest.NewRequest(http.MethodGet, "/api/panel/ai", nil)
|
||||
req.AddCookie(c)
|
||||
s.handleAIState(state, req)
|
||||
var after struct {
|
||||
On bool `json:"on"`
|
||||
}
|
||||
if err := json.Unmarshal(state.Body.Bytes(), &after); err != nil || after.On {
|
||||
t.Fatalf("disabled state: %s (%v)", state.Body.String(), err)
|
||||
}
|
||||
if w := post(); w.Code != http.StatusForbidden {
|
||||
t.Fatalf("explicit off: %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestAIChatKeepsAttachmentTextOnly(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user