Fixed a SQL-Validity Check
This commit is contained in:
parent
d72a0863a3
commit
9d76648a7d
|
|
@ -6,7 +6,7 @@ class AI:
|
|||
self.api_key = api_key
|
||||
openai.api_key = self.api_key
|
||||
self.convertlog = []
|
||||
self.response = None
|
||||
|
||||
|
||||
def humantosql(self, text: str, dbtype: str, tableschema: list) -> str:
|
||||
if not self.convertlog:
|
||||
|
|
@ -21,18 +21,11 @@ class AI:
|
|||
self.response = self.response['choices'][0]['message']['content']
|
||||
self.convertlog.append({"role": "assistant", "content": self.response})
|
||||
|
||||
for i in self.convertlog:
|
||||
print(i)
|
||||
|
||||
# FIXME: After the first validation failed it will always return None
|
||||
|
||||
print(self.response)
|
||||
|
||||
if self.validate(self.response) is True:
|
||||
return self.response
|
||||
else:
|
||||
self.humantosql("Only answer as a Valid SQL-Statement don't add any additional text", dbtype, tableschema)
|
||||
|
||||
valid = self.humantosql("Only answer as a Valid SQL-Statement don't add any additional text", dbtype, tableschema)
|
||||
return valid
|
||||
|
||||
def decide(self, sql: str) -> str:
|
||||
prompt = [{"role": "system", "content": "You have to decide which function it should use. Answer with [FETCHALL] to fetch all, [FETCHONE] to fetch only one, [FETCHMANY=N] to fetchmany with N being the range, [EXECUTE] to just execute, [EXECUTEMANY=N] to execute many with N being the range"},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user