I tried below code and getting error, I am simply trying API to generate some question based on topic given. How can I do that?
Like if I define a topic of Games
, I want to generate two questions for that:
{
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.'
}
Code
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);
}
})();
use a model supported by Azure Open AI. https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models
gpt-35-turbo
gpt-35-turbo-16k
gpt-4
gpt-4-32k
You may be trying to use the Completions api rather than the Chat Completions api.
https://www.educative.io/answers/openai-api-error-not-supported-in-the-v1-completions-endpoint
take this example: https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart?tabs=command-line&pivots=programming-language-javascript#create-a-sample-application
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 = [
{
"user": "system",
"content": `
Summarize the following text.
Text:
""""""
${textToSummarize}
""""""
Summary:
`,
}];
console.log(`Input: ${summarizationPrompt}`);
const deploymentName = "gpt-35-turbo";
try {
const { choices } = await client.getChatCompletions(
deploymentName,
summarizationPrompt
);
const completion = choices[0].message;
console.log(`Summarization: ${completion}`);
} catch (err) {
console.log(err);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With