Azure OpenAI model not working

yash 20 Reputation points
2023-09-01T15:19:02.2633333+00:00

I am getting error while running below code

{
  code: 'OperationNotSupported',
  message: 'The completion operation does not work with the specified model, gpt-35-turbo. Please choose different model and try again. You can learn more about which models can be used with each operation here: https://go.microsoft.com/fwlink/?linkid=2197993.'
}
const { OpenAIClient, AzureKeyCredential } = require("@azure/openai");

(async function main() {
  const endpoint = "https://profileforslack.openai.azure.com/";
  const key = "";
  const client = new OpenAIClient(endpoint, new AzureKeyCredential(key));

  const textToSummarize = `
    Two independent experiments reported their results this morning at CERN, Europe's high-energy physics laboratory near Geneva in Switzerland. Both show convincing evidence of a new boson particle weighing around 125 gigaelectronvolts, which so far fits predictions of the Higgs previously made by theoretical physicists.

    ""As a layman I would say: 'I think we have it'. Would you agree?"" Rolf-Dieter Heuer, CERN's director-general, asked the packed auditorium. The physicists assembled there burst into applause.
  :`;

  const summarizationPrompt = [
    `
    Summarize the following text.

    Text:
    """"""
    ${textToSummarize}
    """"""

    Summary:
  `,
  ];

  console.log(`Input: ${summarizationPrompt}`);

  const deploymentName = "gpt";
  try {
    const { choices } = await client.getCompletions(
      deploymentName,
      summarizationPrompt
    );
    const completion = choices[0].text;
    console.log(`Summarization: ${completion}`);
  } catch (err) {
    console.log(err);
  }
})();

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

Accepted answer
  1. Saurabh Sharma 23,841 Reputation points Microsoft Employee
    2023-09-01T21:52:18.6366667+00:00

    Hi @yash ,

    Thanks for using Microsoft Q&A!!

    I believe you are trying to use the Completions with the latest version (0613) of gpt-3.5-turbo. User's image

    Unfortunately, completions is NOT supported for newer models, it is only supported on older model versions and thus you are getting this error. OpenAI has deprecated this endpoint entirely, Azure OpenAI still supports it, but only in this limited capacity for older models. New model version will only be supported on the chat completions endpoint.

    Please refer to the documentation for details (see snippet from the documentation below):

    User's image

    Also, older model 0301 supports completions and would still technically work in the studio today in both the completions and chat playground.

    I suggest you to please use the Chat completions instead to get the summarization. Please refer to the sample for syntax of using the getChatCompletions function.

    Please find below the code which you can use for your usecase:

    const messages = [
        { role: "system", content: "You are an AI assistant that helps summarizing the texts." },       
        { role: "user", content: 
        `
        Summarize the following text.
    
        Text:
        """"""    
        ${textToSummarize}
        """"""
        Summary:
        ` }
      ];
      
      try {
        const result = await client.getChatCompletions(deploymentName, messages);
    
        for (const choice of result.choices) {
          console.log(choice.message);
      }
      } catch (err) {
        console.log(err);
      }
     
    })();
    

    Please let me know if you have any other questions.

    Thanks

    Saurabh


    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.


0 additional answers

Sort by: Most helpful

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.