feat: Support OpenAI Tools API, including multi-tool generation and handling. Previously only the function-call API was supported, which is now deprecrated by OpenAI.
In particular this means langroid can be used with Ollama's new OpenAI-compatible tools support.
(Note that langroid-native tools have always worked with any strong-enough LLM, since langroid translates Pydantic-based tool definitions to JSON instructions in the system msg).
To use the tools api, you must set:
- `ChatAgentConfig.use_functions_api = True`
- `ChatAgentCofig.use_tools_api = True` (default is `False`)
The first option above is a flag to decide between using OpenAI tools OR functions API rather than using Langroid-native Tools.
The second option is only considered when `use_functions_api` is `True`: in this case if `use_tools_api=True`, then the tools API is used, else the
older/deprecated function-calling API is used.
The reason we default the second option to `False` is that there are some tricky aspects to the tools API, e.g. it is more "strict", in the sense a tool-call message must be followed by messages containing results, which the functions API does not enforce. Langroid has mechanisms to ensure the tools API works correctly, however in practice we find the functions API OR the langroid Tools more straightforward to work. The strictness of the tools API makes some agent workflows harder to achieve, e.g. where a tool is sent by one agent and executed by another. Also, multi-tool generation, while it sounds useful, brings some complications in agent workflows. Again, langroid does ensure these work correctly in most scenarios, but it's possible some edge cases remain.