Spaces:
Runtime error
Runtime error
Commit
·
8cc0ab8
1
Parent(s):
3430dd6
Update app.py
Browse files
app.py
CHANGED
@@ -50,7 +50,7 @@ def load_demo_refresh_model_list(request: gr.Request):
|
|
50 |
state = default_conversation.copy()
|
51 |
dropdown_update = gr.Dropdown.update(
|
52 |
choices=models,
|
53 |
-
value=models[0] if len(models) > 0 else ""
|
54 |
)
|
55 |
return state, dropdown_update
|
56 |
|
@@ -183,27 +183,27 @@ def http_bot(state, model_selector, temperature, top_p, max_new_tokens, request:
|
|
183 |
yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
|
184 |
|
185 |
|
186 |
-
|
187 |
# Stream output
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
|
208 |
state.messages[-1][-1] = state.messages[-1][-1][:-1]
|
209 |
yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
|
@@ -372,6 +372,8 @@ if __name__ == "__main__":
|
|
372 |
model_name = args.model_name
|
373 |
|
374 |
models = [model_name]
|
|
|
|
|
375 |
chat = Chat(
|
376 |
args.model_path,
|
377 |
args.model_base,
|
|
|
50 |
state = default_conversation.copy()
|
51 |
dropdown_update = gr.Dropdown.update(
|
52 |
choices=models,
|
53 |
+
value=models[0]+"-4bit" if len(models) > 0 else ""
|
54 |
)
|
55 |
return state, dropdown_update
|
56 |
|
|
|
183 |
yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
|
184 |
|
185 |
|
186 |
+
try:
|
187 |
# Stream output
|
188 |
+
response = chat.generate_stream_gate(pload)
|
189 |
+
for chunk in response:
|
190 |
+
if chunk:
|
191 |
+
data = json.loads(chunk.decode())
|
192 |
+
if data["error_code"] == 0:
|
193 |
+
output = data["text"][len(prompt):].strip()
|
194 |
+
state.messages[-1][-1] = output + "▌"
|
195 |
+
yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
|
196 |
+
else:
|
197 |
+
output = data["text"] + f" (error_code: {data['error_code']})"
|
198 |
+
state.messages[-1][-1] = output
|
199 |
+
yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
|
200 |
+
return
|
201 |
+
time.sleep(0.03)
|
202 |
+
except Exception:
|
203 |
+
gr.Warning(server_error_msg)
|
204 |
+
state.messages[-1][-1] = server_error_msg
|
205 |
+
yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
|
206 |
+
return
|
207 |
|
208 |
state.messages[-1][-1] = state.messages[-1][-1][:-1]
|
209 |
yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
|
|
|
372 |
model_name = args.model_name
|
373 |
|
374 |
models = [model_name]
|
375 |
+
args.load_4bit = True
|
376 |
+
|
377 |
chat = Chat(
|
378 |
args.model_path,
|
379 |
args.model_base,
|