Merge branch 'main' of github.com:convergence-ai/proxy-lite
Browse files
src/proxy_lite/browser/browser.py
CHANGED
|
@@ -5,6 +5,7 @@ from contextlib import AsyncExitStack
|
|
| 5 |
from pathlib import Path
|
| 6 |
from typing import Literal, Optional, Self
|
| 7 |
|
|
|
|
| 8 |
from playwright.async_api import Browser, BrowserContext, Page, Playwright, async_playwright
|
| 9 |
from playwright.async_api import TimeoutError as PlaywrightTimeoutError
|
| 10 |
from playwright_stealth import stealth_async
|
|
@@ -371,8 +372,13 @@ class BrowserSession:
|
|
| 371 |
if existing_text.strip():
|
| 372 |
# Clear existing text only if it exists
|
| 373 |
await self.click(mark_id)
|
| 374 |
-
|
| 375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
await self.current_page.keyboard.press("Backspace")
|
| 377 |
|
| 378 |
|
|
|
|
| 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 stealth_async
|
|
|
|
| 372 |
if existing_text.strip():
|
| 373 |
# Clear existing text only if it exists
|
| 374 |
await self.click(mark_id)
|
| 375 |
+
if platform.system() == "Darwin": # selecting all text is OS-specific
|
| 376 |
+
await self.click(mark_id)
|
| 377 |
+
await self.current_page.keyboard.press("Meta+a")
|
| 378 |
+
await self.current_page.keyboard.press("Backspace")
|
| 379 |
+
else:
|
| 380 |
+
await self.current_page.keyboard.press("Control+Home")
|
| 381 |
+
await self.current_page.keyboard.press("Control+Shift+End")
|
| 382 |
await self.current_page.keyboard.press("Backspace")
|
| 383 |
|
| 384 |
|
src/proxy_lite/client.py
CHANGED
|
@@ -73,7 +73,7 @@ class BaseClient(BaseModel, ABC):
|
|
| 73 |
class OpenAIClientConfig(BaseClientConfig):
|
| 74 |
name: Literal["openai"] = "openai"
|
| 75 |
model_id: str = "gpt-4o"
|
| 76 |
-
api_key: str = os.environ
|
| 77 |
|
| 78 |
|
| 79 |
class OpenAIClient(BaseClient):
|
|
@@ -137,6 +137,7 @@ class ConvergenceClient(OpenAIClient):
|
|
| 137 |
@cached_property
|
| 138 |
def external_client(self) -> AsyncOpenAI:
|
| 139 |
return AsyncOpenAI(
|
|
|
|
| 140 |
base_url=self.config.api_base,
|
| 141 |
http_client=self.http_client,
|
| 142 |
)
|
|
|
|
| 73 |
class OpenAIClientConfig(BaseClientConfig):
|
| 74 |
name: Literal["openai"] = "openai"
|
| 75 |
model_id: str = "gpt-4o"
|
| 76 |
+
api_key: str = os.environ.get("OPENAI_API_KEY")
|
| 77 |
|
| 78 |
|
| 79 |
class OpenAIClient(BaseClient):
|
|
|
|
| 137 |
@cached_property
|
| 138 |
def external_client(self) -> AsyncOpenAI:
|
| 139 |
return AsyncOpenAI(
|
| 140 |
+
api_key=self.config.api_key,
|
| 141 |
base_url=self.config.api_base,
|
| 142 |
http_client=self.http_client,
|
| 143 |
)
|