Update main.py
Browse files
main.py
CHANGED
@@ -20,10 +20,10 @@ def format_prompt(message):
|
|
20 |
return prompt
|
21 |
|
22 |
def generate_output(stream):
|
23 |
-
output =
|
24 |
for response in stream:
|
25 |
-
output
|
26 |
-
|
27 |
|
28 |
@app.route('/get_course', methods=['POST'])
|
29 |
def recommend():
|
@@ -57,7 +57,8 @@ def recommend():
|
|
57 |
formatted_prompt = format_prompt(prompt)
|
58 |
|
59 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
60 |
-
|
|
|
61 |
|
62 |
@app.route('/get_mentor', methods=['POST'])
|
63 |
def mentor():
|
@@ -99,7 +100,8 @@ def mentor():
|
|
99 |
formatted_prompt = format_prompt(prompt)
|
100 |
|
101 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
102 |
-
|
|
|
103 |
|
104 |
if __name__ == '__main__':
|
105 |
app.run(debug=True)
|
|
|
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():
|
|
|
57 |
formatted_prompt = format_prompt(prompt)
|
58 |
|
59 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
60 |
+
output = generate_output(stream)
|
61 |
+
return jsonify({"ans": output}))
|
62 |
|
63 |
@app.route('/get_mentor', methods=['POST'])
|
64 |
def mentor():
|
|
|
100 |
formatted_prompt = format_prompt(prompt)
|
101 |
|
102 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
103 |
+
output = generate_output(stream)
|
104 |
+
return jsonify({"ans": output}))
|
105 |
|
106 |
if __name__ == '__main__':
|
107 |
app.run(debug=True)
|