pratikshahp commited on
Commit
77b3fb2
·
verified ·
1 Parent(s): 7729f7c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from openai import OpenAI
3
+ from dotenv import load_dotenv
4
+ import os
5
+
6
+ # Load API key from .env
7
+ load_dotenv()
8
+ api_key = os.getenv("openai_api_key")
9
+
10
+ client = OpenAI(api_key=api_key)
11
+
12
+ # Function to generate game cards based on job profile
13
+ def generate_game_cards(job_profile):
14
+ system_prompt = f"""Generate a brief, plain-text overview for the career {job_profile}. The output should include:
15
+
16
+ Title: {job_profile}
17
+ Overview: A short description of the role.
18
+ Pros & Cons: List 3-4 key pros and cons.
19
+ Dual Impact Highlights: Summarize how this career affects personal growth (e.g., satisfaction, skill development) and community impact (e.g., societal contributions, local development).
20
+ response should be in a plaintext
21
+ """
22
+ response = client.chat.completions.create(
23
+ model="gpt-4o-mini",
24
+ messages=[{"role": "system", "content": "You are an interactive career card developer."},
25
+ {"role": "user", "content": system_prompt}]
26
+ )
27
+ return response.choices[0].message.content
28
+
29
+ # Gradio UI
30
+ def game_interface(job_profile):
31
+ return generate_game_cards(job_profile)
32
+
33
+ app = gr.Interface(fn=game_interface, inputs=gr.Textbox(label="Enter a Job Profile"),
34
+ outputs=gr.Textbox(label="Game Card Output"),
35
+ title="Career Simulation Game")
36
+
37
+ app.launch()