willn9 commited on
Commit
4d92904
·
verified ·
1 Parent(s): 76a508c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -27
app.py CHANGED
@@ -7,51 +7,55 @@ import gradio as gr
7
  # Set OpenAI API key from environment variable
8
 
9
  # Function to generate customized career advice
10
- def generate_career_advice(field, position_name, current_qualifications, likes, skills):
11
  # Craft the prompt for the OpenAI model
12
- prompt = f"""You are a career advisor AI. Provide customized career advice using the following details:
13
- - Desired Career Field: {field}
14
- - Dream Job: {position_name}
15
- - Current Qualifications: {current_qualifications}
16
- - Likes: {likes}
17
- - Skills: {skills}
 
 
 
18
  Include:
19
- - Suitable career paths that are a good fit and in demand.
20
- - Additional qualifications, courses, training, or certifications to pursue.
21
- - Tips on networking and gaining experience.
22
  Be concise and limit your response to 512 tokens or less."""
23
 
24
  # Call the OpenAI API
25
  try:
26
- response = client.chat.completions.create(model="gpt-3.5-turbo", # Use "gpt-4" if desired
27
  messages=[
28
- {"role": "system", "content": "You are a helpful and knowledgeable career advisor."},
29
  {"role": "user", "content": prompt},
30
  ],
31
  max_tokens=512,
32
  temperature=0.7)
33
  # Extract the response text
34
- career_advice = response.choices[0].message.content.strip()
35
  except Exception as e:
36
- career_advice = f"An error occurred: {str(e)}"
37
 
38
- return career_advice
39
 
40
- # Create Gradio interface for the career advice application
41
- career_advice_app = gr.Interface(
42
- fn=generate_career_advice,
43
  allow_flagging="never",
44
  inputs=[
45
- gr.Textbox(label="Desired Career Field", placeholder="Enter the field you're interested in (e.g., healthcare, trades, IT, ...) or type 'not sure'."),
46
- gr.Textbox(label="Your Dream Job", placeholder="Enter your dream job (e.g., software developer, plumber, digital marketing specialist, ...) or type 'not sure'."),
47
- gr.Textbox(label="Current Qualifications and Certifications", placeholder="Enter your qualifications (e.g., studying at high school, college business diploma, ...)"),
48
- gr.Textbox(label="Likes", placeholder="Enter things you like (e.g., helping people, working with my hands, solving puzzels, caring for animals, building things, etc.)", lines=2),
49
- gr.Textbox(label="Skills", placeholder="Enter your skills (e.g., math, science, languages, working with tools, ...)", lines=2),
 
50
  ],
51
- outputs=gr.Textbox(label="Customized Career Advice"),
52
- title="Customized AI-Powered Career Advice",
53
- description="This app provides AI-powered customized career advice based on your input. Note: even AI can make mistakes!",
54
  )
55
 
56
  # Launch the application
57
- career_advice_app.launch(server_name="0.0.0.0", debug=True, share=True)
 
7
  # Set OpenAI API key from environment variable
8
 
9
  # Function to generate customized career advice
10
+ def generate_kewords(customer_profile, pain_points, customer_wishes, brand_name, solution_benefits, differentiators):
11
  # Craft the prompt for the OpenAI model
12
+ prompt = f"""You are an experienced digital marketing specialist AI.
13
+ Provide customized keyword recommendations for a producer or service provider, owner of the brand listed below,
14
+ who wishes to market their product online using Google Search Ads, using the following details:
15
+ - Customer profile and what task or job they are trying to do: {customer_profile}
16
+ - Problems and pain points that customers are currently facing while doing this task: {pain_points}
17
+ - Customer needs and what they wish the solution (product or service) would have to make their lives easier: {customer_wishes}
18
+ - Brand name (suggest a brand name and a slogan if the user don't yet have them): {brand_name}
19
+ - What does your solution (product or service) offer to solve their problems, relieve their pain points and meet or exceed their wishes: {solution_benefits}
20
+ - What differentiates your solution for existing competitor offerings: {differentiators}
21
  Include:
22
+ - 3 options for a catchy headline for a Google Search Ad.
23
+ - 3 options for Google Search Ad description each to match the above headline.
24
+ - 15 Recommended keywords to use in Google Search Ad.
25
  Be concise and limit your response to 512 tokens or less."""
26
 
27
  # Call the OpenAI API
28
  try:
29
+ response = client.chat.completions.create(model="gpt-4 # Use "gpt-3.5-turbo" if desired
30
  messages=[
31
+ {"role": "system", "content": "You are a helpful and knowledgeable digital marketing strategist."},
32
  {"role": "user", "content": prompt},
33
  ],
34
  max_tokens=512,
35
  temperature=0.7)
36
  # Extract the response text
37
+ keyword_advice = response.choices[0].message.content.strip()
38
  except Exception as e:
39
+ keyword_advice = f"An error occurred: {str(e)}"
40
 
41
+ return keyword_advice
42
 
43
+ # Create Gradio interface for the keyworder application
44
+ keyworder_app = gr.Interface(
45
+ fn=generate_kewords,
46
  allow_flagging="never",
47
  inputs=[
48
+ gr.Textbox(label="Customer Profile", placeholder="Describe your customer and what task or job they are trying to do. (e.g., My customer is a busy executive on the go. They have a pet whom they love dearly. They want to make sure that their pet is always taken care of even when they are busy or delayed at work.).", lines=2),
49
+ gr.Textbox(label="Customer Pain Points", placeholder="Identify problems and pain points that your customers are currently facing while they are trying to accomplish the above task. (e.g., Sometimes, they are held up late at work or by traffic. They are worried about their pets and feel guilty.)", lines=2),
50
+ gr.Textbox(label="Customer Needs and Wishes", placeholder="Describe your customers' needs and wishes (e.g., They need someone reliable to check on their pets, walk them, ensure that that they have food and water, etc. They wish they could see their pets, make sure they are OK and say hi to them via their phones.).", lines=2),
51
+ gr.Textbox(label="Brand Name", placeholder="List your brand name and slogan. (e.g., InstaPet, where you are always with your pet.) or enter don't have them yet please suggest.", lines=2),
52
+ gr.Textbox(label="Benefits of your Solution", placeholder="Enter key benefits that your product or service offers to solve customer problems (e.g., You can always rely on our network of pet lovers to care for your pet while you are held up at work or other commitments!)", lines=2),
53
+ gr.Textbox(label="Differentiators", placeholder="List what differentiate you from the competition (e.g., Our pet-care-providers love pets and will help you say hi to your pet via our secure network.)", lines=2),
54
  ],
55
+ outputs=gr.Textbox(label="Customized Digital Marketing Advice"),
56
+ title="AI-Powered Keyworder, by wn",
57
+ description="This app provides customized digital marketing advice based on your input. Powered by AI and domain knowledge expertise! Caution: even AI can make mistakes!",
58
  )
59
 
60
  # Launch the application
61
+ keyworder_app.launch(server_name="0.0.0.0", debug=True, share=True)