darshan8950 commited on
Commit
10f9ea6
·
verified ·
1 Parent(s): dfb07ba

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -11
main.py CHANGED
@@ -13,13 +13,9 @@ with open(file_path, "r") as file:
13
  def home():
14
  return jsonify({"message": "Welcome to the Recommendation API!"})
15
 
16
- def format_prompt(message, history):
17
- prompt = "<s>"
18
- for user_prompt, bot_response in history:
19
- prompt += f"[INST] {user_prompt} [/INST]"
20
- prompt += f" {bot_response}</s> "
21
- prompt += f"[INST] {message} [/INST]"
22
- return prompt
23
 
24
  @app.route('/get_course', methods=['POST'])
25
  def recommend():
@@ -27,7 +23,7 @@ def recommend():
27
  max_new_tokens = 256
28
  top_p = 0.95
29
  repetition_penalty = 1.0
30
- history=history
31
 
32
  content = request.json
33
  user_degree = content.get('degree')
@@ -51,7 +47,7 @@ def recommend():
51
  Note: Output should be valid json format in below format:
52
  {{"course1:course_name, course2:course_name, course3:course_name,...}}
53
  """
54
- formatted_prompt = format_prompt(prompt,history)
55
 
56
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=True)
57
  return jsonify({"ans": stream})
@@ -62,7 +58,6 @@ def mentor():
62
  max_new_tokens = 256
63
  top_p = 0.95
64
  repetition_penalty = 1.0
65
- history=history
66
 
67
  content = request.json
68
  user_degree = content.get('degree')
@@ -94,7 +89,7 @@ def mentor():
94
  Note: Output should be valid json format in below format:
95
  {{"mentor1:mentor_name,mentor2:mentor_name,mentor3:mentor_name,...}}
96
  """
97
- formatted_prompt = format_prompt(prompt,history)
98
 
99
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=True)
100
  return jsonify({"ans": stream})
 
13
  def home():
14
  return jsonify({"message": "Welcome to the Recommendation API!"})
15
 
16
+ def format_prompt(message):
17
+ return f"<s>[INST] {message} [/INST]</s>"
18
+
 
 
 
 
19
 
20
  @app.route('/get_course', methods=['POST'])
21
  def recommend():
 
23
  max_new_tokens = 256
24
  top_p = 0.95
25
  repetition_penalty = 1.0
26
+
27
 
28
  content = request.json
29
  user_degree = content.get('degree')
 
47
  Note: Output should be valid json format in below format:
48
  {{"course1:course_name, course2:course_name, course3:course_name,...}}
49
  """
50
+ formatted_prompt = format_prompt(prompt)
51
 
52
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=True)
53
  return jsonify({"ans": stream})
 
58
  max_new_tokens = 256
59
  top_p = 0.95
60
  repetition_penalty = 1.0
 
61
 
62
  content = request.json
63
  user_degree = content.get('degree')
 
89
  Note: Output should be valid json format in below format:
90
  {{"mentor1:mentor_name,mentor2:mentor_name,mentor3:mentor_name,...}}
91
  """
92
+ formatted_prompt = format_prompt(prompt)
93
 
94
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=True)
95
  return jsonify({"ans": stream})