Spaces:
Build error
Build error
Quyet
commited on
Commit
·
9dd44ac
1
Parent(s):
342c3ab
fix bug
Browse files
app.py
CHANGED
@@ -180,13 +180,14 @@ model.eval()
|
|
180 |
def chat(message, history):
|
181 |
history = history or []
|
182 |
eos = tokenizer.eos_token
|
183 |
-
input_str = eos.join([
|
184 |
|
185 |
bot_input_ids = tokenizer.encode(input_str, return_tensors='pt')
|
186 |
bot_output_ids = model.generate(bot_input_ids,
|
187 |
-
max_length=1000,
|
|
|
188 |
pad_token_id=tokenizer.eos_token_id)
|
189 |
-
|
190 |
skip_special_tokens=True)
|
191 |
|
192 |
history.append((message, response))
|
@@ -205,6 +206,6 @@ if __name__ == '__main__':
|
|
205 |
allow_screenshot=False,
|
206 |
allow_flagging="never",
|
207 |
title=title,
|
208 |
-
description=description
|
209 |
)
|
210 |
-
iface.launch(debug=True)
|
|
|
180 |
def chat(message, history):
|
181 |
history = history or []
|
182 |
eos = tokenizer.eos_token
|
183 |
+
input_str = eos.join([x for turn in history for x in turn] + [message])
|
184 |
|
185 |
bot_input_ids = tokenizer.encode(input_str, return_tensors='pt')
|
186 |
bot_output_ids = model.generate(bot_input_ids,
|
187 |
+
max_length=1000,
|
188 |
+
do_sample=True, top_p=0.9, temperature=0.8,
|
189 |
pad_token_id=tokenizer.eos_token_id)
|
190 |
+
response = tokenizer.decode(bot_output_ids[:, bot_input_ids.shape[-1]:][0],
|
191 |
skip_special_tokens=True)
|
192 |
|
193 |
history.append((message, response))
|
|
|
206 |
allow_screenshot=False,
|
207 |
allow_flagging="never",
|
208 |
title=title,
|
209 |
+
description=description,
|
210 |
)
|
211 |
+
iface.launch(debug=True, server_name="0.0.0.0", server_port=2022, share=True)
|