Josedcape commited on
Commit
4fd8631
·
verified ·
1 Parent(s): bafd1e6

Update src/agent/custom_views.py

Browse files
Files changed (1) hide show
  1. src/agent/custom_views.py +44 -55
src/agent/custom_views.py CHANGED
@@ -1,55 +1,44 @@
1
- from dataclasses import dataclass
2
- from typing import Type
3
-
4
- from browser_use.agent.views import AgentOutput
5
- from browser_use.controller.registry.views import ActionModel
6
- from pydantic import BaseModel, ConfigDict, Field, create_model
7
-
8
-
9
- @dataclass
10
- class CustomAgentStepInfo:
11
- step_number: int
12
- max_steps: int
13
- task: str
14
- add_infos: str
15
- memory: str
16
- task_progress: str
17
- future_plans: str
18
-
19
-
20
- class CustomAgentBrain(BaseModel):
21
- """Current state of the agent"""
22
-
23
- prev_action_evaluation: str
24
- important_contents: str
25
- task_progress: str
26
- future_plans: str
27
- thought: str
28
- summary: str
29
-
30
-
31
- class CustomAgentOutput(AgentOutput):
32
- """Output model for agent
33
-
34
- @dev note: this model is extended with custom actions in AgentService. You can also use some fields that are not in this model as provided by the linter, as long as they are registered in the DynamicActions model.
35
- """
36
-
37
- model_config = ConfigDict(arbitrary_types_allowed=True)
38
-
39
- current_state: CustomAgentBrain
40
- action: list[ActionModel]
41
-
42
- @staticmethod
43
- def type_with_custom_actions(
44
- custom_actions: Type[ActionModel],
45
- ) -> Type["CustomAgentOutput"]:
46
- """Extend actions with custom actions"""
47
- return create_model(
48
- "AgentOutput",
49
- __base__=CustomAgentOutput,
50
- action=(
51
- list[custom_actions],
52
- Field(...),
53
- ), # Properly annotated field with no default
54
- __module__=CustomAgentOutput.__module__,
55
- )
 
1
+ from dataclasses import dataclass
2
+ from typing import Type
3
+
4
+ from browser_use.agent.views import AgentOutput
5
+ from browser_use.controller.registry.views import ActionModel
6
+ from pydantic import BaseModel, ConfigDict, Field, create_model
7
+
8
+ @dataclass
9
+ class CustomAgentStepInfo:
10
+ step_number: int
11
+ max_steps: int
12
+ task: str
13
+ add_infos: str
14
+ memory: str
15
+ task_progress: str
16
+ future_plans: str
17
+
18
+ class CustomAgentBrain(BaseModel):
19
+ prev_action_evaluation: str
20
+ important_contents: str
21
+ task_progress: str
22
+ future_plans: str
23
+ thought: str
24
+ summary: str
25
+
26
+ class CustomAgentOutput(AgentOutput):
27
+ model_config = ConfigDict(arbitrary_types_allowed=True)
28
+
29
+ current_state: CustomAgentBrain
30
+ action: list[ActionModel]
31
+
32
+ @staticmethod
33
+ def type_with_custom_actions(
34
+ custom_actions: Type[ActionModel],
35
+ ) -> Type["CustomAgentOutput"]:
36
+ return create_model(
37
+ "AgentOutput",
38
+ __base__=CustomAgentOutput,
39
+ action=(
40
+ list[custom_actions],
41
+ Field(...),
42
+ ),
43
+ __module__=CustomAgentOutput.__module__,
44
+ )