This commit is contained in:
Adrien Bouvais 2024-05-22 17:48:43 +02:00
parent 1aa1968747
commit cae9dfa5fc
3 changed files with 8 additions and 11 deletions

11
LLM.go
View File

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"strconv"
"github.com/edgedb/edgedb-go"
"github.com/gofiber/fiber/v2"
@ -53,14 +54,10 @@ func createLLM(c *fiber.Ctx) error {
temperature := c.FormValue("temperature-slider")
systemPrompt := c.FormValue("model-prompt-input")
// Transform the temperature to a float
temperatureparsed, err := json.Marshal(temperature)
if err != nil {
panic(err)
}
temperatureFloat := float32(temperatureparsed[1])
f, _ := strconv.ParseFloat(temperature, 32)
temperatureFloat := float32(f)
err = edgeClient.Execute(edgeCtx, `
err := edgeClient.Execute(edgeCtx, `
INSERT LLM {
name := <str>$0,
context := <str>$1,

View File

@ -51,8 +51,8 @@ func addGoogleMessage(llm LLM, selected bool) edgedb.UUID {
if err != nil {
panic(err)
} else if len(chatCompletion.Choices) == 0 {
fmt.Println("No response from OpenAI")
id := insertBotMessage("No response from OpenAI", selected, llm.ID)
fmt.Println("No response from Google")
id := insertBotMessage("No response from Google", selected, llm.ID)
return id
} else {
Content := chatCompletion.Choices[0].Message.Content

View File

@ -93,14 +93,14 @@
});
document.addEventListener('keydown', function (event) {
if (event.key === 'Shift') {
if (event.key === 'Shift' && document.activeElement.id !== 'chat-input-textarea' && document.getElementById('models-creation').classList.contains('is-hidden')) {
document.body.classList.add('shift-pressed');
}
});
document.addEventListener('keyup', function (event) {
// If Shift is press and id="chat-input-textarea" not focused
if (event.key === 'Shift' && document.activeElement.id !== 'chat-input-textarea') {
if (event.key === 'Shift' && document.activeElement.id !== 'chat-input-textarea' && document.getElementById('models-creation').classList.contains('is-hidden')) {
document.body.classList.remove('shift-pressed');
lastSelectedIndex = null;