Fixed GPT
This commit is contained in:
parent
13e027afdf
commit
2a2cb0d507
|
|
@ -8,7 +8,9 @@ class AI:
|
||||||
self.convertlog = []
|
self.convertlog = []
|
||||||
|
|
||||||
def humantosql(self, text: str, dbtype: str, tableschema: list) -> str:
|
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}
|
prompt = {"role": "user", "content": text}
|
||||||
self.convertlog.append(prompt)
|
self.convertlog.append(prompt)
|
||||||
response = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
|
|
@ -17,6 +19,9 @@ class AI:
|
||||||
)
|
)
|
||||||
response = response['choices'][0]['message']['content']
|
response = response['choices'][0]['message']['content']
|
||||||
self.convertlog.append({"role": "system", "content": response})
|
self.convertlog.append({"role": "system", "content": response})
|
||||||
|
for i in self.convertlog:
|
||||||
|
print(i)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def decide(self, sql: str) -> str:
|
def decide(self, sql: str) -> str:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user