MCPcopy Create free account
hub / github.com/FlyingFeather/DEA-SQL / get_features_by_llm

Method get_features_by_llm

gen_sql.py:87–120  ·  view source on GitHub ↗
(self, query, table_info, limitation, metric, main_metric, mode="en")

Source from the content-addressed store, hash-verified

85 self.sql_prompt_error = SQLPromptError()
86
87 def get_features_by_llm(self, query, table_info, limitation, metric, main_metric, mode="en"):
88 numbers = len(limitation.split(","))
89 entities = limitation.split(",")
90 if self.filter_characters_mode == FilterType.COMPLEX.value:
91 features_prompt = (get_features_prompt() if mode == 'en' else get_features_prompt_cn())
92 output_format = json.dumps(generate_dictionary_for_complex(entities))
93 prompt_dict = {
94 "query": query,
95 "table_info": table_info,
96 "limitation": limitation,
97 # "metric": metric,
98 "main_metric": main_metric,
99 "numbers": numbers,
100 "output_format": output_format
101 }
102 else:
103 features_prompt = get_features_prompt_simple()
104 output_format = json.dumps(generate_dictionary(entities))
105 prompt_dict = {
106 "table_info": table_info,
107 # "metric": metric,
108 "limitation": limitation,
109 "numbers": numbers,
110 "output_format": output_format
111 }
112 features_prompt = get_prompt_content(features_prompt, prompt_dict)
113 features = ask_llm(features_prompt, args.sc_filter_temp)
114 try:
115 features = get_dict_from_str(features)
116 except Exception as e:
117 print(f"==============={features}")
118 print(f"==============={e.args}")
119 features = ""
120 return features
121
122 @self_consistency(args.sc_nums_question_label, ["question_type"], "all")
123 def get_question_type(self, query, table_info):

Callers 1

step_get_filter_infosMethod · 0.95

Calls 8

get_features_promptFunction · 0.90
get_features_prompt_cnFunction · 0.90
get_prompt_contentFunction · 0.90
ask_llmFunction · 0.90
get_dict_from_strFunction · 0.90
generate_dictionaryFunction · 0.85

Tested by

no test coverage detected