File size: 1,581 Bytes
77b3fb2
 
 
 
 
84164be
77b3fb2
 
 
 
 
 
 
84164be
 
 
 
 
77b3fb2
84164be
 
 
 
 
 
77b3fb2
84164be
77b3fb2
 
84164be
 
 
 
77b3fb2
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from openai import OpenAI
from dotenv import load_dotenv
import os

# Load API key
load_dotenv()
api_key = os.getenv("openai_api_key")

client = OpenAI(api_key=api_key)

# Function to generate game cards based on job profile
def generate_game_cards(job_profile):
    system_message = """You are an interactive career card developer. 
    Generate a plain-text game card for any career. 
    The response should NOT contain Markdown formatting, asterisks, or bullet points. 
    Keep the text structured but in simple plain text format.
    """

    user_message = f"""Provide a game card for the career: {job_profile}. 
    Include:
    - Title: The job title.
    - Overview: A short description of the role.
    - Pros & Cons: List 3-4 key pros and cons in full sentences.
    - Dual Impact Highlights: Explain how this career affects personal growth (skills, satisfaction) and community impact (society, economy).
    """

    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {"role": "system", "content": system_message},  # System instructions
            {"role": "user", "content": user_message}  # User query with job details
        ]
    )
    return response.choices[0].message.content

# Gradio UI
def game_interface(job_profile):
    return generate_game_cards(job_profile)

app = gr.Interface(fn=game_interface, inputs=gr.Textbox(label="Enter a Job Profile"), 
                    outputs=gr.Textbox(label="Game Card Output"),
                    title="Career Simulation Game")

app.launch()