Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,8 +74,13 @@ async def serve_frontend():
|
|
| 74 |
async def generate_infographic(request: InfographicRequest):
|
| 75 |
description = request.description
|
| 76 |
prompt = PROMPT_TEMPLATE.format(description=description)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
try:
|
| 79 |
# messages = [{"role": "user", "content": prompt}]
|
| 80 |
# stream = client.chat.completions.create(
|
| 81 |
# model="Qwen/Qwen2.5-Coder-32B-Instruct",
|
|
@@ -93,11 +98,11 @@ async def generate_infographic(request: InfographicRequest):
|
|
| 93 |
|
| 94 |
# print(generated_text)
|
| 95 |
#code_blocks= await extract_code_blocks(generated_text)
|
| 96 |
-
code_blocks= await generate_infographic(description)
|
| 97 |
-
if code_blocks:
|
| 98 |
-
|
| 99 |
-
else:
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
except Exception as e:
|
| 103 |
-
|
|
|
|
| 74 |
async def generate_infographic(request: InfographicRequest):
|
| 75 |
description = request.description
|
| 76 |
prompt = PROMPT_TEMPLATE.format(description=description)
|
| 77 |
+
code_blocks= await generate_infographic(description)
|
| 78 |
+
if code_blocks:
|
| 79 |
+
return JSONResponse(content={"html": code_blocks[0]})
|
| 80 |
+
else:
|
| 81 |
+
return JSONResponse(content={"error": "No generation"},status_code=500)
|
| 82 |
|
| 83 |
+
# try:
|
| 84 |
# messages = [{"role": "user", "content": prompt}]
|
| 85 |
# stream = client.chat.completions.create(
|
| 86 |
# model="Qwen/Qwen2.5-Coder-32B-Instruct",
|
|
|
|
| 98 |
|
| 99 |
# print(generated_text)
|
| 100 |
#code_blocks= await extract_code_blocks(generated_text)
|
| 101 |
+
# code_blocks= await generate_infographic(description)
|
| 102 |
+
# if code_blocks:
|
| 103 |
+
# return JSONResponse(content={"html": code_blocks[0]})
|
| 104 |
+
# else:
|
| 105 |
+
# return JSONResponse(content={"error": "No generation"},status_code=500)
|
| 106 |
+
|
| 107 |
+
# except Exception as e:
|
| 108 |
+
# return JSONResponse(content={"error": str(e)}, status_code=500)
|