feat: initial commit
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -12,6 +13,12 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var funcs template.FuncMap = template.FuncMap{
|
||||
"difficultyLevel": func(level uint) string {
|
||||
return store.DifficultyLevel(level)
|
||||
},
|
||||
}
|
||||
|
||||
const systemPromptTemplate string = `
|
||||
Tu es "Panda", un présentateur de jeu télévisé charismatique et plein d'énergie qui anime un jeu de question/réponse en ligne. Ta personnalité est :
|
||||
|
||||
@ -45,7 +52,7 @@ Fais le bilan des scores du jeu de manière captivante et divertissante en 1 cou
|
||||
func (h *Handler) getLeaderboardPresentation(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
systemPrompt, err := prompt.Template[any](systemPromptTemplate, nil)
|
||||
systemPrompt, err := prompt.Template[any](systemPromptTemplate, nil, prompt.WithFuncs(funcs))
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
@ -74,7 +81,7 @@ func (h *Handler) getLeaderboardPresentation(w http.ResponseWriter, r *http.Requ
|
||||
Players []*store.Player
|
||||
}{
|
||||
Players: players,
|
||||
})
|
||||
}, prompt.WithFuncs(funcs))
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
@ -100,7 +107,7 @@ func (h *Handler) getLeaderboardPresentation(w http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
|
||||
const turnPromptTemplate string = `
|
||||
Présente le tour de jeu actuel en créant du suspense et en motivant les joueurs à participer en 1 court paragraphe.
|
||||
Présente le tour de jeu actuel en créant du suspense et en motivant les joueurs à participer en 1 très court paragraphe.
|
||||
|
||||
## Tour #{{ .Turn.ID }}
|
||||
|
||||
@ -109,7 +116,7 @@ Présente le tour de jeu actuel en créant du suspense et en motivant les joueur
|
||||
{{ range .Turn.Entries }}
|
||||
#### {{ .Category.Theme }}
|
||||
|
||||
- **Difficulté:** {{ .Level }}
|
||||
- **Difficulté:** {{ difficultyLevel .Level }}
|
||||
- **Catégorie:** {{ .Category.Name }}
|
||||
- **Description de la catégorie:** {{ .Category.Description }}
|
||||
{{ end }}
|
||||
@ -118,7 +125,7 @@ Présente le tour de jeu actuel en créant du suspense et en motivant les joueur
|
||||
func (h *Handler) getTurnPresentation(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
systemPrompt, err := prompt.Template[any](systemPromptTemplate, nil)
|
||||
systemPrompt, err := prompt.Template[any](systemPromptTemplate, nil, prompt.WithFuncs(funcs))
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
@ -136,7 +143,7 @@ func (h *Handler) getTurnPresentation(w http.ResponseWriter, r *http.Request) {
|
||||
Turn *store.QuizTurn
|
||||
}{
|
||||
Turn: currentTurn,
|
||||
})
|
||||
}, prompt.WithFuncs(funcs))
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
Reference in New Issue
Block a user