Unexpected Azure Dependency with OpenAI and Langchain Library in Next.js App Deployed on AWS Amplify
Labels: name: area: embeddings, name: area: doc loader, name: area: vector store, name: auto:bug, name: auto:question

### System Info

langchain 0.0.256 
Python 3.8

### Who can help?

@hwchase17 

### Information

- [ ] The official example notebooks/scripts
- [x] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [X] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

I've developed a Next.js application that uses the Langchain library for chat functionality and is deployed on AWS Amplify. The application works perfectly when running locally, but fails after deployment on AWS Amplify.

The application uses the Langchain library, OpenAIEmbeddings for generating embeddings, and PineconeStore for storing vectors. I've ensured that my environment variables are correctly set up both locally and in the AWS Amplify console.

Here is the code snippet for my chat handler:

```
import type { NextApiRequest, NextApiResponse } from 'next';
import { OpenAIEmbeddings } from 'langchain/embeddings/openai';
import { PineconeStore } from 'langchain/vectorstores/pinecone';
import { makeChain } from '@/utils/makechain';
import { pinecone } from '@/utils/pinecone-client';
import { PINECONE_INDEX_NAME, PINECONE_NAME_SPACE } from '@/config/pinecone';

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse,
) {
  const { question, history } = req.body;

  if (req.method !== 'POST') {
    res.status(405).json({ error: 'Method not allowed' });
    return;
  }

  if (!question) {
    return res.status(400).json({ message: 'No question in the request' });
  }

  const sanitizedQuestion = question.trim().replaceAll('\n', ' ');

  try {
    const index = pinecone.Index(PINECONE_INDEX_NAME);
    const vectorStore = await PineconeStore.fromExistingIndex(
      new OpenAIEmbeddings(),
      {
        pineconeIndex: index,
        textKey: 'text',
        namespace: PINECONE_NAME_SPACE,
      },
    );

    const chain = makeChain(vectorStore);
    const response = await chain.call({
      question: sanitizedQuestion,
      chat_history: history || [],
    });

    res.status(200).json(response);
  } catch (error: any) {
    console.log('chat.ts file error: ', error);
    res.status(500).json({ error: error.message || 'Something went wrong' });
  }
}
```


### Expected behavior

The error message I'm receiving suggests that the Langchain library is assuming I am running on an Azure instance and is expecting an Azure-specific environment variable. However, I am not using Azure, I'm using AWS. The error message states that an 'azureOpenAIApiInstanceName' is missing, which, as I understand, is only relevant if I was using Azure.

Has anyone encountered a similar issue, or have any insights into why this might be happening? I've been unable to find any information in the Langchain library documentation about this Azure dependency.