ShAnSantosh commited on
Commit
f98b4df
1 Parent(s): 9ff91aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -19,19 +19,18 @@ with open('./intents.json', 'r') as json_data:
19
 
20
  FILE = "./data.pth"
21
  data = torch.load(FILE)
22
- model_state = torch.load("chatmodel.pth", map_location=torch.device('cpu'))
23
 
24
  input_size = data["input_size"]
25
  hidden_size = data["hidden_size"]
26
  output_size = data["output_size"]
27
  all_words = data['all_words']
28
  tags = data['tags']
29
- #model_state = data["model_state"]
30
 
31
  model = NeuralNet(input_size, hidden_size, output_size).to(device)
32
  model.load_state_dict(model_state)
33
  model.eval()
34
- #test
35
  def predict(sentence, history):
36
  history = history or []
37
  """
@@ -65,7 +64,9 @@ def predict(sentence, history):
65
  for intent in intents['intents']:
66
  if tag == intent["tag"]:
67
  reply = [random.choice(intent['responses'])]
68
- reply = "Sorry I do not understand :-("
 
 
69
  history.append((sentence, reply))
70
  return history, history
71
 
 
19
 
20
  FILE = "./data.pth"
21
  data = torch.load(FILE)
 
22
 
23
  input_size = data["input_size"]
24
  hidden_size = data["hidden_size"]
25
  output_size = data["output_size"]
26
  all_words = data['all_words']
27
  tags = data['tags']
28
+ model_state = data["model_state"]
29
 
30
  model = NeuralNet(input_size, hidden_size, output_size).to(device)
31
  model.load_state_dict(model_state)
32
  model.eval()
33
+
34
  def predict(sentence, history):
35
  history = history or []
36
  """
 
64
  for intent in intents['intents']:
65
  if tag == intent["tag"]:
66
  reply = [random.choice(intent['responses'])]
67
+ else:
68
+ reply = ["Sorry I do not understand :-("]
69
+
70
  history.append((sentence, reply))
71
  return history, history
72