yashbaidya commited on
Commit
824adbd
·
1 Parent(s): 27031f8
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -1,20 +1,16 @@
1
- import os
2
- import requests
3
- from typing import List
4
  from openai import OpenAI
5
- # import google.generativeai
6
- # import anthropic
7
  import gradio as gr # oh yeah!
8
 
9
- openai = OpenAI(api_key="")
10
 
11
  def set_openai_api_key(apikey):
12
- openai.api_key = apikey
13
- return "✅ API key has been set and stored!"
14
 
15
  system_message = "You are a helpful assistant"
16
 
17
- def create_gtm(product,location):
 
18
  messages = [
19
  {"role": "system", "content": system_message},
20
  {"role": "user", "content": f"Act like a world class market research specialist. I want to promote {product} at {location}. Share a list of segments, potential geographies, decision-makers should target building a GTM strategy. Please give me the output in tabular format. Sort the segments in the decreasing order of the market size & demand"}
@@ -25,7 +21,8 @@ def create_gtm(product,location):
25
  )
26
  return completion.choices[0].message.content
27
 
28
- def buyers_persona(product,location,segment):
 
29
  messages = [
30
  {"role": "system", "content": system_message},
31
  {"role": "user", "content": f"Act like a World Class market Research Specilaist and do the task. I am selling {product} to {segment} at {location}. Build a Buyers Persona in tabular format classify the information based on Demography, Geo, Psychography, Behavior, also add buying barriers and buying triggers, Keywords they browse, Things they want to change, Their fear, etc."}
@@ -36,7 +33,8 @@ def buyers_persona(product,location,segment):
36
  )
37
  return completion.choices[0].message.content
38
 
39
- def create_uvp(product,location,segment,goal,problem,solution):
 
40
  messages = [
41
  {"role": "system", "content": system_message},
42
  {"role": "user", "content": f"I am selling {product} to {segment} in {location} I want you to act as a Marketing expert specializing in creating unique value propositions for {product} targeted to {segment} Craft a compelling and concise unique value proposition statement under 200 characters that highlights how to achieve {goal} without {problem} by utilizing {solution}."}
@@ -47,7 +45,8 @@ def create_uvp(product,location,segment,goal,problem,solution):
47
  )
48
  return completion.choices[0].message.content
49
 
50
- def create_usp(product,location,segment):
 
51
  messages = [
52
  {"role": "system", "content": system_message},
53
  {"role": "user", "content": f"My product is {product} selling to {segment} at {location} Please give the list of USPs & Group the USPs under 7Ps of Marketing."}
@@ -60,11 +59,12 @@ def create_usp(product,location,segment):
60
 
61
  with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
62
 
 
63
  with gr.Row():
64
  API=gr.Textbox(label="Enter OpenAI API key")
65
  set_api=gr.Button("Set API key")
66
  showAPI=gr.Text()
67
- set_api.click(fn=set_openai_api_key, inputs=[API], outputs=[showAPI])
68
 
69
  with gr.Row():
70
  with gr.Column():
@@ -77,7 +77,7 @@ with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
77
  button1=gr.Button("Generate GTM Strategy")
78
  with gr.Column():
79
  output_text1=gr.Markdown(height=400, max_height=400, show_copy_button=True, label="GTM", show_label=True)
80
- button1.click(fn=create_gtm, scroll_to_output=True ,inputs=[product,location], outputs=output_text1)
81
 
82
 
83
 
@@ -90,7 +90,7 @@ with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
90
  button2=gr.Button("Create Buyers Persona")
91
  with gr.Column():
92
  output_text2=gr.Markdown(height=400, max_height=400, show_copy_button=True)
93
- button2.click(fn=buyers_persona, scroll_to_output=True ,inputs=[product,location,segment], outputs=output_text2)
94
 
95
  with gr.Row():
96
  with gr.Column():
@@ -103,7 +103,7 @@ with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
103
  button2=gr.Button("Create UVP")
104
  with gr.Column():
105
  output_text2=gr.Markdown(height=200, max_height=200, show_copy_button=True)
106
- button2.click(fn=create_uvp, scroll_to_output=True ,inputs=[product,location,segment,goal,problem,solution], outputs=output_text2)
107
 
108
  with gr.Row():
109
  with gr.Column():
@@ -112,6 +112,6 @@ with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
112
  button2=gr.Button("Create USP")
113
  with gr.Column():
114
  output_text2=gr.Markdown(height=400, max_height=400, show_copy_button=True)
115
- button2.click(fn=create_usp, scroll_to_output=True ,inputs=[product,location,segment], outputs=output_text2)
116
 
117
  ui.launch(inbrowser=True)
 
 
 
 
1
  from openai import OpenAI
2
+
 
3
  import gradio as gr # oh yeah!
4
 
5
+
6
 
7
  def set_openai_api_key(apikey):
8
+ return apikey, "✅ API key has been set and stored!"
 
9
 
10
  system_message = "You are a helpful assistant"
11
 
12
+ def create_gtm(api_key, product,location):
13
+ openai = OpenAI(api_key)
14
  messages = [
15
  {"role": "system", "content": system_message},
16
  {"role": "user", "content": f"Act like a world class market research specialist. I want to promote {product} at {location}. Share a list of segments, potential geographies, decision-makers should target building a GTM strategy. Please give me the output in tabular format. Sort the segments in the decreasing order of the market size & demand"}
 
21
  )
22
  return completion.choices[0].message.content
23
 
24
+ def buyers_persona(api_key, product,location,segment):
25
+ openai = OpenAI(api_key)
26
  messages = [
27
  {"role": "system", "content": system_message},
28
  {"role": "user", "content": f"Act like a World Class market Research Specilaist and do the task. I am selling {product} to {segment} at {location}. Build a Buyers Persona in tabular format classify the information based on Demography, Geo, Psychography, Behavior, also add buying barriers and buying triggers, Keywords they browse, Things they want to change, Their fear, etc."}
 
33
  )
34
  return completion.choices[0].message.content
35
 
36
+ def create_uvp(api_key, product,location,segment,goal,problem,solution):
37
+ openai = OpenAI(api_key)
38
  messages = [
39
  {"role": "system", "content": system_message},
40
  {"role": "user", "content": f"I am selling {product} to {segment} in {location} I want you to act as a Marketing expert specializing in creating unique value propositions for {product} targeted to {segment} Craft a compelling and concise unique value proposition statement under 200 characters that highlights how to achieve {goal} without {problem} by utilizing {solution}."}
 
45
  )
46
  return completion.choices[0].message.content
47
 
48
+ def create_usp(api_key, product,location,segment):
49
+ openai = OpenAI(api_key)
50
  messages = [
51
  {"role": "system", "content": system_message},
52
  {"role": "user", "content": f"My product is {product} selling to {segment} at {location} Please give the list of USPs & Group the USPs under 7Ps of Marketing."}
 
59
 
60
  with gr.Blocks(theme="Ocean", title="Complete GTM Strategy") as ui:
61
 
62
+ api_key_state = gr.State()
63
  with gr.Row():
64
  API=gr.Textbox(label="Enter OpenAI API key")
65
  set_api=gr.Button("Set API key")
66
  showAPI=gr.Text()
67
+ set_api.click(fn=set_openai_api_key, inputs=[API], outputs=[api_key_state,showAPI])
68
 
69
  with gr.Row():
70
  with gr.Column():
 
77
  button1=gr.Button("Generate GTM Strategy")
78
  with gr.Column():
79
  output_text1=gr.Markdown(height=400, max_height=400, show_copy_button=True, label="GTM", show_label=True)
80
+ button1.click(fn=create_gtm, scroll_to_output=True ,inputs=[api_key_state,product,location], outputs=output_text1)
81
 
82
 
83
 
 
90
  button2=gr.Button("Create Buyers Persona")
91
  with gr.Column():
92
  output_text2=gr.Markdown(height=400, max_height=400, show_copy_button=True)
93
+ button2.click(fn=buyers_persona, scroll_to_output=True ,inputs=[api_key_state,product,location,segment], outputs=output_text2)
94
 
95
  with gr.Row():
96
  with gr.Column():
 
103
  button2=gr.Button("Create UVP")
104
  with gr.Column():
105
  output_text2=gr.Markdown(height=200, max_height=200, show_copy_button=True)
106
+ button2.click(fn=create_uvp, scroll_to_output=True ,inputs=[api_key_state,product,location,segment,goal,problem,solution], outputs=output_text2)
107
 
108
  with gr.Row():
109
  with gr.Column():
 
112
  button2=gr.Button("Create USP")
113
  with gr.Column():
114
  output_text2=gr.Markdown(height=400, max_height=400, show_copy_button=True)
115
+ button2.click(fn=create_usp, scroll_to_output=True ,inputs=[api_key_state,product,location,segment], outputs=output_text2)
116
 
117
  ui.launch(inbrowser=True)