Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bkocis committed Oct 22, 2023
1 parent 0a09ef1 commit df436e4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions chatgptApp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
ChatHistory = List[str]


def insert_into_db(message, content):
conn = sqlite3.connect(path_to_db, check_same_thread=False)
def insert_into_db(conn, DB_NAME, message, content):
c = conn.cursor()
c.execute("INSERT INTO chat_session_01 (question, answer) VALUES (?, ?)", (message, content))
c.execute(f"INSERT INTO {DB_NAME} (question, answer) VALUES (?, ?)", (message, content))
conn.commit()
c.execute("select * from chat_session_01")
c.execute(f"select * from {DB_NAME}")
logging.info(f"{c.fetchall()}")


Expand Down Expand Up @@ -71,7 +70,7 @@ def task():
messages.append(AIMessage(content=content))
logging.debug(f"reply = {content}")
logging.info("Done!")
insert_into_db(message, content)
insert_into_db(conn, DB_NAME, message, content)
return chat, "", chatbot_messages, messages


Expand Down Expand Up @@ -118,7 +117,7 @@ def task():
messages.append(AIMessage(content=content))
logging.debug(f"reply = {content}")
logging.info("Done!")
insert_into_db(message, content)
insert_into_db(conn, DB_NAME, message, content)
return chat, "", chatbot_messages, messages


Expand Down

0 comments on commit df436e4

Please sign in to comment.