File size: 2,469 Bytes
1ad68d2
9870b10
 
d4e972e
a2a42d7
9870b10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4e972e
 
 
 
 
 
 
 
 
d56882c
9870b10
 
 
 
 
 
 
 
 
d4e972e
 
 
 
 
9870b10
cd20648
5e95df2
d4e972e
9870b10
 
d4e972e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from openai import OpenAI
import gradio as gr

# Directly use your API key here (for quick testing only)
client = OpenAI(api_key="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")

def generate_career_advice(field, position_name, current_qualifications, likes, skills):
    prompt = f"""You are a career advisor AI. Provide customized career advice using the following details:
    - Desired Career Field: {field}
    - Dream Job: {position_name}
    - Current Qualifications: {current_qualifications}
    - Likes: {likes}
    - Skills: {skills}
    Include:
    - Suitable career paths that are a good fit and in demand.
    - Additional qualifications, courses, training, or certifications to pursue.
    - Tips on networking and gaining experience.
    Be concise and limit your response to 512 tokens or less."""

    try:
        response = client.chat.completions.create(
            model="gpt-4o",
            messages=[
                {"role": "system", "content": "You are a helpful and knowledgeable career advisor."},
                {"role": "user", "content": prompt},
            ],
            max_tokens=512,
            temperature=0.7
        )
        career_advice = response.choices[0].message.content.strip()
    except Exception as e:
        career_advice = f"An error occurred: {str(e)}"

    return career_advice

career_advice_app = gr.Interface(
    fn=generate_career_advice,
    allow_flagging="never",
    inputs=[
        gr.Textbox(label="Desired Career Field", placeholder="e.g., IT, healthcare, trades..."),
        gr.Textbox(label="Your Dream Job", placeholder="e.g., software developer, doctor, plumber..."),
        gr.Textbox(label="Current Qualifications and Certifications", placeholder="e.g., high school, college diploma..."),
        gr.Textbox(label="Likes", placeholder="e.g., helping people, solving puzzles, building things...", lines=2),
        gr.Textbox(label="Skills", placeholder="e.g., math, coding, communication...", lines=2),
    ],
    outputs=gr.Textbox(label="Customized Career Advice", lines=25),
    title="Customized AI-Powered Career Advice",
    description="This app provides AI-powered customized career advice based on your input. Powered by OpenAI GPT-4o. Developed by wn. Disclaimer: AI can make mistakes. Use with caution.",
)

career_advice_app.launch(debug=True, share=True)