This commit is contained in:
Adrien Bouvais 2024-05-11 15:42:08 +02:00
parent b30bc71da4
commit f08123a2ba
4 changed files with 24 additions and 12 deletions

View File

@ -241,7 +241,7 @@ func generateWelcomeChatHTML() string {
} }
NextMessages = append(NextMessages, nextMsg) NextMessages = append(NextMessages, nextMsg)
botOut, err := botTmpl.Execute(pongo2.Context{"Messages": NextMessages, "ConversationAreaId": 0, "NotClickable": !true}) botOut, err := botTmpl.Execute(pongo2.Context{"Messages": NextMessages, "ConversationAreaId": 0, "NotClickable": true})
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -268,7 +268,7 @@ func generateEnterKeyChatHTML() string {
} }
NextMessages = append(NextMessages, nextMsg) NextMessages = append(NextMessages, nextMsg)
botOut, err := botTmpl.Execute(pongo2.Context{"Messages": NextMessages, "ConversationAreaId": 0, "NotClickable": !true}) botOut, err := botTmpl.Execute(pongo2.Context{"Messages": NextMessages, "ConversationAreaId": 0, "NotClickable": true})
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -1,12 +1,14 @@
package main package main
import ( import (
"context"
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
"github.com/edgedb/edgedb-go" "github.com/edgedb/edgedb-go"
@ -158,6 +160,17 @@ func handleCallback(c *fiber.Ctx) error {
func handleSignOut(c *fiber.Ctx) error { func handleSignOut(c *fiber.Ctx) error {
c.ClearCookie("jade-edgedb-auth-token") c.ClearCookie("jade-edgedb-auth-token")
edgeClient = edgeClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": ""}) edgeClient.Close()
var ctx = context.Background()
client, err := edgedb.CreateClient(ctx, edgedb.Options{})
if err != nil {
fmt.Println("Error in edgedb.CreateClient: in init")
log.Fatal(err)
}
edgeCtx = ctx
edgeClient = client
return c.Redirect("/", fiber.StatusTemporaryRedirect) return c.Redirect("/", fiber.StatusTemporaryRedirect)
} }

View File

@ -81,7 +81,8 @@ func getExistingKeys() (bool, bool, bool) {
); );
`, &openaiExists) `, &openaiExists)
if err != nil { if err != nil {
fmt.Println("Error in edgedb.QuerySingle: in addOpenaiKey: ", err) fmt.Println("Error in edgedb.QuerySingle checking for openai: ", err)
openaiExists = false
} }
err = edgeClient.QuerySingle(edgeCtx, ` err = edgeClient.QuerySingle(edgeCtx, `
@ -91,7 +92,8 @@ func getExistingKeys() (bool, bool, bool) {
); );
`, &anthropicExists) `, &anthropicExists)
if err != nil { if err != nil {
fmt.Println("Error in edgedb.QuerySingle: in addOpenaiKey: ", err) fmt.Println("Error in edgedb.QuerySingle checking for anthropic: ", err)
anthropicExists = false
} }
err = edgeClient.QuerySingle(edgeCtx, ` err = edgeClient.QuerySingle(edgeCtx, `
@ -101,7 +103,8 @@ func getExistingKeys() (bool, bool, bool) {
); );
`, &mistralExists) `, &mistralExists)
if err != nil { if err != nil {
fmt.Println("Error in edgedb.QuerySingle: in addOpenaiKey: ", err) fmt.Println("Error in edgedb.QuerySingle checking for mistral: ", err)
mistralExists = false
} }
return openaiExists, anthropicExists, mistralExists return openaiExists, anthropicExists, mistralExists

View File

@ -30,17 +30,13 @@
</div> </div>
</div> </div>
<div class="is-flex is-justify-content mt-2"> <div class="is-flex is-justify-content mt-2">
<button class="button is-small is-primary message-button is-outlined mr-1"> {% if not NotClickable %}
<span class="icon">
<i class="fa-solid fa-copy"></i>
</span>
</button>
<button class="button is-small is-primary message-button is-outlined mr-5"> <button class="button is-small is-primary message-button is-outlined mr-5">
<span class="icon"> <span class="icon">
<i class="fa-solid fa-copy"></i> <i class="fa-solid fa-copy"></i>
</span> </span>
</button> </button>
{% if not NotClickable %}
{% for message in Messages %} {% for message in Messages %}
<button class="button is-small is-primary message-button is-outlined mr-1" <button class="button is-small is-primary message-button is-outlined mr-1"
hx-get="/messageContent?id={{ message.Id }}" hx-target="#content-{{ ConversationAreaId }}" hx-get="/messageContent?id={{ message.Id }}" hx-target="#content-{{ ConversationAreaId }}"