Here is the text summarization function. I have valid azure openai API, endpoint through a valid subscription and I have mentioned them in the .env file correctly. I do feel the issue is in this url - ${endpoint}/v1/chat/completions
. Please provide any solution.
const prompt = `Provide a summary of the text: ${data}`;
const apiKey = process.env.AZURE_OPENAI_API_KEY;
const endpoint = process.env.AZURE_OPENAI_ENDPOINT;
const url = `${endpoint}/v1/chat/completions`;
const response = await axios.post(
url,
{
model: "gpt-35-turbo",
prompt: prompt,
temperature: 0.3,
max_tokens: 250,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0
},
{
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
},
}
);
const summary = response.data.choices[0].text.trim();
return summary;
I tried,
const url = ${endpoint}/v1/completions
;
const url = ${endpoint}/openai/deployments/MY_DEPLOYMENT_NAME/completions?api-version=2023-05-15
;
const url = ${endpoint}/openai/deployments/MY_DEPLOYMENT_NAME/completions?api-version=2023-05-15-preview
;