const { AzureOpenAI } = require("openai");
// Load the .env file if it exists
const dotenv = require("dotenv");
dotenv.config();
// You will need to set these environment variables or edit the following values
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"] || "https://kuraken-openai.openai.azure.com/";
const apiKey = process.env["AZURE_OPENAI_API_KEY"] || "ad9720265b1f4053b7bc2682beacc94e";
const apiVersion = "2023-03-15-preview";
const deployment = "gpt-4"; //This must match your deployment name.
require("dotenv/config");
async function main() {
const client = new AzureOpenAI({ endpoint, apiKey, apiVersion}); //, deployment
console.log(typeof(client));
const result = await client.streamChat.completions.create({
// const result = await client.getChatCompletions({
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Does Azure OpenAI support customer managed keys?" },
{ role: "assistant", content: "Yes, customer managed keys are supported by Azure OpenAI?" },
{ role: "user", content: "Do other Azure AI services support this too?" },
],
model: "gpt-4",
});
for (const choice of result.choices) {
console.log(choice.message);
}
}
main().catch((err) => {
console.error("The sample encountered an error:", err);
});
module.exports = { main };