Make lastSelectedModels var per user

This commit is contained in:
Adrien Bouvais 2024-08-04 22:16:52 +02:00
parent f76ebd7491
commit 1e0d345fa4

View File

@ -17,7 +17,7 @@ type RequestMessage struct {
Content string `json:"content"`
}
var lastSelectedLLMs []LLM
var lastSelectedLLMs = make(map[string][]LLM)
func GeneratePlaceholderHandler(c *fiber.Ctx) error {
// Step 1 I create a User message and send it as output with a placeholder
@ -68,7 +68,7 @@ func GeneratePlaceholderHTML(c *fiber.Ctx, message string, selectedLLMIds []stri
}
selectedLLMs = append(selectedLLMs, selectedLLM)
}
lastSelectedLLMs = selectedLLMs
lastSelectedLLMs[c.Cookies("jade-edgedb-auth-token")] = selectedLLMs
_, position := insertArea(c)
@ -105,7 +105,7 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
// Step 2 generate multiple messages
// And send them one by one using events
insertArea(c)
selectedLLMs := lastSelectedLLMs
selectedLLMs, _ := lastSelectedLLMs[c.Cookies("jade-edgedb-auth-token")]
var user User
err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(context.Background(), `
@ -238,6 +238,8 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
// Wait for all goroutines to finish
wg.Wait()
delete(lastSelectedLLMs, c.Cookies("jade-edgedb-auth-token"))
return c.SendString("")
}