Update.
This commit is contained in:
parent
e9f7e7ec89
commit
85e642cf05
@ -191,11 +191,14 @@ class EventHandler(AssistantEventHandler):
|
||||
except Exception as ex:
|
||||
result = str(ex)
|
||||
tool_outputs.append({"tool_call_id": tool.id, "output": str(result)})
|
||||
|
||||
self.submit_tool_outputs(tool_outputs, run_id)
|
||||
try:
|
||||
self.submit_tool_outputs(tool_outputs, run_id)
|
||||
except Exception as ex:
|
||||
log.exception(ex)
|
||||
|
||||
def submit_tool_outputs(self, tool_outputs, run_id):
|
||||
event_handler = EventHandler(self.agent)
|
||||
log.debug(f"Submitting tool outputs {tool_outputs} for run {run_id}.")
|
||||
with self.agent.client.beta.threads.runs.submit_tool_outputs_stream(
|
||||
thread_id=self.current_run.thread_id,
|
||||
run_id=self.current_run.id,
|
||||
@ -227,7 +230,12 @@ class Agent:
|
||||
|
||||
self.thread = self.client.beta.threads.create()
|
||||
log.debug(f"Created thread with name {self.thread.id} for assistant {self.assistant.id}.")
|
||||
|
||||
|
||||
def reset(self):
|
||||
self.assistant = self._get_assistant()
|
||||
self.thread = self.client.beta.threads.create()
|
||||
log.debug(f"Resetted and created thread with name {self.thread.id} for assistant {self.assistant.id}.")
|
||||
|
||||
def get_file_by_name(self, name: str):
|
||||
for file in self.client.files.list().data:
|
||||
if file.filename == str(name):
|
||||
@ -408,6 +416,7 @@ class Agent:
|
||||
) as stream:
|
||||
stream.until_done()
|
||||
response = event_handler.message
|
||||
log.debug(f"Event handler: {event_handler}")
|
||||
log.debug(f"Received response: {response} from assistant {self.assistant.id} in thread {self.thread.id}.")
|
||||
log.debug(f"Result of communicate (last returned message): {response} from assistant {self.assistant.id} in thread {self.thread.id}.")
|
||||
self.transcript.append(dict(role="assistant", content=response))
|
||||
|
Loading…
Reference in New Issue
Block a user