MCPcopy Create free account
hub / github.com/KerwinMai/Multi-Agent-Exp / _generate_sql

Method _generate_sql

agents/sql_agent.py:103–112  ·  view source on GitHub ↗

生成SQL语句

(self, question: str)

Source from the content-addressed store, hash-verified

101 return sql.strip()
102
103 def _generate_sql(self, question: str) -> str:
104 """生成SQL语句"""
105 schema = self._get_schema()
106 prompt = get_few_shot_prompt(
107 question=question,
108 schema=schema,
109 num_examples=self.num_examples
110 )
111 sql = self._llm_to_str(self.llm.invoke(prompt)).strip()
112 return self._clean_sql(sql)
113
114 def _correct_sql(self, question: str, original_sql: str, error_msg: str, attempt: int) -> str:
115 """SQL 自动纠错(Reflection 模式)

Callers 1

queryMethod · 0.95

Calls 4

_get_schemaMethod · 0.95
_llm_to_strMethod · 0.95
_clean_sqlMethod · 0.95
get_few_shot_promptFunction · 0.90

Tested by

no test coverage detected