Skip to content

OpenAI API, https://api.openai.com/v1/completions, is no longer valid #3

@suzeeparker

Description

@suzeeparker

I am following your video, Talk to Your Files: Conversational AI for Any Folder of Documents with Langchain in Node.js (https://www.youtube.com/watch?v=EFM-xutgAvY)

Everything is now working using Pinecone and langchain to create and save embedding ventors, except for the last step when the question is submitted to the OPENAI API using the LangChain:

    //11. Execute the chain with input documents and question
          const result = await chain.call( {
             input_documents: [new Document({ pageContent: concatenatedPageContent })],
             question: question,
          });

The error message is: 'Request failed with status code 404'
In the error object, I can see that an API query was sent to https://api.openai.com/v1/completions
The header looks like this

            POST /v1/completions HTTP/1.1
            Accept:         application/json, text/plain, */*
            Content-Type:   application/json
            User-Agent:     OpenAI/NodeJS/3.3.0
            Authorization:  Bearer sk-abcdefghijk123456789ABCDEFGHIJKLMNOPQRSTUVWXYZZZ
            Content-Length: 11096
            Host:           api.openai.com\r\nConnection: keep-alive

I wonder if 1) OpenAI has a new URL and 2) there is a problem with my API_KEY
Here are the two statements where OpenAI objects are created:

   // 8. Create OpenAI embeddings for documents
         const embeddingsArrays = await new OpenAIEmbeddings().embedDocuments(
            chunks.map((chunk) => chunk.pageContent.replace(/\n/g, " "))
         );
        
   // 9. Create an OpenAI instance and load the QAStuffChain
         const llm = new OpenAI({});
         const chain = loadQAStuffChain(llm);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions