Browse Source

template extra args

Michael Yang 1 year ago
parent
commit
cdc9aa14ed
2 changed files with 8 additions and 5 deletions
  1. 6 5
      api/types.go
  2. 2 0
      server/images.go

+ 6 - 5
api/types.go

@@ -32,11 +32,12 @@ func (e StatusError) Error() string {
 }
 
 type GenerateRequest struct {
-	Model    string `json:"model"`
-	Prompt   string `json:"prompt"`
-	System   string `json:"system"`
-	Template string `json:"template"`
-	Context  []int  `json:"context,omitempty"`
+	Model    string         `json:"model"`
+	Prompt   string         `json:"prompt"`
+	System   string         `json:"system"`
+	Template string         `json:"template"`
+	Context  []int          `json:"context,omitempty"`
+	Args     map[string]any `json:"args,omitempty"`
 
 	Options map[string]interface{} `json:"options"`
 }

+ 2 - 0
server/images.go

@@ -66,6 +66,7 @@ func (m *Model) Prompt(request api.GenerateRequest, embedding string) (string, e
 		System string
 		Prompt string
 		Embed  string
+		Args   map[string]any
 
 		// deprecated: versions <= 0.0.7 used this to omit the system prompt
 		Context []int
@@ -75,6 +76,7 @@ func (m *Model) Prompt(request api.GenerateRequest, embedding string) (string, e
 	vars.System = m.System
 	vars.Prompt = request.Prompt
 	vars.Context = request.Context
+	vars.Args = request.Args
 	vars.Embed = embedding
 
 	if request.System != "" {