diff --git a/nogui/modules/aisql.py b/nogui/modules/aisql.py index 0442d45..07352d6 100644 --- a/nogui/modules/aisql.py +++ b/nogui/modules/aisql.py @@ -8,7 +8,9 @@ class AI: self.convertlog = [] def humantosql(self, text: str, dbtype: str, tableschema: list) -> str: - self.convertlog = [{"role": "system", "content": f"You convert Human Language to SQL. Only answer as an SQL Statement as the output of you will be the direct input into the database. Always edit the old Statement and do not create a completly new one. You are using this Database: {dbtype} and for better context here are the tables and columns: {tableschema}"}] + if not self.convertlog: + self.convertlog = [{"role": "system", "content": f"You convert Human Language to SQL. Only answer as an Valid SQL Statement. Always modify your previous answer and do not create something new. You are using this Database: {dbtype}. For better context here are the tables and columns: {tableschema}"}] + prompt = {"role": "user", "content": text} self.convertlog.append(prompt) response = openai.ChatCompletion.create( @@ -17,6 +19,9 @@ class AI: ) response = response['choices'][0]['message']['content'] self.convertlog.append({"role": "system", "content": response}) + for i in self.convertlog: + print(i) + return response def decide(self, sql: str) -> str: