Spaces:
Running
Running
Commit
•
caa4027
1
Parent(s):
eaaed33
Update app.py
Browse files
app.py
CHANGED
@@ -26,15 +26,17 @@ def get_chat_response(name, input_txt = "Hello , what is your name?"):
|
|
26 |
#and also gives character sense if of his/her/its name!
|
27 |
personality = "My name is " + name
|
28 |
|
|
|
|
|
|
|
|
|
29 |
##can respond well to history as well but for this quick demo not implemented
|
30 |
##see metayazar.com/chatbot for a min 2 history
|
31 |
|
32 |
##this is a multi-speaker model, currently no history, so ending with "<speaker2>" to get response. depends on who starts conversation it can be speaker1
|
33 |
##if there is a history depends on who started conversation it should end with <speaker1>
|
34 |
#historical implementation not implemented in this demo
|
35 |
-
|
36 |
-
|
37 |
-
bot_input_ids = tokenizer.encode(tokenizer.bos_token + personality + "<speaker1>" + input_txt + tokenizer.eos_token , return_tensors='pt')
|
38 |
|
39 |
#optimum response and speed
|
40 |
#50 token max length, temperature = 1.3 makes it creative
|
|
|
26 |
#and also gives character sense if of his/her/its name!
|
27 |
personality = "My name is " + name
|
28 |
|
29 |
+
if input_txt[:-1] != ".":
|
30 |
+
#add a dot after sentence to make model understand it more clearly
|
31 |
+
input_txt = input_txt + "."
|
32 |
+
|
33 |
##can respond well to history as well but for this quick demo not implemented
|
34 |
##see metayazar.com/chatbot for a min 2 history
|
35 |
|
36 |
##this is a multi-speaker model, currently no history, so ending with "<speaker2>" to get response. depends on who starts conversation it can be speaker1
|
37 |
##if there is a history depends on who started conversation it should end with <speaker1>
|
38 |
#historical implementation not implemented in this demo
|
39 |
+
bot_input_ids = tokenizer.encode(tokenizer.bos_token + personality + "<speaker1>" + input_txt + tokenizer.eos_token , return_tensors='pt')
|
|
|
|
|
40 |
|
41 |
#optimum response and speed
|
42 |
#50 token max length, temperature = 1.3 makes it creative
|