(self, query, table_info, limitation, metric, main_metric, suggestion, few_shots,
aggr_type=AggrType.NON_NEEDED)
| 174 | |
| 175 | @self_consistency(args.sc_nums, ["sql"], "each") |
| 176 | def get_sql_by_llm(self, query, table_info, limitation, metric, main_metric, suggestion, few_shots, |
| 177 | aggr_type=AggrType.NON_NEEDED): |
| 178 | |
| 179 | sql_prompt = self.get_generate_sql_prompt() |
| 180 | aggr_prompt = add_aggr_prompt() |
| 181 | |
| 182 | if aggr_type == AggrType.NEEDED: |
| 183 | sql_prompt += aggr_prompt |
| 184 | prompt_dict = { |
| 185 | "query": query, |
| 186 | "table_info": table_info, |
| 187 | "limitation": limitation, |
| 188 | "metric": metric, |
| 189 | "suggestion": suggestion, |
| 190 | "main_metric": main_metric, |
| 191 | "few_shots": few_shots |
| 192 | } |
| 193 | sql_prompt = get_prompt_content(sql_prompt, prompt_dict) |
| 194 | sql = ask_llm(sql_prompt, args.sc_sql_temp) |
| 195 | try: |
| 196 | sql = get_dict_from_str(sql) |
| 197 | print(sql) |
| 198 | except Exception as e: |
| 199 | sql = ask_llm(sql_prompt, args.sc_sql_temp) |
| 200 | print(sql) |
| 201 | print(f"==============={e.args}") |
| 202 | sql = {"sql": "error"} |
| 203 | return sql |
| 204 | |
| 205 | def filter_characters_main(self, features, table_list, table_info_list, mode="cn"): |
| 206 | table_list = [i.lower() for i in table_list] |
no test coverage detected