Update app.py
Browse files
app.py
CHANGED
@@ -27,9 +27,16 @@ def chat(message,history):
|
|
27 |
inp_dict = {"inputs":user_input,
|
28 |
"parameters": {"max_new_tokens":2000}}
|
29 |
output = query(inp_dict)
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
return formatted_assistant_msg
|
35 |
|
|
|
27 |
inp_dict = {"inputs":user_input,
|
28 |
"parameters": {"max_new_tokens":2000}}
|
29 |
output = query(inp_dict)
|
30 |
+
try:
|
31 |
+
output_text = output[0]['generated_text']
|
32 |
+
formatted_assistant_msg = output_text.replace(chat_history,'').strip().removesuffix('<|end|>')
|
33 |
+
except:
|
34 |
+
if type(output) == dict:
|
35 |
+
formatted_assistant_msg = f"Error has occured, type of output is {type(output)} and keys of output are: {output.keys()}"
|
36 |
+
else:
|
37 |
+
formatted_assistant_msg = f"Error has occured, type of output is {type(output)} and length of output is: {len(output)}"
|
38 |
+
|
39 |
+
|
40 |
|
41 |
return formatted_assistant_msg
|
42 |
|