From 9b8a456c7d8ea144d243e6f92b0e2c089e6bb2d3 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 6 Jul 2023 11:33:29 -0700 Subject: [PATCH] embed templates --- server/routes.go | 5 ++++- {templates => server/templates}/alpaca.prompt | 0 {templates => server/templates}/falcon.prompt | 0 {templates => server/templates}/gpt4.prompt | 0 {templates => server/templates}/hermes.prompt | 0 {templates => server/templates}/mpt.prompt | 0 {templates => server/templates}/oasst.prompt | 0 {templates => server/templates}/orca.prompt | 0 {templates => server/templates}/qlora.prompt | 0 {templates => server/templates}/tulu.prompt | 0 {templates => server/templates}/ultralm.prompt | 0 {templates => server/templates}/vicuna.prompt | 0 {templates => server/templates}/wizardcoder.prompt | 0 {templates => server/templates}/wizardlm.prompt | 0 14 files changed, 4 insertions(+), 1 deletion(-) rename {templates => server/templates}/alpaca.prompt (100%) rename {templates => server/templates}/falcon.prompt (100%) rename {templates => server/templates}/gpt4.prompt (100%) rename {templates => server/templates}/hermes.prompt (100%) rename {templates => server/templates}/mpt.prompt (100%) rename {templates => server/templates}/oasst.prompt (100%) rename {templates => server/templates}/orca.prompt (100%) rename {templates => server/templates}/qlora.prompt (100%) rename {templates => server/templates}/tulu.prompt (100%) rename {templates => server/templates}/ultralm.prompt (100%) rename {templates => server/templates}/vicuna.prompt (100%) rename {templates => server/templates}/wizardcoder.prompt (100%) rename {templates => server/templates}/wizardlm.prompt (100%) diff --git a/server/routes.go b/server/routes.go index 16c50029..99c589fd 100644 --- a/server/routes.go +++ b/server/routes.go @@ -1,6 +1,7 @@ package server import ( + "embed" "encoding/json" "fmt" "io" @@ -19,7 +20,9 @@ import ( "github.com/jmorganca/ollama/llama" ) -var templates = template.Must(template.ParseGlob("templates/*.prompt")) +//go:embed templates/* +var templatesFS embed.FS +var templates = template.Must(template.ParseFS(templatesFS, "templates/*.prompt")) func generate(c *gin.Context) { // TODO: these should be request parameters diff --git a/templates/alpaca.prompt b/server/templates/alpaca.prompt similarity index 100% rename from templates/alpaca.prompt rename to server/templates/alpaca.prompt diff --git a/templates/falcon.prompt b/server/templates/falcon.prompt similarity index 100% rename from templates/falcon.prompt rename to server/templates/falcon.prompt diff --git a/templates/gpt4.prompt b/server/templates/gpt4.prompt similarity index 100% rename from templates/gpt4.prompt rename to server/templates/gpt4.prompt diff --git a/templates/hermes.prompt b/server/templates/hermes.prompt similarity index 100% rename from templates/hermes.prompt rename to server/templates/hermes.prompt diff --git a/templates/mpt.prompt b/server/templates/mpt.prompt similarity index 100% rename from templates/mpt.prompt rename to server/templates/mpt.prompt diff --git a/templates/oasst.prompt b/server/templates/oasst.prompt similarity index 100% rename from templates/oasst.prompt rename to server/templates/oasst.prompt diff --git a/templates/orca.prompt b/server/templates/orca.prompt similarity index 100% rename from templates/orca.prompt rename to server/templates/orca.prompt diff --git a/templates/qlora.prompt b/server/templates/qlora.prompt similarity index 100% rename from templates/qlora.prompt rename to server/templates/qlora.prompt diff --git a/templates/tulu.prompt b/server/templates/tulu.prompt similarity index 100% rename from templates/tulu.prompt rename to server/templates/tulu.prompt diff --git a/templates/ultralm.prompt b/server/templates/ultralm.prompt similarity index 100% rename from templates/ultralm.prompt rename to server/templates/ultralm.prompt diff --git a/templates/vicuna.prompt b/server/templates/vicuna.prompt similarity index 100% rename from templates/vicuna.prompt rename to server/templates/vicuna.prompt diff --git a/templates/wizardcoder.prompt b/server/templates/wizardcoder.prompt similarity index 100% rename from templates/wizardcoder.prompt rename to server/templates/wizardcoder.prompt diff --git a/templates/wizardlm.prompt b/server/templates/wizardlm.prompt similarity index 100% rename from templates/wizardlm.prompt rename to server/templates/wizardlm.prompt