Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ import datetime
|
|
| 12 |
from pypdf import PdfReader
|
| 13 |
import uuid
|
| 14 |
from PIL import Image
|
|
|
|
| 15 |
|
| 16 |
from agent import (
|
| 17 |
PREFIX,
|
|
@@ -443,34 +444,6 @@ def create_image(url):
|
|
| 443 |
# bytestring=open('tmp.svg').read().encode('utf-8'), write_to="output.png")
|
| 444 |
return "tmp.png"
|
| 445 |
|
| 446 |
-
def create_ss(graph):
|
| 447 |
-
uid=uuid.uuid4()
|
| 448 |
-
code_out=""
|
| 449 |
-
for ea in graph.split("\n"):
|
| 450 |
-
code=ea.strip().strip("\n")
|
| 451 |
-
code_out+=code
|
| 452 |
-
url=f"https://omnibus-text-to-chart.hf.space/file=merm.html?mermaid={code_out}"
|
| 453 |
-
is_url=True
|
| 454 |
-
wait_time=10000
|
| 455 |
-
if is_url:
|
| 456 |
-
options = webdriver.ChromeOptions()
|
| 457 |
-
options.add_argument('--headless')
|
| 458 |
-
options.add_argument('--no-sandbox')
|
| 459 |
-
options.add_argument('--disable-dev-shm-usage')
|
| 460 |
-
mes='<center>operation success'
|
| 461 |
-
try:
|
| 462 |
-
driver = webdriver.Chrome(options=options)
|
| 463 |
-
driver.get(url)
|
| 464 |
-
html=driver.page_source
|
| 465 |
-
print(html)
|
| 466 |
-
driver.implicitly_wait(int(wait_time*30))
|
| 467 |
-
driver.set_window_size(int(width), int(height))
|
| 468 |
-
obj = driver.find_element(By.ID, "char_box")
|
| 469 |
-
screenshot = obj.screenshot(f'{uid}-tmp.png')
|
| 470 |
-
return(f'{uid}-tmp.png')
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
|
| 475 |
score_js="""
|
| 476 |
function(text_input) {
|
|
@@ -480,8 +453,6 @@ function(text_input) {
|
|
| 480 |
return [iframe];
|
| 481 |
}
|
| 482 |
"""
|
| 483 |
-
|
| 484 |
-
|
| 485 |
def zoom_update(inp):
|
| 486 |
this.clear()
|
| 487 |
this.append(str(inp))
|
|
|
|
| 12 |
from pypdf import PdfReader
|
| 13 |
import uuid
|
| 14 |
from PIL import Image
|
| 15 |
+
from screenshot import create_ss
|
| 16 |
|
| 17 |
from agent import (
|
| 18 |
PREFIX,
|
|
|
|
| 444 |
# bytestring=open('tmp.svg').read().encode('utf-8'), write_to="output.png")
|
| 445 |
return "tmp.png"
|
| 446 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
|
| 448 |
score_js="""
|
| 449 |
function(text_input) {
|
|
|
|
| 453 |
return [iframe];
|
| 454 |
}
|
| 455 |
"""
|
|
|
|
|
|
|
| 456 |
def zoom_update(inp):
|
| 457 |
this.clear()
|
| 458 |
this.append(str(inp))
|