Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -520,7 +520,7 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
|
|
| 520 |
if "```" in chart_list[ii]:
|
| 521 |
while True:
|
| 522 |
line_out+=chart_list[ii+cnti].strip().strip("\n").replace('"',"")
|
| 523 |
-
if not line_out.endswith(";"):
|
| 524 |
line_out+=";"
|
| 525 |
line_out+="\n"
|
| 526 |
cnti+=1
|
|
@@ -542,32 +542,12 @@ def clear_fn():
|
|
| 542 |
return "",[(None,None)]
|
| 543 |
|
| 544 |
def create_image(url):
|
| 545 |
-
'''cairosvg.svg2png(
|
| 546 |
-
url="/path/to/input.svg", write_to="/tmp/output.png")
|
| 547 |
-
output = cairosvg.svg2png(
|
| 548 |
-
bytestring=open("/path/to/input.svg").read().encode('utf-8')) ''' #source = requests.get(url)
|
| 549 |
-
#source = urllib.request.urlopen(url).read()
|
| 550 |
-
#soup = bs4.BeautifulSoup(source.content,'lxml')
|
| 551 |
-
|
| 552 |
-
#rawp=(f'RAW TEXT RETURNED: {soup.text}')
|
| 553 |
-
#cnt=0
|
| 554 |
-
#cnt+=len(rawp)
|
| 555 |
-
#out.append(rawp)
|
| 556 |
-
#out.append("HTML fragments: ")
|
| 557 |
-
#q=("a","p","span","content","article")
|
| 558 |
-
#out=[]
|
| 559 |
-
#for b in soup.find_all("div"):
|
| 560 |
-
# for p in b.find_all("pre, {'class': 'mermaid'}"):
|
| 561 |
-
# out.append(p.find('svg'))
|
| 562 |
print(url)
|
| 563 |
-
#out.append(p.string)
|
| 564 |
with open("tmp.svg","w") as svg:
|
| 565 |
svg.write(url)
|
| 566 |
-
#cairosvg.svg2png(
|
| 567 |
-
# url="tmp.svg", write_to="output.png")
|
| 568 |
output = cairosvg.svg2png(
|
| 569 |
bytestring=open('tmp.svg').read().encode('utf-8'), write_to="output.png")
|
| 570 |
-
return "
|
| 571 |
|
| 572 |
score_js="""
|
| 573 |
function(text_input) {
|
|
|
|
| 520 |
if "```" in chart_list[ii]:
|
| 521 |
while True:
|
| 522 |
line_out+=chart_list[ii+cnti].strip().strip("\n").replace('"',"")
|
| 523 |
+
if not line_out.strip().endswith(";"):
|
| 524 |
line_out+=";"
|
| 525 |
line_out+="\n"
|
| 526 |
cnti+=1
|
|
|
|
| 542 |
return "",[(None,None)]
|
| 543 |
|
| 544 |
def create_image(url):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
print(url)
|
|
|
|
| 546 |
with open("tmp.svg","w") as svg:
|
| 547 |
svg.write(url)
|
|
|
|
|
|
|
| 548 |
output = cairosvg.svg2png(
|
| 549 |
bytestring=open('tmp.svg').read().encode('utf-8'), write_to="output.png")
|
| 550 |
+
return "tmp.svg"
|
| 551 |
|
| 552 |
score_js="""
|
| 553 |
function(text_input) {
|