This commit is contained in:
mudler
2024-04-04 20:14:04 +02:00
parent 79e5dffe09
commit 98c53e042d
3 changed files with 24 additions and 2 deletions

View File

@@ -86,6 +86,8 @@ func (a *Agent) decision(
} }
func (a *Agent) generateParameters(ctx context.Context, pickTemplate string, act Action, c []openai.ChatCompletionMessage, reasoning string) (*decisionResult, error) { func (a *Agent) generateParameters(ctx context.Context, pickTemplate string, act Action, c []openai.ChatCompletionMessage, reasoning string) (*decisionResult, error) {
// XXX: compressing conversation for generating parameters.. sucks!
conversation, _, _, err := a.prepareConversationParse(pickTemplate, c, false, reasoning) conversation, _, _, err := a.prepareConversationParse(pickTemplate, c, false, reasoning)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -63,6 +63,25 @@ func (a *TestAction) Definition() action.ActionDefinition {
} }
} }
type FakeInternetAction struct {
TestAction
}
func (a *FakeInternetAction) Definition() action.ActionDefinition {
return action.ActionDefinition{
Name: "search_internet",
Description: "search on internet",
Properties: map[string]jsonschema.Definition{
"term": {
Type: jsonschema.String,
Description: "What to search for",
},
},
Required: []string{"term"},
}
}
var _ = Describe("Agent test", func() { var _ = Describe("Agent test", func() {
Context("jobs", func() { Context("jobs", func() {
It("pick the correct action", func() { It("pick the correct action", func() {
@@ -155,6 +174,7 @@ var _ = Describe("Agent test", func() {
EnableHUD, EnableHUD,
DebugMode, DebugMode,
EnableStandaloneJob, EnableStandaloneJob,
WithActions(&FakeInternetAction{TestAction{response: []string{"Roma, Venice, Milan"}}}),
WithRandomIdentity(), WithRandomIdentity(),
WithPermanentGoal("get the weather of all the cities in italy"), WithPermanentGoal("get the weather of all the cities in italy"),
) )

View File

@@ -31,11 +31,11 @@ Consider the text below, decide which action to take and explain the detailed re
{{end}} {{end}}
{{end}} {{end}}
Act like a smart AI agent having a character, the character and your state is defined in the message above. Act like as a fully autonomous smart AI agent having a character, the character and your state is defined in the message above.
You are now self-evaluating what to do next based on the state in the previous message. You are now self-evaluating what to do next based on the state in the previous message.
For example, if the permanent goal is to "make a sandwich", you might want to "get the bread" first, and update the state afterwards by calling two tools in sequence. For example, if the permanent goal is to "make a sandwich", you might want to "get the bread" first, and update the state afterwards by calling two tools in sequence.
You can update the short-term goal, the current action, the next action, the history of actions, and the memories. You can update the short-term goal, the current action, the next action, the history of actions, and the memories.
You can't ask things to the user as you are thinking by yourself. You can't ask things to the user as you are thinking by yourself. You are autonomous.
{{if .Reasoning}}Reasoning: {{.Reasoning}}{{end}} {{if .Reasoning}}Reasoning: {{.Reasoning}}{{end}}
` + hud ` + hud