haystack icon indicating copy to clipboard operation
haystack copied to clipboard

HuggingFace API does not support `$defs` field in tool parameter schema

Open sjrl opened this issue 7 months ago • 2 comments

While working on https://github.com/deepset-ai/haystack/pull/9342 we found that the HuggingFaceAPIChatGenerator does not support tool parameter schemas with $defs field which is supported by other LLM providers like OpenAI.

There is an open issue for this here https://github.com/huggingface/text-generation-inference/issues/2876.

We could also address this in the HuggingFaceAPIChatGenerator by updating the incoming tool schema to insert all $defs into parameters and then remove the $defs field. This workaround will be needed if any user wishes to use ComponentTool where one of the input parameters of the tool is a dataclass (e.g. ChatMessage, Document) since our new auto tool parameter schema generation (powered by pydantic) always places dataclass definitions into the $defs field.

Originally posted by @sjrl in https://github.com/deepset-ai/haystack/issues/9342#issuecomment-2879664220

sjrl avatar May 15 '25 07:05 sjrl

Google Gemini doesn't support it either. The workaround is to expand these refs as we did in https://github.com/deepset-ai/haystack-core-integrations/pull/1875

vblagoje avatar May 30 '25 14:05 vblagoje

Based on @vblagoje's comment the easiest way to do this is to use replace_refs from json_ref

sjrl avatar Jun 02 '25 08:06 sjrl