Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,4 +8,21 @@ from langchain_core.output_parsers import StrOutputParser
|
|
| 8 |
from langchain_community.chat_message_histories import SQLChatMessageHistory
|
| 9 |
from langchain_core.runnables.history import RunnableWithMessageHistory
|
| 10 |
|
| 11 |
-
st.write('hello welecome to data science tutor')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
from langchain_community.chat_message_histories import SQLChatMessageHistory
|
| 9 |
from langchain_core.runnables.history import RunnableWithMessageHistory
|
| 10 |
|
| 11 |
+
st.write('hello welecome to data science tutor')
|
| 12 |
+
db=chat_history_data
|
| 13 |
+
conn=st.connection('db',type='sql')
|
| 14 |
+
cursor=conn.cursor()
|
| 15 |
+
# Create a table to store the session history (if it doesn't already exist)
|
| 16 |
+
cursor.execute('''CREATE TABLE IF NOT EXISTS message_history (
|
| 17 |
+
session_id TEXT NOT NULL,
|
| 18 |
+
user_message TEXT NOT NULL,
|
| 19 |
+
assistant_message TEXT,
|
| 20 |
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
| 21 |
+
PRIMARY KEY (session_id, timestamp))''')
|
| 22 |
+
|
| 23 |
+
# Commit the changes
|
| 24 |
+
conn.commit()
|
| 25 |
+
|
| 26 |
+
# Close the connection
|
| 27 |
+
conn.close()
|
| 28 |
+
|