Ephraimmm commited on
Commit
7333e24
·
verified ·
1 Parent(s): f9271f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -8
app.py CHANGED
@@ -245,13 +245,40 @@ def stream_pitchdeck(company_name, url):
245
 
246
 
247
  #gradio
248
-
249
-
250
  import gradio as gr
251
 
252
- #create the Gradio interface
253
- iface = gr.Interface(
254
- fn=stream_pitchdeck,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  inputs=[
256
  gr.Textbox(label="Company Name"),
257
  gr.Textbox(label="Company Website URL")
@@ -260,6 +287,21 @@ iface = gr.Interface(
260
  title="Company Pitch Deck Generator",
261
  description="Enter the company name and website URL to generate a pitch deck based on the website content."
262
  )
263
-
264
- # Launch the Gradio app
265
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
 
247
  #gradio
 
 
248
  import gradio as gr
249
 
250
+ def stream_pitchdeck2(company_name, url):
251
+ if not company_name or not url:
252
+ return "Please provide both company name and URL."
253
+
254
+ user_prompt = get_pitch_user_prompt(company_name, url)
255
+
256
+ if user_prompt == "Could not retrieve website details to generate pitch deck.":
257
+ return user_prompt
258
+
259
+ try:
260
+ stream = openai.chat.completions.create(
261
+ model=MODEL,
262
+ messages=[
263
+ {"role": "system", "content": system_prompt},
264
+ {"role": "user", "content": user_prompt}
265
+ ],
266
+ stream=True
267
+ )
268
+
269
+ response = ""
270
+ for chunk in stream:
271
+ response += chunk.choices[0].delta.content or ''
272
+ response = response.replace("```","").replace("markdown", "")
273
+ yield response # Use yield for Gradio streaming
274
+
275
+ return response
276
+ except Exception as e:
277
+ return f"An error occurred during OpenAI API call: {e}"
278
+
279
+ # Create the Gradio interface
280
+ iface2 = gr.Interface(
281
+ fn=stream_pitchdeck2,
282
  inputs=[
283
  gr.Textbox(label="Company Name"),
284
  gr.Textbox(label="Company Website URL")
 
287
  title="Company Pitch Deck Generator",
288
  description="Enter the company name and website URL to generate a pitch deck based on the website content."
289
  )
290
+ iface2.launch(debug = True, share=True)
291
+
292
+ # import gradio as gr
293
+
294
+ # #create the Gradio interface
295
+ # iface = gr.Interface(
296
+ # fn=stream_pitchdeck,
297
+ # inputs=[
298
+ # gr.Textbox(label="Company Name"),
299
+ # gr.Textbox(label="Company Website URL")
300
+ # ],
301
+ # outputs=gr.Markdown(label="Generated Pitch Deck"),
302
+ # title="Company Pitch Deck Generator",
303
+ # description="Enter the company name and website URL to generate a pitch deck based on the website content."
304
+ # )
305
+
306
+ # # Launch the Gradio app
307
+ # iface.launch()