yasserrmd commited on
Commit
ce99034
1 Parent(s): e823d14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -45,7 +45,16 @@ async def extract_code_blocks(markdown_text):
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(
@@ -61,18 +70,6 @@ def generate_infographic(request: InfographicRequest):
61
  stop=None
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)
69
- async def serve_frontend():
70
- return HTMLResponse(open("static/infographic_gen.html").read())
71
-
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]})
 
45
 
46
  return code_blocks
47
 
48
+
49
+
50
+ # Route to serve the HTML template
51
+ @app.get("/", response_class=HTMLResponse)
52
+ async def serve_frontend():
53
+ return HTMLResponse(open("static/infographic_gen.html").read())
54
+
55
+ # Route to handle infographic generation
56
+ @app.post("/generate")
57
+ async def generate_infographic(request: InfographicRequest):
58
  description = request.description
59
  prompt = PROMPT_TEMPLATE.format(description=description)
60
  generated_completion = client.chat.completions.create(
 
70
  stop=None
71
  )
72
  generated_text = generated_completion.choices[0].message.content
 
 
 
 
 
 
 
 
 
 
 
 
73
  code_blocks=await extract_code_blocks(generated_text)
74
  if code_blocks:
75
  return JSONResponse(content={"html": code_blocks[0]})