Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,10 +37,13 @@ def generate_response(message, history):
|
|
| 37 |
|
| 38 |
with torch.no_grad():
|
| 39 |
text = model.generate(**inputs, max_new_tokens=256, do_sample=False)
|
| 40 |
-
start =
|
| 41 |
-
end =
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
chatbot = gr.ChatInterface(
|
| 45 |
fn=generate_response,
|
| 46 |
title="Simple ZeroGPU Chatbot",
|
|
|
|
| 37 |
|
| 38 |
with torch.no_grad():
|
| 39 |
text = model.generate(**inputs, max_new_tokens=256, do_sample=False)
|
| 40 |
+
start = full_output.find('<|object_ref_end|>') + len('<|object_ref_end|>')
|
| 41 |
+
end = full_output.find('<|box_end|>')
|
| 42 |
+
if end == -1: # اگر <|box_end|> پیدا نشد
|
| 43 |
+
result = full_output[start:]
|
| 44 |
+
else:
|
| 45 |
+
result = full_output[start:end]
|
| 46 |
+
return result
|
| 47 |
chatbot = gr.ChatInterface(
|
| 48 |
fn=generate_response,
|
| 49 |
title="Simple ZeroGPU Chatbot",
|