rig icon indicating copy to clipboard operation
rig copied to clipboard

feat: Use finish_reason to check if response messages are tool_calls

Open npuichigo opened this issue 2 months ago • 1 comments

  • [x] I have looked for existing issues (including closed) about this

Feature Request

feat: Use finish_reason to check if response messages are tool_calls

Motivation

https://github.com/0xPlaygrounds/rig/blob/8e6f197f27e0bdbda83d356b7c34001d95a2882e/rig-core/src/providers/openai.rs#L381 Currently we check if tool_calls is None, and actually some openai compatible servers like vllm just return empty list of tool_calls and the openai document does not express tool_calls as optional, so it's not save to just check it with None.

Proposal

Check the finish_reason field on tool_calls or add additional check for empty list

Alternatives

Maybe other ways exist to handle this

npuichigo avatar Dec 24 '24 07:12 npuichigo