Update app.py
Browse files
app.py
CHANGED
|
@@ -162,39 +162,8 @@ def sqlquery(input): #, history=[]):
|
|
| 162 |
for response in enumerate(responses):
|
| 163 |
# Update conversation history
|
| 164 |
conversation_history.append("Bot: " + response)
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
= []
|
| 169 |
-
|
| 170 |
-
for idx, record in enumerate(batch_data):
|
| 171 |
-
# Maintain conversation context by appending history
|
| 172 |
-
if conversation_history:
|
| 173 |
-
history = "\n".join(conversation_history)
|
| 174 |
-
input_text = history + "\nUser: " + record["question"]
|
| 175 |
-
else:
|
| 176 |
-
input_text = "User: " + record["question"]
|
| 177 |
-
|
| 178 |
-
# Tokenize the input text
|
| 179 |
-
tokenized_input = sql_tokenizer.encode(input_text, return_tensors="pt")
|
| 180 |
-
|
| 181 |
-
# Perform inference
|
| 182 |
-
with torch.no_grad():
|
| 183 |
-
output = sql_model.generate(
|
| 184 |
-
input_ids=tokenized_input,
|
| 185 |
-
max_length=1024,
|
| 186 |
-
pad_token_id=sql_tokenizer.eos_token_id,
|
| 187 |
-
)
|
| 188 |
-
|
| 189 |
-
# Decode the output and process the response
|
| 190 |
-
response = sql_tokenizer.decode(output[0], skip_special_tokens=True)
|
| 191 |
-
batch_responses.append(response)
|
| 192 |
-
|
| 193 |
-
# Update conversation history
|
| 194 |
-
conversation_history.append("User: " + record["question"])
|
| 195 |
-
conversation_history.append("Bot: " + response)
|
| 196 |
-
'''
|
| 197 |
-
|
| 198 |
# ==========================================================================
|
| 199 |
|
| 200 |
inputs = [input]
|
|
|
|
| 162 |
for response in enumerate(responses):
|
| 163 |
# Update conversation history
|
| 164 |
conversation_history.append("Bot: " + response)
|
| 165 |
+
'''
|
| 166 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
# ==========================================================================
|
| 168 |
|
| 169 |
inputs = [input]
|