KeyError: 'usage'
Labels: name: auto:bug, name: area: models

### System Info

langchain                 0.0.353
langchain-community       0.0.7
langchain-core            0.1.4
langchain-experimental    0.0.47
Python 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] on linuxd
openai                    0.28.0

### Who can help?

_No response_

### Information

- [ ] 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
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python
import os  
from langchain.llms import AzureOpenAI
from langchain.agents import initialize_agent, AgentType, AgentExecutor  
from langchain.chat_models import ChatOpenAI  
from langchain.prompts import PromptTemplate, ChatPromptTemplate, MessagesPlaceholder  
from langchain.tools import tool  
import openai

os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-06-01-preview"
os.environ["OPENAI_API_BASE"] = "xxx"
os.environ["OPENAI_API_KEY"] = "xxx"

 
prompt_template = ChatPromptTemplate.from_messages([  
    ("system", "You are a powerful assistant. But you do not know how to calculate the length of a word"),  
    ("user", "{input}"), 
])  


llm = AzureOpenAI(
    model_name="gpt-4",
    engine="gpt-4"
)


@tool  
def get_word_length(word):  
    """get the length of a word"""  
    return len(word)  


tools = [get_word_length]  

agent = initialize_agent(  
    tools,  
    llm,  
    agent=AgentType.OPENAI_FUNCTIONS,  
    verbose=True  
)  

agent.run("how many letters are there in Oslo and Beijing?")
```

```
> Entering new AgentExecutor chain...
Traceback (most recent call last):
  File "/mnt/workspace/workgroup/lengmou/Tars-Code-Agent/pages/5.py", line 115, in <module>
    agent.run("how many letters are there in Oslo and Beijing?")
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/chains/base.py", line 507, in run
    return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/chains/base.py", line 312, in __call__
    raise e
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/chains/base.py", line 306, in __call__
    self._call(inputs, run_manager=run_manager)
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/agents/agent.py", line 1312, in _call
    next_step_output = self._take_next_step(
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/agents/agent.py", line 1038, in _take_next_step
    [
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/agents/agent.py", line 1038, in <listcomp>
    [
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/agents/agent.py", line 1066, in _iter_next_step
    output = self.agent.plan(
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain/agents/openai_functions_agent/base.py", line 96, in plan
    predicted_message = self.llm.predict_messages(
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain_core/language_models/llms.py", line 946, in predict_messages
    content = self(text, stop=_stop, **kwargs)
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain_core/language_models/llms.py", line 892, in __call__
    self.generate(
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain_core/language_models/llms.py", line 666, in generate
    output = self._generate_helper(
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain_core/language_models/llms.py", line 553, in _generate_helper
    raise e
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain_core/language_models/llms.py", line 540, in _generate_helper
    self._generate(
  File "/mnt/workspace/workgroup/shared/miniconda3/envs/code-agent/lib/python3.10/site-packages/langchain_community/llms/openai.py", line 1152, in _generate
    "token_usage": full_response["usage"],
KeyError: 'usage'
```



### Expected behavior

Please look at this issue, thanks!