Also do any of you how to make the API interactive- after it gives a results I want askaks based on that how do I do that
the current code I used to input images and messages is
message_content = [
{
“type”: “text”,
“text”: “What is that”
},
{
“type”: “image_url”,
“image_url”: {
“url”: “”,
“detail”: “high”
}
}
]
message = client.beta.threads.messages.create(
thread_id=thread_id,
role=“user”,
content=message_content
)
and then use the code they give to strem it , which is
class MyEventHandler(AssistantEventHandler):
def init(self):
super().init()
self.outputs =
@override
def on_text_created(self, text) -> None:
print(f"\nassistant > {text}", end="", flush=True)
self.outputs.append(text)
@override
def on_text_delta(self, delta, snapshot):
print(delta.value, end="", flush=True)
self.outputs.append(delta.value)
def on_tool_call_created(self, tool_call):
print(f"\nassistant > {tool_call.type}\n", flush=True)
def on_tool_call_delta(self, delta, snapshot):
if delta.type == 'code_interpreter':
if delta.code_interpreter.input:
print(delta.code_interpreter.input, end="", flush=True)
self.outputs.append(delta.code_interpreter.input)
if delta.code_interpreter.outputs:
print(f"\n\noutput >", flush=True)
for output in delta.code_interpreter.outputs:
if output.type == "logs":
print(f"\n{output.logs}", flush=True)
self.outputs.append(output.logs)
Instantiate the handler
handler = MyEventHandler()
Run the stream with the handler
with client.beta.threads.runs.stream(
thread_id=thread_id,
assistant_id=assistant_id,
event_handler=handler,
) as stream:
stream.until_done()
Now how do I agin asks questions based on the result