Spaces:
Running
on
A10G
Running
on
A10G
artificialguybr
commited on
Commit
•
d3cb2df
1
Parent(s):
a12f81f
Update app.py
Browse files
app.py
CHANGED
@@ -64,27 +64,25 @@ def _parse_text(text):
|
|
64 |
# Demo launching function
|
65 |
def _launch_demo(args, model, tokenizer, config):
|
66 |
def predict(_query, _chatbot, _task_history):
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
def regenerate(_chatbot, _task_history):
|
90 |
if not _task_history:
|
|
|
64 |
# Demo launching function
|
65 |
def _launch_demo(args, model, tokenizer, config):
|
66 |
def predict(_query, _chatbot, _task_history):
|
67 |
+
print(f"User: {_parse_text(_query)}")
|
68 |
+
_chatbot.append((_parse_text(_query), ""))
|
69 |
+
|
70 |
+
# Tokenize the input
|
71 |
+
input_ids = tokenizer.encode(_query, return_tensors='pt')
|
72 |
+
|
73 |
+
# Generate a response using the model
|
74 |
+
generated_ids = model.generate(input_ids, max_length=100)
|
75 |
+
|
76 |
+
# Decode the generated IDs to text
|
77 |
+
full_response = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
78 |
+
|
79 |
+
# Update the chatbot state
|
80 |
+
_chatbot[-1] = (_parse_text(_query), _parse_text(full_response))
|
81 |
+
yield _chatbot
|
82 |
+
|
83 |
+
print(f"History: {_task_history}")
|
84 |
+
_task_history.append((_query, full_response))
|
85 |
+
print(f"OpenHermes: {_parse_text(full_response)}")
|
|
|
|
|
86 |
|
87 |
def regenerate(_chatbot, _task_history):
|
88 |
if not _task_history:
|