Skip to content

Commit 2a19579

Browse files
committed
Add mustache rendering for ManageEngine and BrowserUse
1 parent cded634 commit 2a19579

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

patchwork/steps/BrowserUse/BrowserUse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from datetime import datetime
55

6+
from patchwork.common.utils.utils import mustache_render
67
from patchwork.step import Step
78
from patchwork.steps import SimplifiedLLMOnce
89
from patchwork.steps.BrowserUse.typed import BrowserUseInputs, BrowserUseOutputs
@@ -178,7 +179,7 @@ def run(self) -> dict:
178179
agent = Agent(
179180
browser=browser,
180181
controller=controller,
181-
task=self.inputs["task"],
182+
task=mustache_render(self.inputs["task"], self.inputs["task_value"]),
182183
llm=self.llm,
183184
generate_gif=self.generate_gif,
184185
validate_output=True,

patchwork/steps/BrowserUse/typed.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
from typing_extensions import Annotated, TypedDict
1+
from typing_extensions import Annotated, Any, Dict, Optional, TypedDict
22

33
from patchwork.common.utils.step_typing import StepTypeConfig
44

55

6-
class BrowserUseInputs(TypedDict, total=False):
6+
class __BrowserUseInputsRequired(TypedDict):
77
task: str
8-
example_json: str
9-
openai_api_key: Annotated[
10-
str,
11-
StepTypeConfig(is_config=True, or_op=["google_api_key", "anthropic_api_key"]),
12-
]
13-
anthropic_api_key: Annotated[str, StepTypeConfig(is_config=True, or_op=["google_api_key", "openai_api_key"])]
14-
google_api_key: Annotated[
15-
str,
16-
StepTypeConfig(is_config=True, or_op=["openai_api_key", "anthropic_api_key"]),
17-
]
18-
generate_gif: Annotated[bool, StepTypeConfig(is_config=True)]
8+
task_value: Dict[str, Any]
9+
10+
11+
class BrowserUseInputs(__BrowserUseInputsRequired, total=False):
12+
example_json: Optional[str]
13+
openai_api_key: Annotated[str, StepTypeConfig(or_op=["google_api_key", "anthropic_api_key"])]
14+
anthropic_api_key: Annotated[str, StepTypeConfig(or_op=["google_api_key", "openai_api_key"])]
15+
google_api_key: Annotated[str, StepTypeConfig(or_op=["openai_api_key", "anthropic_api_key"])]
16+
generate_gif: Optional[bool]
1917

2018

2119
class BrowserUseOutputs(TypedDict):

patchwork/steps/ManageEngineAgent/ManageEngineAgent.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
AgenticStrategyV2,
55
)
66
from patchwork.common.tools.api_tool import APIRequestTool
7+
from patchwork.common.utils.utils import mustache_render
78
from patchwork.step import Step
89

910
from .typed import ManageEngineAgentInputs, ManageEngineAgentOutputs
1011

1112

12-
class ManageEngineAgent(
13-
Step, input_class=ManageEngineAgentInputs, output_class=ManageEngineAgentOutputs
14-
):
13+
class ManageEngineAgent(Step, input_class=ManageEngineAgentInputs, output_class=ManageEngineAgentOutputs):
1514
def __init__(self, inputs: dict):
1615
super().__init__(inputs)
1716

@@ -43,7 +42,7 @@ def __init__(self, inputs: dict):
4342
llm_client=llm_client,
4443
system_prompt_template=system_prompt,
4544
template_data={},
46-
user_prompt_template=inputs.get("user_prompt"),
45+
user_prompt_template=mustache_render(inputs.get("user_prompt"), inputs.get("prompt_value")),
4746
agent_configs=[
4847
AgentConfig(
4948
name="ManageEngine Assistant",

patchwork/steps/ManageEngineAgent/typed.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
from typing_extensions import Annotated, Dict, List, Optional, TypedDict
1+
from typing_extensions import Annotated, Any, Dict, List, Optional, TypedDict
22

33
from patchwork.common.utils.step_typing import StepTypeConfig
44

55

6-
class ManageEngineAgentInputs(TypedDict, total=False):
6+
class __ManageEngineAgentInputsRequired(TypedDict):
77
me_access_token: str
8+
user_prompt: str
9+
prompt_value: Dict[str, Any]
10+
11+
12+
class ManageEngineAgentInputs(__ManageEngineAgentInputsRequired, total=False):
813
max_agent_calls: int
9-
openai_api_key: Annotated[
10-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "anthropic_api_key"])
11-
]
12-
anthropic_api_key: Annotated[
13-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"])
14-
]
15-
google_api_key: Annotated[
16-
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
17-
]
14+
openai_api_key: Annotated[str, StepTypeConfig(or_op=["google_api_key", "anthropic_api_key"])]
15+
anthropic_api_key: Annotated[str, StepTypeConfig(or_op=["google_api_key", "openai_api_key"])]
16+
google_api_key: Annotated[str, StepTypeConfig(or_op=["openai_api_key", "anthropic_api_key"])]
1817

1918
# Prompt and strategy configuration
2019
system_prompt: Optional[str]
21-
user_prompt: str
2220
example_json: Optional[Dict]
2321

2422

0 commit comments

Comments
 (0)