azure-openai-node icon indicating copy to clipboard operation
azure-openai-node copied to clipboard

Your readme is wrong

Open FrancescoSaverioZuppichini opened this issue 1 year ago • 0 comments

Your readme is wrong, come on!! Incredbile

import "dotenv/config";

config({ path: ".env.local" });

import { Configuration, OpenAIApi } from "azure-openai";

import { OpenAIStream, StreamingTextResponse } from "ai";
import { config } from "dotenv";

const apiKey = "asdsaads";

const openai = new OpenAIApi(
  new Configuration({
    apiKey,
    // add azure info into configuration
    azure: {
      apiKey,
      endpoint: "asddsads",
      // deploymentName is optional, if you donot set it, you need to set it in the request parameter
      deploymentName: "gpt-35-turbo",
    },
  })
);
// Extract the `messages` from the body of the request
const messages = [
  {
    role: "assistant",
    content: "You are an helpful AI assistant",
  },
  {
    role: "user",
    content: "Hi",
  },
];

// Ask OpenAI for a streaming chat completion given the prompt
const response = await openai.chat.completions.create({
  model: "gpt-35-turbo",
  stream: false,
  messages,
  max_tokens: 5,
});

console.log(response);

const response = await openai.chat.completions.create(
                                   ^

TypeError: Cannot read properties of undefined (reading 'completions')