bstraehle commited on
Commit
7e0d287
·
verified ·
1 Parent(s): f39d227

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -39,12 +39,15 @@ def chat(message, history, openai_api_key):
39
 
40
  try:
41
  # TODO: Use Gradio session
42
- if get_thread() == None or len(history) == 0:
43
- set_openai_client(openai_api_key)
 
 
44
 
45
  #set_assistant(create_assistant()) # first run
46
  set_assistant(load_assistant()) # subsequent runs
47
-
 
48
  set_thread(create_thread())
49
 
50
  create_message(get_thread(), message)
@@ -62,7 +65,6 @@ def chat(message, history, openai_api_key):
62
  raise gr.Error(e)
63
 
64
  return f"{'<hr>'.join(list(reversed(text_values))[1:])}{download_link}"
65
- #return f"{text_values[0]}{download_link}"
66
 
67
  gr.ChatInterface(
68
  fn=chat,
 
39
 
40
  try:
41
  # TODO: Use Gradio session
42
+ if os.environ["OPENAI_API_KEY"] != openai_api_key:
43
+ os.environ["OPENAI_API_KEY"] = openai_api_key
44
+
45
+ set_openai_client()
46
 
47
  #set_assistant(create_assistant()) # first run
48
  set_assistant(load_assistant()) # subsequent runs
49
+
50
+ if get_thread() == None or len(history) == 0:
51
  set_thread(create_thread())
52
 
53
  create_message(get_thread(), message)
 
65
  raise gr.Error(e)
66
 
67
  return f"{'<hr>'.join(list(reversed(text_values))[1:])}{download_link}"
 
68
 
69
  gr.ChatInterface(
70
  fn=chat,