Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ from openai import OpenAI
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
# Load API key
|
| 7 |
load_dotenv()
|
| 8 |
api_key = os.getenv("openai_api_key")
|
| 9 |
|
|
@@ -11,18 +11,26 @@ 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
"""
|
|
|
|
| 22 |
response = client.chat.completions.create(
|
| 23 |
model="gpt-4o-mini",
|
| 24 |
-
messages=[
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
)
|
| 27 |
return response.choices[0].message.content
|
| 28 |
|
|
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
# Load API key
|
| 7 |
load_dotenv()
|
| 8 |
api_key = os.getenv("openai_api_key")
|
| 9 |
|
|
|
|
| 11 |
|
| 12 |
# Function to generate game cards based on job profile
|
| 13 |
def generate_game_cards(job_profile):
|
| 14 |
+
system_message = """You are an interactive career card developer.
|
| 15 |
+
Generate a plain-text game card for any career.
|
| 16 |
+
The response should NOT contain Markdown formatting, asterisks, or bullet points.
|
| 17 |
+
Keep the text structured but in simple plain text format.
|
| 18 |
+
"""
|
| 19 |
|
| 20 |
+
user_message = f"""Provide a game card for the career: {job_profile}.
|
| 21 |
+
Include:
|
| 22 |
+
- Title: The job title.
|
| 23 |
+
- Overview: A short description of the role.
|
| 24 |
+
- Pros & Cons: List 3-4 key pros and cons in full sentences.
|
| 25 |
+
- Dual Impact Highlights: Explain how this career affects personal growth (skills, satisfaction) and community impact (society, economy).
|
| 26 |
"""
|
| 27 |
+
|
| 28 |
response = client.chat.completions.create(
|
| 29 |
model="gpt-4o-mini",
|
| 30 |
+
messages=[
|
| 31 |
+
{"role": "system", "content": system_message}, # System instructions
|
| 32 |
+
{"role": "user", "content": user_message} # User query with job details
|
| 33 |
+
]
|
| 34 |
)
|
| 35 |
return response.choices[0].message.content
|
| 36 |
|