darshan8950 commited on
Commit
09a4a4b
·
verified ·
1 Parent(s): 5b490c8

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +30 -33
main.py CHANGED
@@ -31,39 +31,36 @@ def recommend():
31
  top_p = 0.95
32
  repetition_penalty = 1.0
33
 
34
- if request.method == 'POST':
35
- content = request.json
36
- user_degree = content.get('degree')
37
- user_stream = content.get('stream')
38
- user_semester = content.get('semester')
39
-
40
- generate_kwargs = dict(
41
- temperature=temperature,
42
- max_new_tokens=max_new_tokens,
43
- top_p=top_p,
44
- repetition_penalty=repetition_penalty,
45
- do_sample=True,
46
- seed=42,
47
- )
48
- prompt = f""" prompt:
49
- You need to act like as recommendation engine for course recommendation for a student based on below details.
50
- Degree: {user_degree}
51
- Stream: {user_stream}
52
- Current Semester: {user_semester}
53
- Based on above details recommend the courses that relate to the above details
54
- Note: Output should be valid json format in below format:
55
- {{"course1:course_name, course2:course_name, course3:course_name,...}}
56
- """
57
- formatted_prompt = format_prompt(prompt)
58
- print(formatted_prompt)
59
- stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
60
- output = ""
61
-
62
- for response in stream:
63
- output += response.token.text
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():