Issue with transformers==4.29.0 and openai==1.3.4 Integration
Author: Strive-for-excellence
Pull request: no

### System Info


transformers==4.29.0
openai==1.3.4
When running the code provided in the version openai==1.3.4, which can be found at the following link: https://huggingface.co/docs/transformers/transformers_agents, an error occurs:

```
APIRemovedInV1                            Traceback (most recent call last)
[<ipython-input-6-4578d52c5ccf>](https://localhost:8080/#) in <cell line: 1>()
----> 1 boat = agent.run("Generate an image of a boat in the water")
      2 boat

5 frames
[/usr/local/lib/python3.10/dist-packages/transformers/tools/agents.py](https://localhost:8080/#) in run(self, task, return_code, remote, **kwargs)
    312         """
    313         prompt = self.format_prompt(task)
--> 314         result = self.generate_one(prompt, stop=["Task:"])
    315         explanation, code = clean_code_for_run(result)
    316 

[/usr/local/lib/python3.10/dist-packages/transformers/tools/agents.py](https://localhost:8080/#) in generate_one(self, prompt, stop)
    407             return self._chat_generate(prompt, stop)
    408         else:
--> 409             return self._completion_generate([prompt], stop)[0]
    410 
    411     def _chat_generate(self, prompt, stop):

[/usr/local/lib/python3.10/dist-packages/transformers/tools/agents.py](https://localhost:8080/#) in _completion_generate(self, prompts, stop)
    419 
    420     def _completion_generate(self, prompts, stop):
--> 421         result = openai.Completion.create(
    422             model=self.model,
    423             prompt=prompts,

[/usr/local/lib/python3.10/dist-packages/openai/_utils/_proxy.py](https://localhost:8080/#) in __getattr__(self, attr)
     20 
     21     def __getattr__(self, attr: str) -> object:
---> 22         return getattr(self.__get_proxied__(), attr)
     23 
     24     @override

[/usr/local/lib/python3.10/dist-packages/openai/_utils/_proxy.py](https://localhost:8080/#) in __get_proxied__(self)
     41     def __get_proxied__(self) -> T:
     42         if not self.should_cache:
---> 43             return self.__load__()
     44 
     45         proxied = self.__proxied

[/usr/local/lib/python3.10/dist-packages/openai/lib/_old_api.py](https://localhost:8080/#) in __load__(self)
     31     @override
     32     def __load__(self) -> None:
---> 33         raise APIRemovedInV1(symbol=self._symbol)
     34 
     35 

APIRemovedInV1: 

You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
```

The error traceback indicates an issue within the file 'transformers/tools/agents.py':


```
    def _chat_generate(self, prompt, stop):
        result = openai.ChatCompletion.create(
            model=self.model,
            messages=[{"role": "user", "content": prompt}],
            temperature=0,
            stop=stop,
        )
        return result["choices"][0]["message"]["content"]
```

To resolve this issue, you can update the code in 'transformers/tools/agents.py' as follows:

```
    def _chat_generate(self, prompt, stop):
        result = openai.chat.completions.create(
            model=self.model,
            messages=[{"role": "user", "content": prompt}],
            temperature=0,
            stop=stop,
        )
        return result.choices[0].message.content
```



### Who can help?

@Narsil @stevhliu 

### Information

- [x] The official example scripts
- [ ] My own modified scripts

### Tasks

- [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

from transformers import tools
from transformers.tools import OpenAiAgent

API_KEY = '**'

agent = OpenAiAgent(model='gpt-4',api_key=API_KEY)
boat = agent.run("Generate an image of a boat in the water")
boat


### Expected behavior

Updating the code would be a better solution.

Comments:
Hey! Thanks for reporting 🤗 would you like to open a PR for a fix?