gera commited on
Commit
354e8e7
1 Parent(s): 3879995

no event handler

Browse files
Files changed (1) hide show
  1. app.py +0 -18
app.py CHANGED
@@ -9,23 +9,6 @@ client = openai.OpenAI()
9
  assistant_id = "asst_NHnYFIdpvioacAJqWYMchJHI"
10
  vector_id = "vs_sqT4VRRTwkH7JPr3AT8CpoXV"
11
 
12
- class EventHandler(openai.AssistantEventHandler):
13
- # def on_event(self, event):
14
- # print(f"event: {event.event}\n{event.data}\n\n")
15
-
16
- def on_tool_call_created(self, tool_call):
17
- print(f"\nassistant > {tool_call.type}\n", flush=True)
18
-
19
- def on_tool_call_delta(self, delta, snapshot):
20
- if delta.type == 'code_interpreter':
21
- if delta.code_interpreter.input:
22
- print(delta.code_interpreter.input, end="", flush=True)
23
- if delta.code_interpreter.outputs:
24
- print(f"\n\noutput >", flush=True)
25
- for output in delta.code_interpreter.outputs:
26
- if output.type == "logs":
27
- print(f"\n{output.logs}", flush=True)
28
-
29
  def chat(user_message, history, state):
30
  if (state is None) or (not state['user']):
31
  gr.Warning("You need to authenticate first")
@@ -51,7 +34,6 @@ def chat(user_message, history, state):
51
  with client.beta.threads.runs.stream(
52
  thread_id=thread.id,
53
  assistant_id=assistant_id,
54
- event_handler=EventHandler(),
55
  ) as stream:
56
  total = ''
57
  for delta in stream.text_deltas:
 
9
  assistant_id = "asst_NHnYFIdpvioacAJqWYMchJHI"
10
  vector_id = "vs_sqT4VRRTwkH7JPr3AT8CpoXV"
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  def chat(user_message, history, state):
13
  if (state is None) or (not state['user']):
14
  gr.Warning("You need to authenticate first")
 
34
  with client.beta.threads.runs.stream(
35
  thread_id=thread.id,
36
  assistant_id=assistant_id,
 
37
  ) as stream:
38
  total = ''
39
  for delta in stream.text_deltas: