bstraehle commited on
Commit
273f79a
1 Parent(s): a138a98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -11,6 +11,8 @@ def show_json(str, obj):
11
  print(json.loads(obj.model_dump_json()))
12
 
13
  def init_assistant():
 
 
14
  client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
15
 
16
  assistant = client.beta.assistants.create(
@@ -21,8 +23,6 @@ def init_assistant():
21
 
22
  thread = client.beta.threads.create()
23
 
24
- return client, assistant, thread
25
-
26
  def wait_on_run(client, run, thread):
27
  while run.status == "queued" or run.status == "in_progress":
28
  run = client.beta.threads.runs.retrieve(
@@ -54,11 +54,7 @@ def chat(message, history):
54
  history_openai_format.append({"role": "user", "content": message})
55
 
56
  if len(history_openai_format) == 1:
57
- client, assistant, thread = init_assistant()
58
-
59
- client = client
60
- assistant = assistant
61
- thread = thread
62
 
63
  show_json("assistant", assistant)
64
  show_json("thread", thread)
 
11
  print(json.loads(obj.model_dump_json()))
12
 
13
  def init_assistant():
14
+ global client, assistant, thread
15
+
16
  client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
17
 
18
  assistant = client.beta.assistants.create(
 
23
 
24
  thread = client.beta.threads.create()
25
 
 
 
26
  def wait_on_run(client, run, thread):
27
  while run.status == "queued" or run.status == "in_progress":
28
  run = client.beta.threads.runs.retrieve(
 
54
  history_openai_format.append({"role": "user", "content": message})
55
 
56
  if len(history_openai_format) == 1:
57
+ init_assistant()
 
 
 
 
58
 
59
  show_json("assistant", assistant)
60
  show_json("thread", thread)