Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
3 |
from playwright.async_api import async_playwright
|
|
|
1 |
+
import subprocess
|
2 |
+
from playwright.async_api import async_playwright
|
3 |
+
|
4 |
+
async def main():
|
5 |
+
# Check if the browser binaries exist, if not, download them
|
6 |
+
try:
|
7 |
+
subprocess.check_output(["which", "chromium"])
|
8 |
+
except FileNotFoundError:
|
9 |
+
print("Browser binaries not found. Downloading...")
|
10 |
+
subprocess.run(["playwright", "install"])
|
11 |
+
|
12 |
+
# Your existing initialization code follows
|
13 |
+
async with async_playwright() as p:
|
14 |
+
browser = await p.chromium.launch()
|
15 |
+
# Continue with your application logic...
|
16 |
+
|
17 |
+
# Run the main function
|
18 |
+
if __name__ == "__main__":
|
19 |
+
import asyncio
|
20 |
+
asyncio.run(main())
|
21 |
+
|
22 |
+
|
23 |
import gradio as gr
|
24 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
25 |
from playwright.async_api import async_playwright
|