fix: improve docs and indicate change in expected response

This commit is contained in:
David Holtz 2024-10-02 12:07:25 +00:00
parent 04b409e7ae
commit 6466be8365

View File

@ -311,11 +311,13 @@ print(chat.choices[0].message.tool_calls)
```
### OpenAI integration
### OpenAI Integration
TGI exposes an OpenAI-compatible API, which means you can use OpenAI's client libraries to interact with TGI's Messages API and Tool functions.
Text Generation Inference (TGI) offers seamless integration with OpenAI's client libraries, allowing developers to interact with TGI's Messages API and Tool functions in a familiar way. This compatibility simplifies the implementation of advanced features, such as tools and grammar, within your applications using OpenAIs client.
However there are some minor differences in the API, for example `tool_choice="auto"` will ALWAYS choose the tool for you. This is different from OpenAI's API where `tool_choice="auto"` will choose a tool if the model thinks it's necessary.
Previously, TGI handled tool selection differently than OpenAIs API—`tool_choice="auto"` would always pick a tool for you. However, as of the latest version, TGI now mimics OpenAIs behavior more closely: `tool_choice="auto"` selects a tool only when the model deems it necessary, aligning with how OpenAI's API works. This enhancement ensures a smoother and more predictable integration experience.
Additionally, error notifications like `notify_error`, which previously indicated that no tool was chosen, are no longer returned. Instead, TGI will proceed with generating a response as if no tool was selected, further improving consistency with OpenAI's API.
```python
from openai import OpenAI