victor7246 commited on
Commit
27f61f6
·
verified ·
1 Parent(s): 0cbb043

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +0 -48
utils.py CHANGED
@@ -203,54 +203,6 @@ def translate(llm, user_query, to_translate):
203
 
204
  return pred
205
 
206
- warnings.filterwarnings('ignore', message="pandas only supports SQLAlchemy connectable.*", category=UserWarning, module='chain')
207
-
208
- intermediate_steps_KEY = "intermediate_steps"
209
-
210
- template = """
211
-
212
- You are a database expert. Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer.
213
- The final answer should be in a concise natural language.
214
-
215
- Use the history if you can not understand the question.
216
-
217
- If the question is in another language, translate it to English before proceeding.
218
-
219
- Do not repeat the question while generating the SQL query.
220
-
221
- Only generate a correct {dialect} query.
222
-
223
- Once the SQLResult is available, generate the final answer in natural language format. Do not regenerate the question or SQL query in the final answer.
224
-
225
- If the question asks any information for any particular number of days, use the lookback from the maximum date in the table, not from today's date.
226
-
227
- Please note that MSSQL does not use LIMIT, but uses TOP clause.
228
-
229
- You may also need to resolve the column name, as per the metadata. For instance, if the user asks about families and the column name is family, you should use family in the generated SQL.
230
-
231
- Make sure that the column names are present in the table, by looking at the metadata.
232
-
233
- If a question asks about availability over a period of time, you need to use SUM to calculate the total availability over that time period.
234
-
235
- If a question mentions SKU, then use SKU column for filter, do not use any other column like comodity
236
-
237
- If a question asks about AV of shortage, do not use AV in the SQL query as AV is not a valid column name. AV is the key in the Shortage column.
238
-
239
- In the OpenOrderShotage table, the column Item should be used to extract the part ids, to answer questions related to shortage.
240
-
241
- In the OpenOrderShotage table, Customer_Part_Name column is equivalent to SKU.
242
-
243
- Use the following format:
244
- Question: Question here
245
- SQLQuery: SQL Query to run
246
- SQLResult: Result of the SQLQuery
247
- Answer: Final answer here.
248
-
249
- Only use the following tables:
250
- {table_info}
251
- Question: {input}
252
- """
253
-
254
  def num_tokens_from_string(string: str, encoding_name: str) -> int:
255
  encoding = tiktoken.get_encoding(encoding_name)
256
  num_tokens = len(encoding.encode(string))
 
203
 
204
  return pred
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  def num_tokens_from_string(string: str, encoding_name: str) -> int:
207
  encoding = tiktoken.get_encoding(encoding_name)
208
  num_tokens = len(encoding.encode(string))