Update main.py
Browse files
main.py
CHANGED
|
@@ -31,39 +31,36 @@ def recommend():
|
|
| 31 |
top_p = 0.95
|
| 32 |
repetition_penalty = 1.0
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
return jsonify({"ans": output})
|
| 65 |
-
else:
|
| 66 |
-
return jsonify({"error": "Invalid request method"})
|
| 67 |
|
| 68 |
@app.route('/get_mentor', methods=['POST'])
|
| 69 |
def mentor():
|
|
|
|
| 31 |
top_p = 0.95
|
| 32 |
repetition_penalty = 1.0
|
| 33 |
|
| 34 |
+
content = request.json
|
| 35 |
+
user_degree = content.get('degree')
|
| 36 |
+
user_stream = content.get('stream')
|
| 37 |
+
user_semester = content.get('semester')
|
| 38 |
+
|
| 39 |
+
generate_kwargs = dict(
|
| 40 |
+
temperature=temperature,
|
| 41 |
+
max_new_tokens=max_new_tokens,
|
| 42 |
+
top_p=top_p,
|
| 43 |
+
repetition_penalty=repetition_penalty,
|
| 44 |
+
do_sample=True,
|
| 45 |
+
seed=42,
|
| 46 |
+
)
|
| 47 |
+
prompt = f""" prompt:
|
| 48 |
+
You need to act like as recommendation engine for course recommendation for a student based on below details.
|
| 49 |
+
Degree: {user_degree}
|
| 50 |
+
Stream: {user_stream}
|
| 51 |
+
Current Semester: {user_semester}
|
| 52 |
+
Based on above details recommend the courses that relate to the above details
|
| 53 |
+
Note: Output should be valid json format in below format:
|
| 54 |
+
{{"course1:course_name, course2:course_name, course3:course_name,...}}
|
| 55 |
+
"""
|
| 56 |
+
formatted_prompt = format_prompt(prompt)
|
| 57 |
+
print(formatted_prompt)
|
| 58 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 59 |
+
output = ""
|
| 60 |
+
|
| 61 |
+
for response in stream:
|
| 62 |
+
output += response.token.text
|
| 63 |
+
return jsonify({"ans": output})
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
@app.route('/get_mentor', methods=['POST'])
|
| 66 |
def mentor():
|