Spaces:
Build error
Build error
Canstralian
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from Backend import get_correction_and_comments, generate_questions
|
3 |
from logger import logger
|
4 |
-
from pymongo import MongoClient, errors
|
5 |
import interpreter
|
6 |
from dotenv import load_dotenv
|
7 |
import os
|
@@ -16,14 +16,22 @@ st.title("✨ Interactive Code Assistant with Python Interpreter ✨")
|
|
16 |
if "helpful" not in st.session_state:
|
17 |
st.session_state.helpful = None # Initialize feedback as None
|
18 |
|
19 |
-
# Set up
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
# Create two expanded columns for wider side-by-side text areas
|
29 |
colu1, colu2 = st.columns([1, 1]) # Both columns have equal width
|
@@ -82,7 +90,10 @@ st.session_state.helpful = st.radio("Were the questions helpful?", ("Yes", "No")
|
|
82 |
if st.button("Submit Feedback"):
|
83 |
if st.session_state.helpful is not None:
|
84 |
try:
|
85 |
-
|
|
|
|
|
|
|
86 |
st.success("Feedback submitted successfully.")
|
87 |
except Exception as e:
|
88 |
st.error(f"Failed to submit feedback: {e}")
|
@@ -102,4 +113,4 @@ st.markdown(
|
|
102 |
</style>
|
103 |
""",
|
104 |
unsafe_allow_html=True
|
105 |
-
)
|
|
|
1 |
import streamlit as st
|
2 |
+
import sqlite3
|
3 |
from Backend import get_correction_and_comments, generate_questions
|
4 |
from logger import logger
|
|
|
5 |
import interpreter
|
6 |
from dotenv import load_dotenv
|
7 |
import os
|
|
|
16 |
if "helpful" not in st.session_state:
|
17 |
st.session_state.helpful = None # Initialize feedback as None
|
18 |
|
19 |
+
# Set up SQLite connection
|
20 |
+
def init_sqlite():
|
21 |
+
conn = sqlite3.connect("feedback.db")
|
22 |
+
cursor = conn.cursor()
|
23 |
+
# Create table if it doesn't exist
|
24 |
+
cursor.execute("""
|
25 |
+
CREATE TABLE IF NOT EXISTS Feedback (
|
26 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
27 |
+
helpful TEXT NOT NULL,
|
28 |
+
question_type TEXT NOT NULL
|
29 |
+
)
|
30 |
+
""")
|
31 |
+
conn.commit()
|
32 |
+
return conn
|
33 |
+
|
34 |
+
conn = init_sqlite()
|
35 |
|
36 |
# Create two expanded columns for wider side-by-side text areas
|
37 |
colu1, colu2 = st.columns([1, 1]) # Both columns have equal width
|
|
|
90 |
if st.button("Submit Feedback"):
|
91 |
if st.session_state.helpful is not None:
|
92 |
try:
|
93 |
+
cursor = conn.cursor()
|
94 |
+
cursor.execute("INSERT INTO Feedback (helpful, question_type) VALUES (?, ?)",
|
95 |
+
(st.session_state.helpful, question_type))
|
96 |
+
conn.commit()
|
97 |
st.success("Feedback submitted successfully.")
|
98 |
except Exception as e:
|
99 |
st.error(f"Failed to submit feedback: {e}")
|
|
|
113 |
</style>
|
114 |
""",
|
115 |
unsafe_allow_html=True
|
116 |
+
)
|