Issue with Azure OpenAI Integration: Response Returning None and Debugging Steps

Hi everyone,

I’m working on an application that integrates with Azure OpenAI using the azure-openai Python SDK. My setup includes functionality for creating assistants, uploading files to a vector store, and requesting responses using threads and tools like file_search. However, I’m encountering an issue where the assistant response consistently returns None.
Some code snippet -
For Upload to vector -

def upload_files_to_vector_store(self, file_streams):
try:
print(“Uploading files to vector store…”)
seen_files = set()
unique_files =

        for file_stream in file_streams:
            file_name = file_stream.name
            if file_name not in seen_files:
                seen_files.add(file_name)
                unique_files.append(file_stream)
                print(f"Adding file: {file_name}")
            else:
                print(f"Skipping duplicate file: {file_name}")

        vector_store = self.client.beta.vector_stores.create(name="My Vector Store new one")
        print(f"Vector store created with ID: {vector_store.id}")

        batch = self.client.beta.vector_stores.file_batches.upload_and_poll(
            vector_store_id=vector_store.id, files=unique_files
        )
        print("File batch upload completed.")

        self.client.beta.assistants.update(
            assistant_id=self.assistant_id,
            tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}
        )
        print("Assistant updated with new vector store.")
        self.vector_store_id = vector_store.id
        return self.vector_store_id

thread = self.client.beta.threads.create(
messages=[{“role”: “user”, “content”: prompt}],
tool_resources={“file_search”: {“vector_store_ids”: [self.vector_store_id]}}
)

with self.client.beta.threads.runs.stream(
thread_id=thread.id,
assistant_id=self.assistant_id,
instructions=“Provide a detailed response.”,
event_handler=event_handler,
) as stream:
stream.until_done()