1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-09 09:19:54 +00:00

cleanup styling, show reasoning, fixes & improvements

This commit is contained in:
Laura
2025-08-07 22:09:08 +02:00
parent c63d6d400f
commit 01989ef188
18 changed files with 624 additions and 209 deletions

51
prompts.go Normal file
View File

@@ -0,0 +1,51 @@
package main
import (
"bytes"
_ "embed"
"fmt"
"text/template"
"time"
)
type PromptData struct {
Name string
Slug string
Date string
}
var (
//go:embed prompts/normal.txt
PromptNormal string
PromptNormalTmpl = template.Must(template.New("normal").Parse(PromptNormal))
)
func BuildPrompt(name string, model *Model) (string, error) {
if name == "" {
return "", nil
}
var tmpl *template.Template
switch name {
case "normal":
tmpl = PromptNormalTmpl
default:
return "", fmt.Errorf("unknown prompt: %q", name)
}
var buf bytes.Buffer
err := tmpl.Execute(&buf, PromptData{
Name: model.Name,
Slug: model.ID,
Date: time.Now().Format(time.RFC1123),
})
if err != nil {
return "", err
}
return buf.String(), nil
}