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