Update app.py
Browse files
app.py
CHANGED
@@ -93,6 +93,13 @@ def handle_input(user_input, state):
|
|
93 |
logger.info("User attempted to interact without uploading a file.")
|
94 |
return state['chat_history'], state
|
95 |
elif state['mode'] == 'waiting_for_query':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
query = user_input
|
97 |
state['current_query'] = query
|
98 |
state['feedback_count'] = 0
|
@@ -109,6 +116,13 @@ def handle_input(user_input, state):
|
|
109 |
# Log the query and initial answer here:
|
110 |
logger.info(f"Query: {query}, Answer: {answer}")
|
111 |
elif state['mode'] == 'waiting_for_feedback':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
feedback = user_input.lower()
|
113 |
state['chat_history'].append(("User", feedback))
|
114 |
logger.info(f"Feedback: {feedback}")
|
@@ -135,6 +149,9 @@ def handle_input(user_input, state):
|
|
135 |
state['feedback_count'] += 1
|
136 |
state['chat_history'].append(("Bot", f"Updated answer: {adjusted_answer}\nPlease provide feedback: good, too vague, not helpful."))
|
137 |
logger.info(f"Adjusted answer: {adjusted_answer}")
|
|
|
|
|
|
|
138 |
return state['chat_history'], state
|
139 |
|
140 |
# Initial state
|
|
|
93 |
logger.info("User attempted to interact without uploading a file.")
|
94 |
return state['chat_history'], state
|
95 |
elif state['mode'] == 'waiting_for_query':
|
96 |
+
if user_input.lower() == "exit":
|
97 |
+
logger.info("User entered 'exit'. Ending session.")
|
98 |
+
state['mode'] = 'exited'
|
99 |
+
state['chat_history'].append(("User", "exit"))
|
100 |
+
state['chat_history'].append(("Bot", "Session ended. You can download the log file."))
|
101 |
+
return state['chat_history'], state
|
102 |
+
|
103 |
query = user_input
|
104 |
state['current_query'] = query
|
105 |
state['feedback_count'] = 0
|
|
|
116 |
# Log the query and initial answer here:
|
117 |
logger.info(f"Query: {query}, Answer: {answer}")
|
118 |
elif state['mode'] == 'waiting_for_feedback':
|
119 |
+
if user_input.lower() == "exit":
|
120 |
+
logger.info("User entered 'exit'. Ending session.")
|
121 |
+
state['mode'] = 'exited'
|
122 |
+
state['chat_history'].append(("User", "exit"))
|
123 |
+
state['chat_history'].append(("Bot", "Session ended. You can download the log file."))
|
124 |
+
return state['chat_history'], state
|
125 |
+
|
126 |
feedback = user_input.lower()
|
127 |
state['chat_history'].append(("User", feedback))
|
128 |
logger.info(f"Feedback: {feedback}")
|
|
|
149 |
state['feedback_count'] += 1
|
150 |
state['chat_history'].append(("Bot", f"Updated answer: {adjusted_answer}\nPlease provide feedback: good, too vague, not helpful."))
|
151 |
logger.info(f"Adjusted answer: {adjusted_answer}")
|
152 |
+
elif state['mode'] == 'exited':
|
153 |
+
state['chat_history'].append(("Bot", "Session is over. Please download the log."))
|
154 |
+
logger.info("User interacted after exiting.")
|
155 |
return state['chat_history'], state
|
156 |
|
157 |
# Initial state
|