Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -211,7 +211,6 @@ def get_streams():
|
|
211 |
top_p = 0.95
|
212 |
repetition_penalty = 1.0
|
213 |
|
214 |
-
|
215 |
generate_kwargs = dict(
|
216 |
temperature=temperature,
|
217 |
max_new_tokens=max_new_tokens,
|
@@ -220,17 +219,25 @@ def get_streams():
|
|
220 |
do_sample=True,
|
221 |
seed=42,
|
222 |
)
|
223 |
-
|
224 |
-
You need to act
|
225 |
-
List all 40+ streams/branches in
|
226 |
-
Note:
|
227 |
-
[
|
228 |
-
Return only
|
229 |
-
|
230 |
formatted_prompt = format_prompt(prompt)
|
231 |
|
232 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=False, return_full_text=False)
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
|
236 |
@app.route('/get_education_profiles', methods=['GET'])
|
|
|
211 |
top_p = 0.95
|
212 |
repetition_penalty = 1.0
|
213 |
|
|
|
214 |
generate_kwargs = dict(
|
215 |
temperature=temperature,
|
216 |
max_new_tokens=max_new_tokens,
|
|
|
219 |
do_sample=True,
|
220 |
seed=42,
|
221 |
)
|
222 |
+
|
223 |
+
prompt = """You need to act as a recommendation engine.
|
224 |
+
List all 40+ streams/branches in computer science, chemical engineering, aerospace engineering, etc.
|
225 |
+
Note: The output should be a valid JSON list in the format:
|
226 |
+
["Artificial Intelligence", "Computer Science", "Data Science", "Cyber Security", ...]
|
227 |
+
Return only the list, no additional text, and ensure it is properly formatted as JSON."""
|
228 |
+
|
229 |
formatted_prompt = format_prompt(prompt)
|
230 |
|
231 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=False, return_full_text=False)
|
232 |
+
|
233 |
+
# Ensure the response is correctly formatted as a JSON list
|
234 |
+
try:
|
235 |
+
stream_list = json.loads(stream) # Convert string to list
|
236 |
+
except json.JSONDecodeError:
|
237 |
+
return jsonify({"error": "Invalid response format"}), 500
|
238 |
+
|
239 |
+
return jsonify({"ans": stream_list})
|
240 |
+
|
241 |
|
242 |
|
243 |
@app.route('/get_education_profiles', methods=['GET'])
|