Spaces:
Running
Running
precommit
Browse files- .pre-commit-config.yaml +22 -0
- pyproject.toml +1 -0
- src/proxy_lite/app.py +7 -4
- src/proxy_lite/browser/browser.py +2 -8
- src/proxy_lite/environments/environment_base.py +1 -1
- src/proxy_lite/tools/return_tool.py +1 -1
- src/proxy_lite/tools/tool_base.py +1 -1
- uv.lock +0 -0
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
+
rev: v4.5.0
|
4 |
+
hooks:
|
5 |
+
- id: trailing-whitespace
|
6 |
+
files: ^src/
|
7 |
+
- id: end-of-file-fixer
|
8 |
+
files: ^src/
|
9 |
+
- id: check-yaml
|
10 |
+
files: ^src/
|
11 |
+
- id: check-added-large-files
|
12 |
+
files: ^src/
|
13 |
+
- id: debug-statements
|
14 |
+
|
15 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
16 |
+
rev: v0.9.3
|
17 |
+
hooks:
|
18 |
+
- id: ruff
|
19 |
+
args: ["--fix"]
|
20 |
+
files: ^src/
|
21 |
+
- id: ruff-format
|
22 |
+
files: ^src/
|
pyproject.toml
CHANGED
@@ -18,6 +18,7 @@ dependencies = [
|
|
18 |
"torch>=2.5.1",
|
19 |
"torchvision>=0.20.1",
|
20 |
"streamlit>=1.40.2",
|
|
|
21 |
]
|
22 |
|
23 |
[project.scripts]
|
|
|
18 |
"torch>=2.5.1",
|
19 |
"torchvision>=0.20.1",
|
20 |
"streamlit>=1.40.2",
|
21 |
+
"pre-commit>=4.1.0",
|
22 |
]
|
23 |
|
24 |
[project.scripts]
|
src/proxy_lite/app.py
CHANGED
@@ -20,7 +20,7 @@ def get_user_config(config_expander):
|
|
20 |
"include_poi_text": True,
|
21 |
"homepage": "https://www.google.com",
|
22 |
"keep_original_image": False,
|
23 |
-
"headless": False, #
|
24 |
},
|
25 |
"solver": {
|
26 |
"name": "simple",
|
@@ -151,9 +151,12 @@ async def run_task_async(
|
|
151 |
# Update status with latest step
|
152 |
if run.actions:
|
153 |
latest_step = run.actions[-1].text
|
154 |
-
latest_step += "".join(
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
157 |
action_placeholder.write(f"⚡ **Latest Step:** {latest_step}")
|
158 |
all_steps.append(latest_step)
|
159 |
|
|
|
20 |
"include_poi_text": True,
|
21 |
"homepage": "https://www.google.com",
|
22 |
"keep_original_image": False,
|
23 |
+
"headless": False, # without proxies headless mode often results in getting bot blocked
|
24 |
},
|
25 |
"solver": {
|
26 |
"name": "simple",
|
|
|
151 |
# Update status with latest step
|
152 |
if run.actions:
|
153 |
latest_step = run.actions[-1].text
|
154 |
+
latest_step += "".join(
|
155 |
+
[
|
156 |
+
f'<tool_call>{{"name": {tool_call.function["name"]}, "arguments": {tool_call.function["arguments"]}}}</tool_call>' # noqa: E501
|
157 |
+
for tool_call in run.actions[-1].tool_calls
|
158 |
+
]
|
159 |
+
)
|
160 |
action_placeholder.write(f"⚡ **Latest Step:** {latest_step}")
|
161 |
all_steps.append(latest_step)
|
162 |
|
src/proxy_lite/browser/browser.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
import asyncio
|
2 |
import logging
|
|
|
3 |
import re
|
4 |
from contextlib import AsyncExitStack
|
5 |
from pathlib import Path
|
6 |
from typing import Literal, Optional, Self
|
7 |
|
8 |
-
import platform
|
9 |
from playwright.async_api import Browser, BrowserContext, Page, Playwright, async_playwright
|
10 |
from playwright.async_api import TimeoutError as PlaywrightTimeoutError
|
11 |
-
from playwright_stealth import
|
12 |
from pydantic import Field
|
13 |
from tenacity import before_sleep_log, retry, stop_after_delay, wait_exponential
|
14 |
|
@@ -383,12 +383,6 @@ class BrowserSession:
|
|
383 |
|
384 |
|
385 |
if __name__ == "__main__":
|
386 |
-
import json
|
387 |
-
|
388 |
-
test = """{"name": "return_value", "arguments": {'value': 'The most downloaded French speech recognition model on Hugging Face is DeepSeek-R1. Here are its evaluation metrics:\n\n- Claude-3.5-1022: MMLU 88.3, MMLU-Redux 88.9\n- GPT-4.0-5013: MMLU 87.2, MMLU-Redux 88.0\n- DeepSeek-01-3013: MMLU 88.5, MMLU-Redux 89.1\n- OpenAI-01-mini: MMLU 91.0, MMLU-Redux 88.7\n\nPlease see the attached screenshot for more details.'}}"""
|
389 |
-
test = json.loads(test)
|
390 |
-
print(test)
|
391 |
-
exit()
|
392 |
|
393 |
async def dummy_test():
|
394 |
async with BrowserSession(headless=False) as s:
|
|
|
1 |
import asyncio
|
2 |
import logging
|
3 |
+
import platform
|
4 |
import re
|
5 |
from contextlib import AsyncExitStack
|
6 |
from pathlib import Path
|
7 |
from typing import Literal, Optional, Self
|
8 |
|
|
|
9 |
from playwright.async_api import Browser, BrowserContext, Page, Playwright, async_playwright
|
10 |
from playwright.async_api import TimeoutError as PlaywrightTimeoutError
|
11 |
+
from playwright_stealth import StealthConfig, stealth_async
|
12 |
from pydantic import Field
|
13 |
from tenacity import before_sleep_log, retry, stop_after_delay, wait_exponential
|
14 |
|
|
|
383 |
|
384 |
|
385 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
|
387 |
async def dummy_test():
|
388 |
async with BrowserSession(headless=False) as s:
|
src/proxy_lite/environments/environment_base.py
CHANGED
@@ -84,7 +84,7 @@ class BaseEnvironment(BaseModel, ABC):
|
|
84 |
for tool in self.tools:
|
85 |
if hasattr(tool, function["name"]):
|
86 |
arguments = json.loads(function["arguments"])
|
87 |
-
if
|
88 |
arguments = json.loads(arguments)
|
89 |
return await getattr(tool, function["name"])(
|
90 |
**arguments,
|
|
|
84 |
for tool in self.tools:
|
85 |
if hasattr(tool, function["name"]):
|
86 |
arguments = json.loads(function["arguments"])
|
87 |
+
if isinstance(arguments, str):
|
88 |
arguments = json.loads(arguments)
|
89 |
return await getattr(tool, function["name"])(
|
90 |
**arguments,
|
src/proxy_lite/tools/return_tool.py
CHANGED
@@ -13,5 +13,5 @@ class ReturnValueTool(Tool):
|
|
13 |
|
14 |
@attach_param_schema(ReturnValueParams)
|
15 |
def return_value(self, value: str):
|
16 |
-
"""Return a value to the user. Use this tool when you have finished the task in order to provide any information the user has requested."""
|
17 |
print(value)
|
|
|
13 |
|
14 |
@attach_param_schema(ReturnValueParams)
|
15 |
def return_value(self, value: str):
|
16 |
+
"""Return a value to the user. Use this tool when you have finished the task in order to provide any information the user has requested.""" # noqa: E501
|
17 |
print(value)
|
src/proxy_lite/tools/tool_base.py
CHANGED
@@ -2,7 +2,7 @@ import inspect
|
|
2 |
from functools import cached_property, wraps
|
3 |
from typing import Any, Callable, Optional
|
4 |
|
5 |
-
from pydantic import BaseModel
|
6 |
|
7 |
|
8 |
class Tool:
|
|
|
2 |
from functools import cached_property, wraps
|
3 |
from typing import Any, Callable, Optional
|
4 |
|
5 |
+
from pydantic import BaseModel
|
6 |
|
7 |
|
8 |
class Tool:
|
uv.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|