Update main.py
Browse files
main.py
CHANGED
|
@@ -19,11 +19,6 @@ def format_prompt(message):
|
|
| 19 |
prompt += "</s>"
|
| 20 |
return prompt
|
| 21 |
|
| 22 |
-
def generate_output(stream):
|
| 23 |
-
output = []
|
| 24 |
-
for response in stream:
|
| 25 |
-
output.append(response.token.text)
|
| 26 |
-
return output
|
| 27 |
|
| 28 |
@app.route('/get_course', methods=['POST'])
|
| 29 |
def recommend():
|
|
@@ -56,9 +51,8 @@ def recommend():
|
|
| 56 |
"""
|
| 57 |
formatted_prompt = format_prompt(prompt)
|
| 58 |
|
| 59 |
-
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=
|
| 60 |
-
|
| 61 |
-
return jsonify({"ans": output}))
|
| 62 |
|
| 63 |
@app.route('/get_mentor', methods=['POST'])
|
| 64 |
def mentor():
|
|
@@ -99,9 +93,8 @@ def mentor():
|
|
| 99 |
"""
|
| 100 |
formatted_prompt = format_prompt(prompt)
|
| 101 |
|
| 102 |
-
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=
|
| 103 |
-
|
| 104 |
-
return jsonify({"ans": output}))
|
| 105 |
|
| 106 |
if __name__ == '__main__':
|
| 107 |
app.run(debug=True)
|
|
|
|
| 19 |
prompt += "</s>"
|
| 20 |
return prompt
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
@app.route('/get_course', methods=['POST'])
|
| 24 |
def recommend():
|
|
|
|
| 51 |
"""
|
| 52 |
formatted_prompt = format_prompt(prompt)
|
| 53 |
|
| 54 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=False)
|
| 55 |
+
return jsonify({"ans": stream}))
|
|
|
|
| 56 |
|
| 57 |
@app.route('/get_mentor', methods=['POST'])
|
| 58 |
def mentor():
|
|
|
|
| 93 |
"""
|
| 94 |
formatted_prompt = format_prompt(prompt)
|
| 95 |
|
| 96 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=False)
|
| 97 |
+
return jsonify({"ans": stream}))
|
|
|
|
| 98 |
|
| 99 |
if __name__ == '__main__':
|
| 100 |
app.run(debug=True)
|