Skip to content

Commit c9f9b3d

Browse files
authored
Merge pull request #75 from MarketSquare/chore/update_dep_versions
Update dependency versions. Use pydantic-ai-slim (instead of full package) Use named arguments for UsageLimits Adjust Tests
2 parents a263795 + c1fa8bc commit c9f9b3d

File tree

5 files changed

+245
-81
lines changed

5 files changed

+245
-81
lines changed

SelfhealingAgents/self_healing_system/agents/locator_agent/base_locator_agent.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
from typing import Optional
21
from abc import ABC, abstractmethod
2+
from typing import Optional
33

4-
from robot.api import logger as rf_logger
5-
from pydantic_ai.usage import UsageLimits
6-
from pydantic_ai.agent import AgentRunResult
74
from pydantic_ai import Agent, ModelRetry, RunContext
5+
from pydantic_ai.agent import AgentRunResult
6+
from pydantic_ai.usage import UsageLimits
7+
from robot.api import logger as rf_logger
88

9-
from SelfhealingAgents.utils.cfg import Cfg
10-
from SelfhealingAgents.utils.logging import log
11-
from SelfhealingAgents.self_healing_system.llm.client_model import get_client_model
12-
from SelfhealingAgents.self_healing_system.schemas.api.locator_healing import LocatorHealingResponse
13-
from SelfhealingAgents.self_healing_system.schemas.internal_state.prompt_payload import PromptPayload
14-
from SelfhealingAgents.self_healing_system.context_retrieving.library_dom_utils.base_dom_utils import BaseDomUtils
159
from SelfhealingAgents.self_healing_system.agents.prompts.locator.prompts_locator import (
1610
PromptsLocatorGenerationAgent,
17-
PromptsLocatorSelectionAgent
11+
PromptsLocatorSelectionAgent,
12+
)
13+
from SelfhealingAgents.self_healing_system.context_retrieving.library_dom_utils.base_dom_utils import (
14+
BaseDomUtils,
15+
)
16+
from SelfhealingAgents.self_healing_system.llm.client_model import get_client_model
17+
from SelfhealingAgents.self_healing_system.schemas.api.locator_healing import (
18+
LocatorHealingResponse,
19+
)
20+
from SelfhealingAgents.self_healing_system.schemas.internal_state.prompt_payload import (
21+
PromptPayload,
1822
)
23+
from SelfhealingAgents.utils.cfg import Cfg
24+
from SelfhealingAgents.utils.logging import log
1925

2026

2127
class BaseLocatorAgent(ABC):
@@ -31,18 +37,17 @@ class BaseLocatorAgent(ABC):
3137
generation.
3238
selection_agent (Optional[Agent[PromptPayload, str]]): Agent for DOM-based locator selection.
3339
"""
34-
def __init__(
35-
self,
36-
cfg: Cfg,
37-
dom_utility: BaseDomUtils
38-
) -> None:
40+
41+
def __init__(self, cfg: Cfg, dom_utility: BaseDomUtils) -> None:
3942
"""Initializes the BaseLocatorAgent.
4043
4144
Args:
4245
cfg (Cfg): Instance of Cfg config class containing user-defined app configuration.
4346
dom_utility (BaseDomUtils): DOM utility instance for validation.
4447
"""
45-
self._usage_limits: UsageLimits = UsageLimits(cfg.request_limit, cfg.total_tokens_limit)
48+
self._usage_limits: UsageLimits = UsageLimits(
49+
request_limit=cfg.request_limit, total_tokens_limit=cfg.total_tokens_limit
50+
)
4651
self._dom_utility: BaseDomUtils = dom_utility
4752
self._use_llm_for_locator_generation = cfg.use_llm_for_locator_generation
4853

@@ -60,7 +65,9 @@ def __init__(
6065
model=cfg.locator_agent_model,
6166
cfg=cfg,
6267
),
63-
system_prompt=PromptsLocatorGenerationAgent.get_system_msg(self._dom_utility),
68+
system_prompt=PromptsLocatorGenerationAgent.get_system_msg(
69+
self._dom_utility
70+
),
6471
deps_type=PromptPayload,
6572
output_type=LocatorHealingResponse,
6673
)

SelfhealingAgents/self_healing_system/agents/orchestrator_agent/orchestrator_agent.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
from robot.api import logger as rf_logger
2-
from pydantic_ai.usage import UsageLimits
3-
from pydantic_ai.agent import AgentRunResult
41
from pydantic_ai import Agent, ModelRetry, RunContext
2+
from pydantic_ai.agent import AgentRunResult
3+
from pydantic_ai.usage import UsageLimits
4+
from robot.api import logger as rf_logger
55

6-
from SelfhealingAgents.utils.cfg import Cfg
7-
from SelfhealingAgents.utils.logging import log
6+
from SelfhealingAgents.self_healing_system.agents.locator_agent.base_locator_agent import (
7+
BaseLocatorAgent,
8+
)
9+
from SelfhealingAgents.self_healing_system.agents.prompts.orchestrator.prompts_orchestrator import (
10+
PromptsOrchestrator,
11+
)
812
from SelfhealingAgents.self_healing_system.llm.client_model import get_client_model
9-
from SelfhealingAgents.self_healing_system.schemas.internal_state.prompt_payload import PromptPayload
10-
from SelfhealingAgents.self_healing_system.agents.locator_agent.base_locator_agent import BaseLocatorAgent
11-
from SelfhealingAgents.self_healing_system.agents.prompts.orchestrator.prompts_orchestrator import PromptsOrchestrator
1213
from SelfhealingAgents.self_healing_system.schemas.api.locator_healing import (
1314
LocatorHealingResponse,
1415
NoHealingNeededResponse,
1516
)
17+
from SelfhealingAgents.self_healing_system.schemas.internal_state.prompt_payload import (
18+
PromptPayload,
19+
)
20+
from SelfhealingAgents.utils.cfg import Cfg
21+
from SelfhealingAgents.utils.logging import log
1622

1723

1824
class OrchestratorAgent:
@@ -24,6 +30,7 @@ class OrchestratorAgent:
2430
_usage_limits (UsageLimits): Usage limits for the orchestrator agent.
2531
_agent (Agent[PromptPayload, str]): The underlying agent for orchestrating healing.
2632
"""
33+
2734
def __init__(
2835
self,
2936
cfg: Cfg,
@@ -37,7 +44,9 @@ def __init__(
3744
"""
3845
self._cfg = cfg
3946
self._locator_agent: BaseLocatorAgent = locator_agent
40-
self._usage_limits: UsageLimits = UsageLimits(cfg.request_limit, cfg.total_tokens_limit)
47+
self._usage_limits: UsageLimits = UsageLimits(
48+
request_limit=cfg.request_limit, total_tokens_limit=cfg.total_tokens_limit
49+
)
4150
self._agent: Agent[PromptPayload, str] = Agent[PromptPayload, str](
4251
model=get_client_model(
4352
provider=cfg.orchestrator_agent_provider,
@@ -46,7 +55,7 @@ def __init__(
4655
),
4756
system_prompt=PromptsOrchestrator.get_system_msg(),
4857
deps_type=PromptPayload,
49-
output_type=[self._get_healed_locators, str],
58+
output_type=[self._get_healed_locators],
5059
)
5160

5261
@log
@@ -105,4 +114,4 @@ def _catch_token_limit_exceedance(response_output: str) -> None:
105114
response_output (str): The response from the LLM request.
106115
"""
107116
if "error" in response_output:
108-
rf_logger.info(response_output)
117+
rf_logger.info(response_output)

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ license = "Apache-2.0"
1010
readme = "README.md"
1111
requires-python = ">=3.12,<4.0"
1212
dependencies = [
13-
"pydantic-ai>=0.5.0",
13+
"pydantic-ai-slim[logfire, openai, azure, litellm]",
1414
"robotframework >=7.1",
1515
"beautifulsoup4 >=4.13.4",
1616
"pydantic-settings >=2.9.1",
1717
"lxml>=6.0.0",
1818
"robotframework-browser",
1919
"robotframework-seleniumlibrary",
2020
"python-dotenv>=1.1.1",
21-
"pydantic-logfire>=0.0.1",
2221
]
2322

2423

0 commit comments

Comments
 (0)