Error occurred when using Retrieval feature in Azure Assistant : Retrieval Tools Not Supported

Su Myat Hlaing 160 Reputation points
2024-05-22T04:42:42.82+00:00

I encountered an error while trying to use the Retrieval feature in Azure Assistant and would appreciate any help resolving it. Below are the details of the error:

could you also support how to download the file by fileID?User's image

Code:



const { OpenAIClient, AzureKeyCredential,AssistantsClient } = require("@azure/openai-assistants");

async function main() {
  const assistantsClient = new AssistantsClient(endpoint, new AzureKeyCredential(azureApiKey));
  // File upload sample code
  const filename = "sample_file_for_upload.txt";
  const uint8array = new TextEncoder().encode(
    "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457.",
  );
  const uploadAssistantFile = await assistantsClient.uploadFile(uint8array, "assistants", {
    filename,
  });
  console.log(uploadAssistantFile);
  const fileAssistantResponse = await assistantsClient.createAssistant({
    model: "gpt-4-turbo",
    name: "JS SDK Test Assistant - Retrieval",
    instructions: "Please address the user as Jane Doe. The user has a premium account.",
    tools: [{ type: "retrieval" }],
    fileIds: [uploadAssistantFile.id],
  });
  console.log(fileAssistantResponse);

  const assistantThread = await assistantsClient.assistantThreads.createThread({});
  console.log(assistantThread);

  const question = "I need to know codes for apple and banana. Can you help me?";
  const threadResponse = await assistantsClient.threadMessages.createMessage(
    assistantThread.id,
    "user",
    question,
  );
  console.log(threadResponse);
  let runResponse = await assistantsClient.threadRuns.createRun(
    assistantThread.id,
    fileAssistantResponse.id,
    {
      requestOptions: { timeout: 10000 },
      instructions:
        "You are a helpful assistant that can help fetch data from files you know about.",
      tools: [{ type: "retrieval" }],
    },
  );
  console.log(runResponse);

  do {
    await new Promise((r) => setTimeout(r, 500));
    runResponse = await assistantsClient.threadRuns.retrieveRun(assistantThread.id, runResponse.id);
    console.log(runResponse);
    const runSteps = await assistantsClient.runSteps.listRunSteps(
      assistantThread.id,
      runResponse.id,
      {
        requestOptions: {},
        limit: 1,
      },
    );
    console.log(runSteps);
  } while (runResponse.status === "queued" || runResponse.status === "in_progress");

  const runMessages = await assistantsClient.threadMessages.listMessages(assistantThread.id);
  for (const runMessageDatum of runMessages.data) {
    for (const item of runMessageDatum.content) {
      if (item.type === "text") {
        console.log(item.text?.value);
      } else if (item.type === "image_file") {
        console.log(item.imageFile?.fileId);
      }
    }
  }
}

main().catch((err) => {
  console.error("The sample encountered an error:", err);
});

module.exports = { main };
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,235 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 34,616 Reputation points
    2024-05-22T10:50:08.6066667+00:00

    Su Myat Hlaing

    AFAIK As mentioned here, Tools can currently be of types code_interpreter, or function.

    Our team is actively working on supporting this feature. Currently there is no exact ETA which can be shared on these feature availability.

    Once these updated feature is available in Azure OpenAI, What's new in Azure OpenAI Service and Assistants API (Preview) reference pages will be updated accordingly.

    I hope this helps. Let me know if you have any further queries.


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.