Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ async def extract_code_blocks(markdown_text):
|
|
45 |
|
46 |
return code_blocks
|
47 |
|
48 |
-
|
49 |
description = request.description
|
50 |
prompt = PROMPT_TEMPLATE.format(description=description)
|
51 |
generated_completion = client.chat.completions.create(
|
@@ -62,8 +62,7 @@ async def generate_infographic(request: InfographicRequest):
|
|
62 |
)
|
63 |
generated_text = generated_completion.choices[0].message.content
|
64 |
print(generated_text)
|
65 |
-
|
66 |
-
return code_blocks
|
67 |
|
68 |
# Route to serve the HTML template
|
69 |
@app.get("/", response_class=HTMLResponse)
|
@@ -73,7 +72,8 @@ async def serve_frontend():
|
|
73 |
# Route to handle infographic generation
|
74 |
@app.post("/generate")
|
75 |
async def generate_infographic(request: InfographicRequest):
|
76 |
-
|
|
|
77 |
if code_blocks:
|
78 |
return JSONResponse(content={"html": code_blocks[0]})
|
79 |
else:
|
|
|
45 |
|
46 |
return code_blocks
|
47 |
|
48 |
+
def generate_infographic(request: InfographicRequest):
|
49 |
description = request.description
|
50 |
prompt = PROMPT_TEMPLATE.format(description=description)
|
51 |
generated_completion = client.chat.completions.create(
|
|
|
62 |
)
|
63 |
generated_text = generated_completion.choices[0].message.content
|
64 |
print(generated_text)
|
65 |
+
return generated_text
|
|
|
66 |
|
67 |
# Route to serve the HTML template
|
68 |
@app.get("/", response_class=HTMLResponse)
|
|
|
72 |
# Route to handle infographic generation
|
73 |
@app.post("/generate")
|
74 |
async def generate_infographic(request: InfographicRequest):
|
75 |
+
generated_text= generate_infographic(request)
|
76 |
+
code_blocks=await extract_code_blocks(generated_text)
|
77 |
if code_blocks:
|
78 |
return JSONResponse(content={"html": code_blocks[0]})
|
79 |
else:
|