Update app.py
Browse files
app.py
CHANGED
@@ -58,7 +58,7 @@ Generate a detailed JSON object representing a career card for a {career}. The J
|
|
58 |
- "ModerateImage": "images/careers/{career}/moderate_{career}.jpg",
|
59 |
- "Retry": Message for a **low score** (e.g., "Your journey ends here… but you can try again!").
|
60 |
- "RetryImage": "images/careers/{career}/retry_{career}.jpg",
|
61 |
-
- "Quit":
|
62 |
- "QuitImage": "images/careers/{career}/game_over.jpg",
|
63 |
Ensure the JSON is properly formatted and adheres to the structure exactly. Generate unique and creative responses for each section while maintaining consistency across different careers and all three gender representations.
|
64 |
"""
|
@@ -114,21 +114,22 @@ def generate_career_profile(career, job_category, gender):
|
|
114 |
with open(file_path, "w", encoding="utf-8") as f:
|
115 |
json.dump(career_profile, f, indent=4)
|
116 |
|
117 |
-
|
|
|
118 |
|
119 |
except json.JSONDecodeError:
|
120 |
return "Error: Failed to parse OpenAI response into JSON."
|
121 |
|
122 |
return "Error: OpenAI API response did not contain the expected content."
|
123 |
|
124 |
-
# Define the Gradio interface
|
125 |
iface = gr.Interface(
|
126 |
fn=generate_career_profile,
|
127 |
inputs=[
|
128 |
gr.Textbox(label="Job Profile Name"),
|
129 |
gr.Dropdown(
|
130 |
label="Job Category",
|
131 |
-
choices=["Education", "Technology", "Healthcare", "Hospitality", "Finance", "Marketing", "Engineering", "Arts and Design", "Legal", "Science and Research","Civil Services"],
|
132 |
type="value",
|
133 |
),
|
134 |
gr.Dropdown(
|
@@ -137,7 +138,7 @@ iface = gr.Interface(
|
|
137 |
type="value",
|
138 |
),
|
139 |
],
|
140 |
-
outputs=gr.
|
141 |
live=False
|
142 |
)
|
143 |
|
|
|
58 |
- "ModerateImage": "images/careers/{career}/moderate_{career}.jpg",
|
59 |
- "Retry": Message for a **low score** (e.g., "Your journey ends here… but you can try again!").
|
60 |
- "RetryImage": "images/careers/{career}/retry_{career}.jpg",
|
61 |
+
- "Quit": "Game Over!",
|
62 |
- "QuitImage": "images/careers/{career}/game_over.jpg",
|
63 |
Ensure the JSON is properly formatted and adheres to the structure exactly. Generate unique and creative responses for each section while maintaining consistency across different careers and all three gender representations.
|
64 |
"""
|
|
|
114 |
with open(file_path, "w", encoding="utf-8") as f:
|
115 |
json.dump(career_profile, f, indent=4)
|
116 |
|
117 |
+
# Return the file path so that Gradio displays a downloadable file.
|
118 |
+
return file_path
|
119 |
|
120 |
except json.JSONDecodeError:
|
121 |
return "Error: Failed to parse OpenAI response into JSON."
|
122 |
|
123 |
return "Error: OpenAI API response did not contain the expected content."
|
124 |
|
125 |
+
# Define the Gradio interface with a file output for download
|
126 |
iface = gr.Interface(
|
127 |
fn=generate_career_profile,
|
128 |
inputs=[
|
129 |
gr.Textbox(label="Job Profile Name"),
|
130 |
gr.Dropdown(
|
131 |
label="Job Category",
|
132 |
+
choices=["Education", "Technology", "Healthcare", "Hospitality", "Finance", "Marketing", "Engineering", "Arts and Design", "Legal", "Science and Research", "Civil Services"],
|
133 |
type="value",
|
134 |
),
|
135 |
gr.Dropdown(
|
|
|
138 |
type="value",
|
139 |
),
|
140 |
],
|
141 |
+
outputs=gr.File(label="Career Profile JSON"),
|
142 |
live=False
|
143 |
)
|
144 |
|