URL is not defined as soon as I send a message to completions

I had a small chat UI working in Linux with openAi GPT3.5 and started working on updating packages and versions to allow support for langchain as well. The app launches and starts a service as it always did before but as soon as I submit a message for completion, it fails with the message above (where previously it was working prior to incorporating more packages and updating) Currently installed:
nodejs v8.16
npm 6.4.1
openai 3.2.1

code

const dotenv = require('dotenv');
dotenv.config();
const express = require('express');
const http = require('http');
const socketIO = require('socket.io');
const openai = require('openai');
const chromadb = require('chromadb');
// ... (other requires)

const app = express();
const server = http.createServer(app);
const io = socketIO(server);
const port = process.env.PORT || 3000;

const { Configuration, OpenAIApi } = require("openai");

// Export statements
module.exports = {
  express,
  http,
  socketIO,
  openai,
  Configuration,
  OpenAIApi,
  chromadb,
  // ... (other exports)
  app,
  server,
  io,
  port,
};

// OpenAI API configuration
const configuration = new Configuration({
    apiKey: process.env.OPENAI_API_KEY,
});

const openai2 = new OpenAIApi(configuration);

app.use(express.static("public"));

io.on("connection", (socket) => {
  console.log("New user connected");

  // Initialize the conversation history
  const personality = "Answer in character as Marcus Aurelius...

  const conversationHistory = [];
   conversationHistory.push({ role: "system", content: personality });

  socket.on("sendMessage", async (message, callback) => {
    try {
      // Add the user message to the conversation history
      conversationHistory.push({ role: "user", content: message });

      const completion = await openai2.createChatCompletion({
        model: "gpt-3.5-turbo",
        messages: conversationHistory,
        max_tokens: 110,

      });

thanks for any tips!

pls ignore- not sure how to delete this BUT turned out to be fatfinger nodejs downgrade accident- 8.16 was meant to be 18.16. After that small correction worked again in case anyone sees the same ever again

1 Like

You can’t delete it, but you can mark your own post as a solution and the system will close the topic after a few days.