mirror of
https://github.com/mudler/LocalAI.git
synced 2025-01-19 19:27:31 +00:00
e1db6dce82
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
27 lines
525 B
Go
27 lines
525 B
Go
package templates
|
|
|
|
import (
|
|
"bytes"
|
|
"text/template"
|
|
|
|
"github.com/Masterminds/sprig/v3"
|
|
)
|
|
|
|
func TemplateMultiModal(templateString string, templateID int, text string) (string, error) {
|
|
// compile the template
|
|
tmpl, err := template.New("template").Funcs(sprig.FuncMap()).Parse(templateString)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
result := bytes.NewBuffer(nil)
|
|
// execute the template
|
|
err = tmpl.Execute(result, struct {
|
|
ID int
|
|
Text string
|
|
}{
|
|
ID: templateID,
|
|
Text: text,
|
|
})
|
|
return result.String(), err
|
|
}
|