forked from aellxx/InterviewAI-Inquisitive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeedback_tool.py
More file actions
76 lines (60 loc) · 2.67 KB
/
Copy pathfeedback_tool.py
File metadata and controls
76 lines (60 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import psycopg2
import random
import streamlit as st
from transformers import BartForConditionalGeneration, BartTokenizer
# establishing connection to the database used
database_name = "postgres"
database_user = "souadyakubu"
database_password = "souadseny"
database_host = "localhost"
database_port = "5432"
my_connection = psycopg2.connect(database = database_name , user = database_user , password = database_password, host = database_host, port = database_port)
cursor = my_connection.cursor()
# making a feedback table
with my_connection.cursor() as cursor:
cursor.execute('''
CREATE TABLE IF NOT EXISTS feedback (
id SERIAL PRIMARY KEY,
context TEXT,
question TEXT,
system_generated TEXT,
rater_id INTEGER,
rank INTEGER
)
''')
my_connection.commit()
@st.cache(allow_output_mutation=True)
def generate_questions(model_choice, context):
pass
def feedback_log(context, question, system, rater_id, rank):
# putting the feedback data into the PostgreSQL database
with my_connection.cursor() as cursor:
cursor.execute(
"INSERT INTO feedback (context, question, system_generated, rater_id, rank) VALUES (%s, %s, %s, %s, %s)",
(context, question, system, rater_id, rank)
)
my_connection.commit()
st.title("Feedback Collection Tool")
# collecting contexts
# contexts = st.text_area("Enter the contexts (one per line):").split("\n")
#selecting random context
# random_context = random.choice(contexts)
#selecting some questions for the random context
# random_questions = generate_questions(model_choice, random_context)
# for demonstration purposes, I'll assume we already have a random context and its generated questions.
random_context = "This is a sample context."
random_questions = ["What is your name?", "What are your hobbies?", "Tell me about your work experience."]
st.subheader("Context:")
st.write(random_context)
st.subheader("Generated Questions:")
for i, question in enumerate(random_questions):
st.write(f"{i + 1}. {question}")
#User Feedback
selected_question_index = st.selectbox("Select the best question:", [i + 1 for i in range(len(random_questions))])
rank = st.slider("Rate the question (1 = worst, 5 = best):", 1, 5)
if st.button("Submit Feedback"):
selected_question = random_questions[selected_question_index - 1]
system_that_generated = "hyechanjun/interview-question-remake"
rater_id = 1 #can be changed based on user authentication
feedback_log(random_context, selected_question, system_that_generated, rater_id, rank)
st.success("Feedback submitted successfully!")