diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main.go b/main.go index 5a5c947..b30e904 100644 --- a/main.go +++ b/main.go @@ -5,12 +5,12 @@ import ( "context" "encoding/json" "fmt" + "html/template" "io/ioutil" "log" "net/http" "os" "strings" - "text/template" "time" "github.com/gin-gonic/gin" @@ -230,6 +230,17 @@ func renderPrompt(tmplStr string, data any) (string, error) { return buf.String(), nil } +var uiTemplate *template.Template + +func loadUITemplate(path string) error { + tmpl, err := template.ParseFiles(path) + if err != nil { + return err + } + uiTemplate = tmpl + return nil +} + func main() { if err := loadConfig("config.yaml"); err != nil { log.Fatalf("Failed to load config.yaml: %v", err) @@ -239,12 +250,18 @@ func main() { log.Fatalf("Failed to load db.yaml: %v", err) } fmt.Printf("Loaded %d reasons from db.yaml\n", len(reasonsDB)) - + if err := loadUITemplate("ui.html"); err != nil { + log.Fatalf("Failed to load ui.html: %v", err) + } llm := &LLMClient{ APIKey: os.Getenv("OPENAI_API_KEY"), BaseURL: os.Getenv("OPENAI_BASE_URL"), // e.g. http://localhost:1234/v1/completions } r := gin.Default() + r.GET("/", func(c *gin.Context) { + c.Status(200) + uiTemplate.Execute(c.Writer, nil) + }) r.POST("/chat", func(c *gin.Context) { var req ChatRequest if err := c.ShouldBindJSON(&req); err != nil { diff --git a/ui.html b/ui.html new file mode 100644 index 0000000..0772032 --- /dev/null +++ b/ui.html @@ -0,0 +1,69 @@ + + + + + Vet Clinic Chat Assistant + + + +
+

Vet Clinic Chat Assistant

+
+ + +
+ + + +