Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 🔍 Code Quality Checks

on: [pull_request]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
files: ^src/
- id: end-of-file-fixer
files: ^src/
- id: check-yaml
files: ^src/
- id: check-added-large-files
files: ^src/
- id: debug-statements

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.3
hooks:
- id: ruff
args: ["--fix"]
files: ^src/
- id: ruff-format
files: ^src/
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies = [
"torch>=2.5.1",
"torchvision>=0.20.1",
"streamlit>=1.40.2",
"pre-commit>=4.1.0",
]

[project.scripts]
Expand Down
11 changes: 7 additions & 4 deletions src/proxy_lite/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_user_config(config_expander):
"include_poi_text": True,
"homepage": "https://www.google.com",
"keep_original_image": False,
"headless": False, # without proxies headless mode often results in getting bot blocked
"headless": False, # without proxies headless mode often results in getting bot blocked
},
"solver": {
"name": "simple",
Expand Down Expand Up @@ -151,9 +151,12 @@ async def run_task_async(
# Update status with latest step
if run.actions:
latest_step = run.actions[-1].text
latest_step += "".join([
f'<tool_call>{{"name": {tool_call.function["name"]}, "arguments": {tool_call.function["arguments"]}}}</tool_call>' for tool_call in run.actions[-1].tool_calls
])
latest_step += "".join(
[
f'<tool_call>{{"name": {tool_call.function["name"]}, "arguments": {tool_call.function["arguments"]}}}</tool_call>' # noqa: E501
for tool_call in run.actions[-1].tool_calls
]
)
action_placeholder.write(f"⚡ **Latest Step:** {latest_step}")
all_steps.append(latest_step)

Expand Down
10 changes: 2 additions & 8 deletions src/proxy_lite/browser/browser.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import asyncio
import logging
import platform
import re
from contextlib import AsyncExitStack
from pathlib import Path
from typing import Literal, Optional, Self

import platform
from playwright.async_api import Browser, BrowserContext, Page, Playwright, async_playwright
from playwright.async_api import TimeoutError as PlaywrightTimeoutError
from playwright_stealth import stealth_async, StealthConfig
from playwright_stealth import StealthConfig, stealth_async
from pydantic import Field
from tenacity import before_sleep_log, retry, stop_after_delay, wait_exponential

Expand Down Expand Up @@ -383,12 +383,6 @@ async def clear_text_field(self, mark_id: int) -> None:


if __name__ == "__main__":
import json

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.'}}"""
test = json.loads(test)
print(test)
exit()

async def dummy_test():
async with BrowserSession(headless=False) as s:
Expand Down
2 changes: 1 addition & 1 deletion src/proxy_lite/environments/environment_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def execute_tool(self, tool_call: ToolCall) -> None:
for tool in self.tools:
if hasattr(tool, function["name"]):
arguments = json.loads(function["arguments"])
if type(arguments) == str:
if isinstance(arguments, str):
arguments = json.loads(arguments)
return await getattr(tool, function["name"])(
**arguments,
Expand Down
2 changes: 1 addition & 1 deletion src/proxy_lite/tools/return_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def __init__(self):

@attach_param_schema(ReturnValueParams)
def return_value(self, value: str):
"""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."""
"""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
print(value)
2 changes: 1 addition & 1 deletion src/proxy_lite/tools/tool_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import cached_property, wraps
from typing import Any, Callable, Optional

from pydantic import BaseModel, Field
from pydantic import BaseModel


class Tool:
Expand Down
Loading