Spaces:
Runtime error

SuhasGholkar commited on
Commit
9cb71b2
·
verified ·
1 Parent(s): 2fea8c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -17
app.py CHANGED
@@ -94,24 +94,29 @@ def get_connection():
94
 
95
 
96
  logger.info("===== BEFORE init_chat_history_table =====")
97
- def init_chat_history_table():
98
- with get_connection() as conn:
99
- conn.execute("""
100
- CREATE TABLE IF NOT EXISTS chat_history (
101
- id INTEGER PRIMARY KEY AUTOINCREMENT,
102
- timestamp TEXT,
103
- user_message TEXT,
104
- intent TEXT,
105
- sentiment TEXT,
106
- resolution TEXT,
107
- bot_reply TEXT,
108
- ftr_ms REAL,
109
- sql_query TEXT,
110
- sql_params TEXT
111
- )
112
- """)
113
- conn.commit()
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  def save_chat_to_db(user_message, intent, sentiment, resolution, bot_reply, ftr_ms, sql_query, sql_params):
116
  with get_connection() as conn:
117
  conn.execute("""
 
94
 
95
 
96
  logger.info("===== BEFORE init_chat_history_table =====")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ def init_chat_history_table():
99
+ try:
100
+ with get_connection() as conn:
101
+ conn.execute("""
102
+ CREATE TABLE IF NOT EXISTS chat_history (
103
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
104
+ timestamp TEXT,
105
+ user_message TEXT,
106
+ intent TEXT,
107
+ sentiment TEXT,
108
+ resolution TEXT,
109
+ bot_reply TEXT,
110
+ ftr_ms REAL,
111
+ sql_query TEXT,
112
+ sql_params TEXT
113
+ )
114
+ """)
115
+ conn.commit()
116
+ except sqlite3.OperationalError as e:
117
+ st.error(f"Error creating chat history table: {e}")
118
+ st.stop()
119
+
120
  def save_chat_to_db(user_message, intent, sentiment, resolution, bot_reply, ftr_ms, sql_query, sql_params):
121
  with get_connection() as conn:
122
  conn.execute("""