Allow to template model prompts inputs

This commit is contained in:
mudler 2023-04-08 10:46:51 +02:00
parent 48aca246e3
commit 9fb581739b
2 changed files with 59 additions and 8 deletions

12
api.go
View file

@ -103,10 +103,18 @@ func api(defaultModel *llama.LLama, loader *ModelLoader, listenAddr string, thre
mess = append(mess, i.Content)
}
fmt.Println("Received", input, input.Model)
predInput := strings.Join(mess, "\n")
templatedInput, err := loader.TemplatePrefix(input.Model, struct {
Input string
}{Input: predInput})
if err == nil {
predInput = templatedInput
}
// Generate the prediction using the language model
prediction, err := model.Predict(
strings.Join(mess, "\n"),
templatedInput,
llama.SetTemperature(temperature),
llama.SetTopP(topP),
llama.SetTopK(topK),