How do we add more files to Azure Assitant with Code Intepreter after it is created?

P Mahadevan 20 Reputation points
2024-07-03T04:54:13.2166667+00:00

assistant = client.beta.assistants.create( instructions="You are an AI assistant that can write code to help answer math questions.", model="gpt-4-1106-preview", tools=[{"type": "code_interpreter"}],

)

Aftet creating this, If i have to update the Assitant , hw do we do this?

The Example create assistant file request is mentioned in

the API reference at https://video2.skills-academy.com/en-us/azure/ai-services/openai/assistants-reference?tabs=python

assistant_file = client.beta.assistants.files.create( assistant_id="asst_abc123", file_id="assistant-abc123" )

but when we try this there is no files Property for assistant .

After some trail and error found an alternate way using the following code:

assistant = client.beta.assistants.update(
    assistant_id=assitantID,
    tool_resources={
        "code_interpreter": {
            "file_ids": fileIDs
        }
    }
)

is this the correct approach?

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,538 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,577 questions
0 comments No comments
{count} votes

Accepted answer
  1. AshokPeddakotla-MSFT 30,066 Reputation points
    2024-07-03T06:09:11.0566667+00:00

    P Mahadevan Greetings & Welcome to Microsoft Q&A forum!

    AFAIK, You can upload up to 20 files, with a max file size of 512 MB to use with tools.

    After some trail and error found an alternate way using the following code: is this the correct approach?

    That is a correct approach to update the tool resources of an assistant. In your code, you are updating the code_interpreter tool resource of the assistant with the specified file_ids.

    As mentioned here, you can modify the assistant with an update method.

    my_updated_assistant = client.beta.assistants.update(
      "asst_abc123",
      instructions="You are an HR bot, and you have access to files to answer employee questions about company policies. Always respond with info from either of the files.",
      name="HR Helper",
      tools=[{"type": "code-interpreter"}],
      model="gpt-4", #model = model deployment name
      file_ids=["assistant-abc123", "assistant-abc456"],
    )
    
    

    The update method of the assistant object can be used to update various properties of an assistant.

    The file_ids parameter is a list of file IDs that contain the code that the code_interpreter tool resource will execute.

    By updating the file_ids of the code_interpreter tool resource, you are essentially updating the code that the assistant will execute when using this tool.

    So, your code seems to be correct and should work as expected to update the tool resources of an assistant.

    Do let me know if that helps or have any other queries.


    If the response helped, please do click Accept Answer and Yes for was this answer helpful.

    0 comments No comments

0 additional answers

Sort by: Most helpful