mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-22 03:24:59 +00:00
Allow to template model prompts inputs
This commit is contained in:
parent
48aca246e3
commit
9fb581739b
2 changed files with 59 additions and 8 deletions
12
api.go
12
api.go
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue