Spaces:
Sleeping
Sleeping
Attempt to ensure playright is ready when starting
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from playwright.async_api import async_playwright,
|
| 3 |
-
import asyncio
|
| 4 |
from PIL import Image
|
| 5 |
from io import BytesIO
|
| 6 |
from anthropic import Anthropic, TextEvent
|
|
@@ -9,7 +8,7 @@ import os
|
|
| 9 |
from typing import Literal
|
| 10 |
import time
|
| 11 |
from base64 import b64encode
|
| 12 |
-
import
|
| 13 |
|
| 14 |
load_dotenv()
|
| 15 |
# check for ANTHROPIC_API_KEY
|
|
@@ -22,6 +21,17 @@ anthropic = Anthropic()
|
|
| 22 |
model = "claude-3-5-sonnet-20240620"
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def apply_tailwind(content):
|
| 26 |
return f"""
|
| 27 |
<!DOCTYPE html>
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from playwright.async_api import async_playwright, Page
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
from io import BytesIO
|
| 5 |
from anthropic import Anthropic, TextEvent
|
|
|
|
| 8 |
from typing import Literal
|
| 9 |
import time
|
| 10 |
from base64 import b64encode
|
| 11 |
+
import sys
|
| 12 |
|
| 13 |
load_dotenv()
|
| 14 |
# check for ANTHROPIC_API_KEY
|
|
|
|
| 21 |
model = "claude-3-5-sonnet-20240620"
|
| 22 |
|
| 23 |
|
| 24 |
+
def prepare_playwright_if_needed():
|
| 25 |
+
# on linux install chromium with deps
|
| 26 |
+
if sys.platform.startswith("linux"):
|
| 27 |
+
os.system("playwright install chromium --with-deps")
|
| 28 |
+
else:
|
| 29 |
+
os.system("playwright install chromium")
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
prepare_playwright_if_needed()
|
| 33 |
+
|
| 34 |
+
|
| 35 |
def apply_tailwind(content):
|
| 36 |
return f"""
|
| 37 |
<!DOCTYPE html>
|