Spaces:
Sleeping
Sleeping
File size: 1,379 Bytes
77b3fb2 dce8793 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 |
import gradio as gr
from openai import OpenAI
from dotenv import load_dotenv
import os
# Load API key from .env
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_prompt = f"""Generate a complete set of game cards for the career {job_profile}. The output should include the following:
Title: {job_profile}
Overview: A short description of the role.
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).
response should be in a plaintext
"""
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "system", "content": "You are an interactive career card developer."},
{"role": "user", "content": system_prompt}]
)
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()
|