Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,6 +120,11 @@ async def perform_web_browse(action: str, query: str, browser_name: str, search_
|
|
| 120 |
if browser_key == 'firefox': browser_instance = await p.firefox.launch(headless=True)
|
| 121 |
elif browser_key == 'chromium': browser_instance = await p.chromium.launch(headless=True)
|
| 122 |
elif browser_key == 'webkit': browser_instance = await p.webkit.launch(headless=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
else: raise ValueError(f"Invalid browser name: {browser_name}")
|
| 124 |
PLAYWRIGHT_STATE[browser_key] = browser_instance
|
| 125 |
except Exception as e:
|
|
@@ -179,7 +184,7 @@ with gr.Blocks(title="Web Browse API", theme=gr.themes.Soft()) as demo:
|
|
| 179 |
query_input = gr.Textbox(label="Query or URL", placeholder="e.g., 'best cat food' or 'www.wikipedia.org'")
|
| 180 |
|
| 181 |
with gr.Row():
|
| 182 |
-
browser_input = gr.Dropdown(label="Browser", choices=["firefox", "chromium", "webkit"], value="firefox", scale=1)
|
| 183 |
search_engine_input = gr.Dropdown(label="Search Engine (if action is Search)", choices=sorted(list(SEARCH_ENGINES.keys())), value="DuckDuckGo", scale=2)
|
| 184 |
|
| 185 |
submit_button = gr.Button("Browse", variant="primary")
|
|
|
|
| 120 |
if browser_key == 'firefox': browser_instance = await p.firefox.launch(headless=True)
|
| 121 |
elif browser_key == 'chromium': browser_instance = await p.chromium.launch(headless=True)
|
| 122 |
elif browser_key == 'webkit': browser_instance = await p.webkit.launch(headless=True)
|
| 123 |
+
elif browser_key == 'camoufox':
|
| 124 |
+
from camoufox.async_api import AsyncCamoufox
|
| 125 |
+
browser_instance = await AsyncCamoufox().new_page()
|
| 126 |
+
|
| 127 |
+
|
| 128 |
else: raise ValueError(f"Invalid browser name: {browser_name}")
|
| 129 |
PLAYWRIGHT_STATE[browser_key] = browser_instance
|
| 130 |
except Exception as e:
|
|
|
|
| 184 |
query_input = gr.Textbox(label="Query or URL", placeholder="e.g., 'best cat food' or 'www.wikipedia.org'")
|
| 185 |
|
| 186 |
with gr.Row():
|
| 187 |
+
browser_input = gr.Dropdown(label="Browser", choices=["firefox", "chromium", "webkit", "camoufox"], value="firefox", scale=1)
|
| 188 |
search_engine_input = gr.Dropdown(label="Search Engine (if action is Search)", choices=sorted(list(SEARCH_ENGINES.keys())), value="DuckDuckGo", scale=2)
|
| 189 |
|
| 190 |
submit_button = gr.Button("Browse", variant="primary")
|