Spaces:
Build error
Build error
ShAnSantosh
commited on
Commit
•
505069b
1
Parent(s):
c7ccbbb
Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,7 @@ model.load_state_dict(model_state)
|
|
33 |
model.eval()
|
34 |
#test
|
35 |
def predict(sentence, history=[]):
|
|
|
36 |
"""
|
37 |
# tokenize the new input sentence
|
38 |
new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors='pt')
|
@@ -48,8 +49,8 @@ def predict(sentence, history=[]):
|
|
48 |
response = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)] # convert to tuples of list
|
49 |
"""
|
50 |
|
51 |
-
|
52 |
-
X = bag_of_words(
|
53 |
X = X.reshape(1, X.shape[0])
|
54 |
X = torch.from_numpy(X).to(device)
|
55 |
|
@@ -64,8 +65,8 @@ def predict(sentence, history=[]):
|
|
64 |
for intent in intents['intents']:
|
65 |
if tag == intent["tag"]:
|
66 |
reply = [random.choice(intent['responses'])]
|
67 |
-
|
68 |
-
return reply
|
69 |
|
70 |
import gradio as gr
|
71 |
|
|
|
33 |
model.eval()
|
34 |
#test
|
35 |
def predict(sentence, history=[]):
|
36 |
+
history =[]
|
37 |
"""
|
38 |
# tokenize the new input sentence
|
39 |
new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors='pt')
|
|
|
49 |
response = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)] # convert to tuples of list
|
50 |
"""
|
51 |
|
52 |
+
sentence1 = tokenize(sentence)
|
53 |
+
X = bag_of_words(sentence1, all_words)
|
54 |
X = X.reshape(1, X.shape[0])
|
55 |
X = torch.from_numpy(X).to(device)
|
56 |
|
|
|
65 |
for intent in intents['intents']:
|
66 |
if tag == intent["tag"]:
|
67 |
reply = [random.choice(intent['responses'])]
|
68 |
+
history.append((sentence, reply))
|
69 |
+
return reply, history
|
70 |
|
71 |
import gradio as gr
|
72 |
|