Skip to content

Commit b18f346

Browse files
committed
feat: Add AI interaction support to manager.py
fix: Improve error handling for AI interactions patch: Optimize SQL generation process
1 parent 866f919 commit b18f346

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

manager.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,9 @@ def default(self, line: str, prompt_confirmation: bool = False, ai_generated=Fal
509509
elif line.startswith("/sql"):
510510
line = [line[4:].strip()]
511511
elif line.startswith("/ai"):
512-
line = TextToSql(self.db_manager).generate(line[3:].strip())
512+
if not hasattr(self, "text_to_sql"):
513+
self.text_to_sql = TextToSql(self.db_manager)
514+
line = self.text_to_sql.generate(line[3:].strip())
513515
prompt_confirmation = True
514516
ai_generated = True
515517
elif self.ai:
@@ -539,6 +541,16 @@ def default(self, line: str, prompt_confirmation: bool = False, ai_generated=Fal
539541
)
540542
self.__end_time = time.time()
541543

544+
@cli_error_handler
545+
def do_reset(self, line):
546+
"""Start new conversation thread with AI"""
547+
assert hasattr(self, "text_to_sql"), f"You haven't chat with AI yet!"
548+
assert hasattr(
549+
self.text_to_sql.ai, "conversation"
550+
), f"Your haven't interacted with AI yet!"
551+
self.text_to_sql.ai.conversation.chat_history = ""
552+
logging.info("New conversation thread started.")
553+
542554
def do_exit(self, line):
543555
"""Quit this program"""
544556
if click.confirm("Are you sure to exit"):

0 commit comments

Comments
 (0)