InvalidRequestError: Unrecognized request argument supplied: functions
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

Python 3.11.4
LangChain 0.0.321

Platform info (WSL2):
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

This is my code (based on https://python.langchain.com/docs/use_cases/question_answering/conversational_retrieval_agents and modified to use AzureOpenAI and OpenSearch):

```pyhton
import os
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.chat_models.azure_openai import AzureChatOpenAI
from langchain.vectorstores.opensearch_vector_search import OpenSearchVectorSearch
from langchain.memory import ConversationTokenBufferMemory

from langchain.prompts import (
    ChatPromptTemplate,
    MessagesPlaceholder,
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
)

from langchain.chains import ConversationalRetrievalChain


# Load environment variables
host = os.environ['HOST']
auth = os.environ['AUTH_PASS']
index_uk = os.environ['INDEX_NAME_UK']
opensearch_url = os.environ['OPENSEARCH_URL']
embedding_model = os.environ['EMBEDDING_MODEL']
model_name = os.environ['MODEL_NAME']

openai_api_base = os.environ['OPENAI_API_BASE']
openai_api_key = os.environ['OPENAI_API_KEY']
openai_api_type = os.environ['OPENAI_API_TYPE']
openai_api_version = os.environ['OPENAI_API_VERSION']

# Define Azure OpenAI component
llm = AzureChatOpenAI(
    openai_api_key = openai_api_key,
    openai_api_base = openai_api_base,
    openai_api_type = openai_api_type,
    openai_api_version = openai_api_version,
    deployment_name = model_name,
    temperature=0
)

# Define Memory component for chat history
memory = ConversationTokenBufferMemory(llm=llm,memory_key="chat_history",return_messages=True, max_token_limit=1000)

# Build a Retriever
embeddings = OpenAIEmbeddings(deployment=embedding_model, chunk_size=1)
docsearch = OpenSearchVectorSearch(index_name=index_uk, embedding_function=embeddings,opensearch_url=opensearch_url, http_auth=('admin', auth))
doc_retriever = docsearch.as_retriever()

# Build a retrieval tool
from langchain.agents.agent_toolkits import create_retriever_tool
tool = create_retriever_tool(
    doc_retriever, 
    "search_hr_documents",
    "Searches and returns documents regarding HR questions."
)
tools = [tool]

# Build an Agent Constructor
from langchain.agents.agent_toolkits import create_conversational_retrieval_agent
agent_executor = create_conversational_retrieval_agent(llm, tools, verbose=True)

result = agent_executor({"input": "hi, im bob"})
```

When I execute it, it generates the log error below:

```
InvalidRequestError                       Traceback (most recent call last)
[c:\k8s-developer\git\lambda-hr-docQA\conv_retrieval_tool.ipynb](file:///C:/k8s-developer/git/lambda-hr-docQA/conv_retrieval_tool.ipynb) Cell 3 line 6
     [58](vscode-notebook-cell:/c%3A/k8s-developer/git/lambda-hr-docQA/conv_retrieval_tool.ipynb#W2sZmlsZQ%3D%3D?line=57) from langchain.agents.agent_toolkits import create_conversational_retrieval_agent
     [59](vscode-notebook-cell:/c%3A/k8s-developer/git/lambda-hr-docQA/conv_retrieval_tool.ipynb#W2sZmlsZQ%3D%3D?line=58) agent_executor = create_conversational_retrieval_agent(llm, tools, verbose=True)
---> [61](vscode-notebook-cell:/c%3A/k8s-developer/git/lambda-hr-docQA/conv_retrieval_tool.ipynb#W2sZmlsZQ%3D%3D?line=60) result = agent_executor({"input": "hi, im bob"})

File [c:\Users\fezzef\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain\chains\base.py:310](file:///C:/Users/fezzef/AppData/Local/Programs/Python/Python311/Lib/site-packages/langchain/chains/base.py:310), in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info)
    308 except BaseException as e:
    309     run_manager.on_chain_error(e)
--> 310     raise e
    311 run_manager.on_chain_end(outputs)
    312 final_outputs: Dict[str, Any] = self.prep_outputs(
    313     inputs, outputs, return_only_outputs
    314 )
File [c:\Users\fezzef\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain\agents\openai_functions_agent\base.py:104](file:///C:/Users/fezzef/AppData/Local/Programs/Python/Python311/Lib/site-packages/langchain/agents/openai_functions_agent/base.py:104), in OpenAIFunctionsAgent.plan(self, intermediate_steps, callbacks, with_functions, **kwargs)
    102 messages = prompt.to_messages()
    103 if with_functions:
--> 104     predicted_message = self.llm.predict_messages(
    105         messages,
    106         functions=self.functions,
    107         callbacks=callbacks,
    108     )
    109 else:
    110     predicted_message = self.llm.predict_messages(
    111         messages,
    112         callbacks=callbacks,
    113     )
InvalidRequestError: Unrecognized request argument supplied: functions
```

I suspect the `OpenAIFunctionsAgent` is not compatible with AzureOpenAI. I'm not sure. Please check and let me know.

### Expected behavior

It should be getting a response but LangChain throws an error