improve templating

This commit is contained in:
mudler
2024-04-01 18:08:29 +02:00
parent 56ceedb4fb
commit fdb0585dcb
2 changed files with 11 additions and 23 deletions

View File

@@ -88,38 +88,26 @@ func (a *Agent) generateParameters(ctx context.Context, action Action, conversat
const pickActionTemplate = `You can take any of the following tools:
{{range .Actions -}}
{{.Name}}: {{.Description }}
- {{.Name}}: {{.Description }}
{{ end }}
To answer back to the user, use the "answer" tool.
To answer back to the user, use the "reply" tool.
Given the text below, decide which action to take and explain the detailed reasoning behind it. For answering without picking a choice, reply with 'none'.
{{range .Messages }}
{{if eq .Role "tool"}}Tool result{{else}}{{.Role}}{{ end }}: {{.Content}}
{{if .FunctionCall}}
Tool called with: {{.FunctionCall}}
{{end}}
{{range .ToolCalls}}
{{.Name}}: {{.Arguments}}
{{end}}
{{range .Messages -}}
{{.Role}}{{if .FunctionCall}}(tool_call){{.FunctionCall}}{{end}}: {{if .FunctionCall}}{{.FunctionCall}}{{else if .ToolCalls -}}{{range .ToolCalls -}}{{.Name}} called with {{.Arguments}}{{end}}{{ else }}{{.Content -}}{{end}}
{{end}}
`
const reEvalTemplate = `You can take any of the following tools:
{{range .Actions}}{{.Name}}: {{.Description}}{{end}}
To answer back to the user, use the "answer" tool.
For answering without picking a choice, reply with 'none'.
Given the text below, decide which action to take and explain the reasoning behind it.
{{range .Actions -}}
- {{.Name}}: {{.Description }}
{{ end }}
To answer back to the user, use the "reply" tool.
Given the text below, decide which action to take and explain the detailed reasoning behind it. For answering without picking a choice, reply with 'none'.
{{range .Messages -}}
{{if eq .Role "tool" }}Tool result{{else}}{{.Role}}: {{ end }}{{.Content }}
{{if .FunctionCall}}Tool called with: {{.FunctionCall}}{{end}}
{{range .ToolCalls}}
{{.Name}}: {{.Arguments}}
{{end}}
{{.Role}}{{if .FunctionCall}}(tool_call){{.FunctionCall}}{{end}}: {{if .FunctionCall}}{{.FunctionCall}}{{else if .ToolCalls -}}{{range .ToolCalls -}}{{.Name}} called with {{.Arguments}}{{end}}{{ else }}{{.Content -}}{{end}}
{{end}}
We already have called tools. Evaluate the current situation and decide if we need to execute other tools or answer back with a result.`

View File

@@ -11,7 +11,7 @@ import (
)
const testActionResult = "In Boston it's 30C today, it's sunny, and humidity is at 98%"
const testActionResult2 = "In milan it's very hot today"
const testActionResult2 = "In milan it's very hot today, it is 45C and the humidity is at 200%"
var _ Action = &TestAction{}