Update app.py
Browse files
app.py
CHANGED
@@ -61,7 +61,16 @@ def predict(input, history=[]):
|
|
61 |
else:
|
62 |
# tokenize the new input sentence
|
63 |
new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors='pt')
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
# append the new user input tokens to the chat history
|
66 |
bot_input_ids = torch.cat([torch.LongTensor(history), new_user_input_ids], dim=-1)
|
67 |
|
|
|
61 |
else:
|
62 |
# tokenize the new input sentence
|
63 |
new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors='pt')
|
64 |
+
|
65 |
+
sql_encoding = sql_tokenizer(table=table, query=input + sql_tokenizer.eos_token, return_tensors="pt")
|
66 |
+
sql_outputs = sql_model.generate(**sql_encoding)
|
67 |
+
sql_response = sql_tokenizer.batch_decode(sql_outputs, skip_special_tokens=True)
|
68 |
+
|
69 |
+
# Append the SQL model's response to the history
|
70 |
+
sql_response_ids = tokenizer.encode(sql_response + tokenizer.eos_token, return_tensors='pt')
|
71 |
+
history.extend(sql_response_ids[0].tolist()) # Add SQL response token IDs to history
|
72 |
+
|
73 |
+
|
74 |
# append the new user input tokens to the chat history
|
75 |
bot_input_ids = torch.cat([torch.LongTensor(history), new_user_input_ids], dim=-1)
|
76 |
|