rishabhpr commited on
Commit
75a27fc
·
verified ·
1 Parent(s): af2de81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -45,7 +45,7 @@ if "generated_question" not in st.session_state:
45
  st.session_state.generated_question = None # Stores the generated question for persistence
46
 
47
  if "debug_logs" not in st.session_state:
48
- st.session_state.debug_logs = [] # Stores debug logs for toggling
49
 
50
  # Function to find the top 1 most similar question based on user input
51
  def find_top_question(query):
@@ -69,8 +69,8 @@ def find_top_question(query):
69
 
70
  # Function to generate response using OpenAI API with debugging logs
71
  def generate_response(messages):
72
- debug_log_entry = {"messages": messages}
73
- st.session_state.debug_logs.append(debug_log_entry) # Store debug log
74
 
75
  response = client.chat.completions.create(
76
  model="o1-mini",
@@ -160,9 +160,8 @@ else:
160
 
161
  # Right sidebar toggleable debug logs and code interpreter section
162
  with st.expander("Debug Logs (Toggle On/Off)", expanded=False):
163
- if len(st.session_state.debug_logs) > 0:
164
- for log_entry in reversed(st.session_state.debug_logs): # Show most recent logs first
165
- st.write(log_entry)
166
 
167
  st.sidebar.markdown("---")
168
  st.sidebar.markdown("## Python Code Interpreter")
 
45
  st.session_state.generated_question = None # Stores the generated question for persistence
46
 
47
  if "debug_logs" not in st.session_state:
48
+ st.session_state.debug_logs = None # Stores debug logs for toggling
49
 
50
  # Function to find the top 1 most similar question based on user input
51
  def find_top_question(query):
 
69
 
70
  # Function to generate response using OpenAI API with debugging logs
71
  def generate_response(messages):
72
+ # For debug logs, store only the follow-up conversation history
73
+ st.session_state.debug_logs = st.session_state.messages # Update debug logs with current conversation
74
 
75
  response = client.chat.completions.create(
76
  model="o1-mini",
 
160
 
161
  # Right sidebar toggleable debug logs and code interpreter section
162
  with st.expander("Debug Logs (Toggle On/Off)", expanded=False):
163
+ if st.session_state.debug_logs:
164
+ st.write(st.session_state.debug_logs)
 
165
 
166
  st.sidebar.markdown("---")
167
  st.sidebar.markdown("## Python Code Interpreter")