Anustup commited on
Commit
661eedc
1 Parent(s): ea3c78a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -103,13 +103,15 @@ def response_evaluation_for_case_tx(thread_id, query, question_text, input, outp
103
 
104
 
105
  def run_chat_in_all_cases(message, history, question_text,input, output, examples, code_written):
106
- if "thread_id" in gr.get_session():
107
- pass
108
- else:
109
- thread = client.beta.threads.create()
110
- thread_id = thread.id
111
- gr.save_to_session(thread_id=thread_id)
112
- gr.save_to_session(thread=thread)
 
 
113
  print(thread_id)
114
  if not message and not code_written:
115
  ai_message = opening_statement(thread_id, question_text, input, output, examples, thread)
 
103
 
104
 
105
  def run_chat_in_all_cases(message, history, question_text,input, output, examples, code_written):
106
+ try:
107
+ with open("thread_id.txt", "r") as file:
108
+ thread_id = file.read().strip()
109
+ except FileNotFoundError:
110
+ # If file does not exist, create a new thread and save its ID
111
+ thread = client.beta.threads.create()
112
+ thread_id = thread.id
113
+ with open("thread_id.txt", "w") as file:
114
+ file.write(thread_id)
115
  print(thread_id)
116
  if not message and not code_written:
117
  ai_message = opening_statement(thread_id, question_text, input, output, examples, thread)