Hello, I am using the Azure Assistant API to stream messages, and on Azure code interpreter is turned off and in the code we only write tools=file_search, but it still calls code interpreter multiple times before it does file search.
Is there a way to 100% turn off code interpreter?
The code:
while attempt <= max_retries:
try:
self.logger.debug(f"Initiating Azure run for thread {thread_id} (attempt {attempt + 1}).")
with self.client.beta.threads.runs.stream(
thread_id=thread_id,
assistant_id=assistant_id,
tools=[{"type": "file_search"}],
#tool_choice="required"
) as event_handler:
for event in event_handler:
if event.__class__.__name__ == "ThreadMessageInProgress":
self.logger.debug(f"Azure run started streaming.")
if event.__class__.__name__ == "ThreadRunCompleted":
duration_sec = time.time() - local_start
self.logger.info(f"Azure run finished in {duration_sec:.2f} seconds.")
if self.promo is not None:
self.promo.setGaugeValue("openai_run_duration", duration_sec)
return response_text
if event.__class__.__name__ == "ThreadMessageDelta":
if hasattr(event, "data") and event.data and hasattr(event.data, "delta"):
content = getattr(event.data.delta, "content", None)
if content:
for part in content:
text_chunk = part.text.value
response_text += text_chunk
if callable(stream_handler):
stream_handler(text_chunk)
if event.__class__.__name__ == "ThreadRunStepDelta":
if hasattr(event, "data") and event.data and hasattr(event.data, "delta"):
step_details = getattr(event.data.delta, "step_details", None)
if step_details and step_details.tool_calls:
for call in step_details.tool_calls:
if call.type == "code_interpreter" and call.code_interpreter and call.code_interpreter.input:
self.logger.debug(f"Code interpreter tool was called")
if call.type == "file_search":
self.logger.debug(f"File search tool was called")
return response_text