File size: 3,724 Bytes
77b3fb2
 
 
 
 
84164be
77b3fb2
 
 
 
 
 
ba425c7
84164be
 
29b5547
 
84164be
 
77b3fb2
ba425c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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(JobProfileName):
    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. 
    Add points wherever required.
    Keep the text structured but in simple plain text format.
    """

    user_message = f"""
    Generate a complete set of game cards for the career {JobProfileName}. The output should include the following:
Career Card:
Title: {JobProfileName}
Overview: Provide a brief description explaining the role, responsibilities, and significance of a {JobProfileName}.
Pros & Cons: List 3–4 key pros and cons.
Dual Impact Highlights: Summarize how this career affects personal growth (e.g., satisfaction, skill development) and community impact (e.g., societal contributions, local development).
Level 1 Scenario Cards: (Entry-Level Challenges)
Scenario Card 1:
Title: e.g., 'Initial Challenge 1'
Description: Describe a basic challenge or opportunity typical for an entry-level {JobProfileName}.
Decision Cards:
Option A: Describe an action choice, then include outcomes (e.g., 'Personal Impact: +X, Community Impact: +Y').
Option B: Describe an alternative action choice, then include outcomes (e.g., 'Personal Impact: +A, Community Impact: +B').
Scenario Card 2:
Title: e.g., 'Initial Challenge 2'
Description: Describe a second basic scenario for a beginner-level {JobProfileName}.
Decision Cards:
Option A: Provide an action choice with outcomes (e.g., 'Personal Impact: +X2, Community Impact: +Y2').
Option B: Provide an alternative action choice with outcomes (e.g., 'Personal Impact: +A2, Community Impact: +B2').
Level 2 Scenario Cards: (Advanced-Level Challenges)
Scenario Card 1:
Title: e.g., 'Advanced Challenge 1'
Description: Describe a more complex challenge that a {JobProfileName} might face as responsibilities increase.
Decision Cards:
Option A: Provide an action choice with outcomes (e.g., 'Personal Impact: +X3, Community Impact: +Y3').
Option B: Provide an alternative action choice with outcomes (e.g., 'Personal Impact: +A3, Community Impact: +B3').
Scenario Card 2:
Title: e.g., 'Advanced Challenge 2'
Description: Describe a second complex scenario for an advanced-level {JobProfileName}.
Decision Cards:
Option A: Provide an action choice with outcomes (e.g., 'Personal Impact: +X4, Community Impact: +Y4').
Option B: Provide an alternative action choice with outcomes (e.g., 'Personal Impact: +A4, Community Impact: +B4').
Ensure that the design includes clear labels (such as 'Career Card', 'Level 1 Scenario', 'Level 2 Scenario', 'Decision Card'), along with visual cues like icons for Personal Impact (e.g., a star) and Community Impact (e.g., a group or community icon). The tone should be engaging and accessible for a 12–16-year-old audience.
    """

    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()