Skip to content

Commit c23e655

Browse files
authored
feat(agent): shared state, allow to track conversations globally (#148)
* feat(agent): shared state, allow to track conversations globally Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Cleanup Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * track conversations initiated by the bot Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 2b07dd7 commit c23e655

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+290
-316
lines changed

core/action/custom.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (a *CustomAction) Plannable() bool {
8181
return true
8282
}
8383

84-
func (a *CustomAction) Run(ctx context.Context, params types.ActionParams) (types.ActionResult, error) {
84+
func (a *CustomAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
8585
v, err := a.i.Eval(fmt.Sprintf("%s.Run", a.config["name"]))
8686
if err != nil {
8787
return types.ActionResult{}, err

core/action/custom_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ return []string{"foo"}
7676
Description: "A test action",
7777
}))
7878

79-
runResult, err := customAction.Run(context.Background(), types.ActionParams{
79+
runResult, err := customAction.Run(context.Background(), nil, types.ActionParams{
8080
"Foo": "bar",
8181
})
8282
Expect(err).ToNot(HaveOccurred())

core/action/goal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type GoalResponse struct {
2121
Achieved bool `json:"achieved"`
2222
}
2323

24-
func (a *GoalAction) Run(context.Context, types.ActionParams) (types.ActionResult, error) {
24+
func (a *GoalAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
2525
return types.ActionResult{}, nil
2626
}
2727

core/action/intention.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type IntentResponse struct {
2222
Reasoning string `json:"reasoning"`
2323
}
2424

25-
func (a *IntentAction) Run(context.Context, types.ActionParams) (types.ActionResult, error) {
25+
func (a *IntentAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
2626
return types.ActionResult{}, nil
2727
}
2828

core/action/newconversation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type ConversationActionResponse struct {
1919
Message string `json:"message"`
2020
}
2121

22-
func (a *ConversationAction) Run(context.Context, types.ActionParams) (types.ActionResult, error) {
22+
func (a *ConversationAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
2323
return types.ActionResult{}, nil
2424
}
2525

core/action/noreply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func NewStop() *StopAction {
1616

1717
type StopAction struct{}
1818

19-
func (a *StopAction) Run(context.Context, types.ActionParams) (types.ActionResult, error) {
19+
func (a *StopAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
2020
return types.ActionResult{}, nil
2121
}
2222

core/action/plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type PlanSubtask struct {
3030
Reasoning string `json:"reasoning"`
3131
}
3232

33-
func (a *PlanAction) Run(context.Context, types.ActionParams) (types.ActionResult, error) {
33+
func (a *PlanAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
3434
return types.ActionResult{}, nil
3535
}
3636

core/action/reasoning.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type ReasoningResponse struct {
2020
Reasoning string `json:"reasoning"`
2121
}
2222

23-
func (a *ReasoningAction) Run(context.Context, types.ActionParams) (types.ActionResult, error) {
23+
func (a *ReasoningAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
2424
return types.ActionResult{}, nil
2525
}
2626

core/action/reply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ReplyResponse struct {
2222
Message string `json:"message"`
2323
}
2424

25-
func (a *ReplyAction) Run(context.Context, types.ActionParams) (string, error) {
25+
func (a *ReplyAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (string, error) {
2626
return "no-op", nil
2727
}
2828

core/action/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func NewState() *StateAction {
1515

1616
type StateAction struct{}
1717

18-
func (a *StateAction) Run(context.Context, types.ActionParams) (types.ActionResult, error) {
18+
func (a *StateAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error) {
1919
return types.ActionResult{Result: "internal state has been updated"}, nil
2020
}
2121

0 commit comments

Comments
 (0)