AI Asstants generated with Azure Assistants SDK do not have tools activated even those files are attached for vector search and code interpreter

Nenad Crnčec 25 Reputation points
2024-10-21T11:02:16.6733333+00:00

Hi

I am creating a Java Spring boot app that is using assistants SDK https://learn.microsoft.com/en-us/java/api/overview/azure/ai-openai-assistants-readme?view=azure-java-preview

When I create an assistant and attach vector store and files for code interpreter responses are clearly not using those files.

When I check the assistant in Azure AI Studio, I see that files are there, but "toggle" is not turned on.

When I turn on the toggle and query the assistant through AI Studio, assistant returns relevant responses.

As there is no explanation in provided page, or examples on github, it is unclear on how to use or activate code interpreter and vector search through SDK.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,052 questions
{count} votes

Accepted answer
  1. AshokPeddakotla-MSFT 35,971 Reputation points Moderator
    2024-10-22T11:57:55.54+00:00

    Nenad Crnčec I'm glad that your issue is resolved and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

    Error Message:

    I am creating a Java Spring boot app that is using assistants SDK https://learn.microsoft.com/en-us/java/api/overview/azure/ai-openai-assistants-readme?view=azure-java-preview

    When I create an assistant and attach vector store and files for code interpreter responses are clearly not using those files.

    When I check the assistant in Azure AI Studio, I see that files are there, but "toggle" is not turned on.

    When I turn on the toggle and query the assistant through AI Studio, assistant returns relevant responses.

    As there is no explanation in provided page, or examples on github, it is unclear on how to use or activate code interpreter and vector search through SDK.

    Solution:

    What was missing is that I need to set ToolResources AND ToolOptions

    Examples didn't include CodeInterpeter

    createToolResourcesOptions = new CreateToolResourcesOptions();
                CreateCodeInterpreterToolResourceOptions codeInterpreter = createToolResourcesOptions.setCodeInterpreter(
                        new CreateCodeInterpreterToolResourceOptions().setFileIds(assistantDTO.getCodeInterpreterFiles())
                ).getCodeInterpreter();
    
               if(!assistantDTO.getCodeInterpreterFiles().isEmpty())
    createToolResourcesOptions.setCodeInterpreter(codeInterpreter);
    toolDefinitions.add(new CodeInterpreterToolDefinition();
    
    
    AssistantCreationOptions options = new AssistantCreationOptions(model)
            .setName(assistantDTO.getName())
            .setDescription(assistantDTO.getDescription())
            .setInstructions(assistantDTO.getInstructions());
    
    if (createToolResourcesOptions != null) {
        options.setToolResources(createToolResourcesOptions);
    }
    
    
    options.setTools(toolDefinitions);  // enables tools
    Assistant assistant =  this.assistantsClient.createAssistant(options);
    
    

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nenad Crnčec 25 Reputation points
    2024-10-22T08:12:29.6966667+00:00

    As mentioned, With a file ID association and a supported tool enabled, the assistant will then be able to consume the associated data when running threads.

    ...this is/was actual problem. I am using that SDK. Examples on the page you shared ( I also shared it in first post ) add the files to the assistant, but do not enable it.

    In the mean time I resolved the issue.

    What was missing is that I need to set ToolResources AND ToolOptions

    Examples didn't include CodeInterpeter

                createToolResourcesOptions = new CreateToolResourcesOptions();
                CreateCodeInterpreterToolResourceOptions codeInterpreter = createToolResourcesOptions.setCodeInterpreter(
                        new CreateCodeInterpreterToolResourceOptions().setFileIds(assistantDTO.getCodeInterpreterFiles())
                ).getCodeInterpreter();
    
               if(!assistantDTO.getCodeInterpreterFiles().isEmpty())
    createToolResourcesOptions.setCodeInterpreter(codeInterpreter);
    toolDefinitions.add(new CodeInterpreterToolDefinition();
    
    
    AssistantCreationOptions options = new AssistantCreationOptions(model)
            .setName(assistantDTO.getName())
            .setDescription(assistantDTO.getDescription())
            .setInstructions(assistantDTO.getInstructions());
    
    if (createToolResourcesOptions != null) {
        options.setToolResources(createToolResourcesOptions);
    }
    
    
    options.setTools(toolDefinitions);  // enables tools
    Assistant assistant =  this.assistantsClient.createAssistant(options);
    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.