AhmedM20 commited on
Commit
3d9549e
β€’
1 Parent(s): ec427fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -13,7 +13,9 @@ import cohere
13
  import gradio as gr
14
  co = cohere.Client('aJ2AOC9ign3E3xKpWiUQ6tAWdKRv7O6QWBvCQVrN') # This is your trial API key
15
 
16
- def write_email(tone="",goal="",industry="",text="",audience=""):
 
 
17
  if audience=="" and industry=="":
18
  print(f'write 5 different {tone} emails to {goal} {text}')
19
  Message=f'write 5 different {tone} emails to {goal} {text}'
@@ -26,6 +28,7 @@ def write_email(tone="",goal="",industry="",text="",audience=""):
26
  else:
27
  print(f'write 5 different {tone} emails for {audience} to {goal} in the {industry} industry {text}')
28
  Message=f'write 5 different {tone} emails for {audience} to {goal} in the {industry} industry {text}'
 
29
  response = co.generate(
30
  model='command',
31
  prompt=Message,
@@ -44,15 +47,12 @@ with gr.Blocks() as demo:
44
  return gr.update(visible=False)
45
  else:
46
  return gr.update(visible=True)
47
- def Onchange_other_field(other_text):
48
- return gr.update(value=other_text)
49
  gr.Markdown("Create your marketing emails with AI")
50
  inp1 = gr.Radio(
51
  ["Convince to buy a product", "Recover churned customers", "Teach a new concept","Onboard users","Share product updates","Other"], value="Convince to buy a product",label = "Campagin goal"
52
  )
53
  other=gr.Textbox(visible=False,placeholder="Please enter other text",label = "Other:")
54
  inp1.input(other_field,inp1, other)
55
- other.change(Onchange_other_field, other,inp1)
56
  inp2 = gr.Radio(
57
  ["Formal", "Semi-formal", "Informal"], value="Formal",label = "Brand Tone"
58
  )
@@ -61,6 +61,6 @@ with gr.Blocks() as demo:
61
  inp5 = gr.Textbox(placeholder="Example: I am offering 10 dollars discount for customers who cancelled their subscription and want to find a way to bring them back ", label = "Tell us more about the email you want to send")
62
  btn = gr.Button("Generate πŸš€")
63
  out = gr.Textbox(label = "Here is your 5 Generated emails")
64
- btn.click(fn=write_email, inputs=[inp2, inp1,inp3,inp5,inp4], outputs=out)
65
 
66
  demo.launch(debug = True)
 
13
  import gradio as gr
14
  co = cohere.Client('aJ2AOC9ign3E3xKpWiUQ6tAWdKRv7O6QWBvCQVrN') # This is your trial API key
15
 
16
+ def write_email(tone="",goal="",industry="",text="",audience="",other=""):
17
+ if goal=="Other":
18
+ goal=other
19
  if audience=="" and industry=="":
20
  print(f'write 5 different {tone} emails to {goal} {text}')
21
  Message=f'write 5 different {tone} emails to {goal} {text}'
 
28
  else:
29
  print(f'write 5 different {tone} emails for {audience} to {goal} in the {industry} industry {text}')
30
  Message=f'write 5 different {tone} emails for {audience} to {goal} in the {industry} industry {text}'
31
+
32
  response = co.generate(
33
  model='command',
34
  prompt=Message,
 
47
  return gr.update(visible=False)
48
  else:
49
  return gr.update(visible=True)
 
 
50
  gr.Markdown("Create your marketing emails with AI")
51
  inp1 = gr.Radio(
52
  ["Convince to buy a product", "Recover churned customers", "Teach a new concept","Onboard users","Share product updates","Other"], value="Convince to buy a product",label = "Campagin goal"
53
  )
54
  other=gr.Textbox(visible=False,placeholder="Please enter other text",label = "Other:")
55
  inp1.input(other_field,inp1, other)
 
56
  inp2 = gr.Radio(
57
  ["Formal", "Semi-formal", "Informal"], value="Formal",label = "Brand Tone"
58
  )
 
61
  inp5 = gr.Textbox(placeholder="Example: I am offering 10 dollars discount for customers who cancelled their subscription and want to find a way to bring them back ", label = "Tell us more about the email you want to send")
62
  btn = gr.Button("Generate πŸš€")
63
  out = gr.Textbox(label = "Here is your 5 Generated emails")
64
+ btn.click(fn=write_email, inputs=[inp2, inp1,inp3,inp5,inp4,other], outputs=out)
65
 
66
  demo.launch(debug = True)