Skip to content

ChatHuggingFace does not include tools in prompt with local HuggingFacePipeline #29033

@edmcman

Description

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

Please see this notebook

Error Message and Stack Trace (if applicable)

Note that the prompt does not include any tools:

ai_msg: content='<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nCutting Knowledge Date: December 2023\nToday Date: 05 Jan 2025\n\n<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWhich city is hotter today and which is bigger: LA or NY?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nAs of my cut-off knowledge date (01 March 2023), I can provide information on the' additional_kwargs={} response_metadata={} id='run-4089df0b-879c-461f-900b-60ae362612ae-0'

Description

  • I am trying to use tools with a local HuggingFace model.
  • The ChatHuggingFace documentation suggests that tools are supported, but the generated prompt does not include tools bound with bind_tools.

It's unclear if this is a documentation issue or just a mistake in the code. Since the HuggingFace tokenizer supports tool calling, I think it should be fairly easy to pass the tools to the tokenizer.

System Info

System Information

OS: Linux
OS Version: #1 SMP PREEMPT_DYNAMIC Thu Jun 27 21:05:47 UTC 2024
Python Version: 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0]

Package Information

langchain_core: 0.3.25
langchain: 0.3.12
langsmith: 0.2.3
langchain_huggingface: 0.1.2
langchain_text_splitters: 0.3.3

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.11.10
async-timeout: 4.0.3
httpx: 0.28.1
huggingface-hub: 0.27.0
jsonpatch: 1.33
langsmith-pyo3: Installed. No version info available.
numpy: 1.26.4
orjson: 3.10.12
packaging: 24.2
pydantic: 2.10.3
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
sentence-transformers: 3.3.1
SQLAlchemy: 2.0.36
tenacity: 9.0.0
tokenizers: 0.21.0
transformers: 4.47.1
typing-extensions: 4.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalhuggingface`langchain-huggingface` package issues & PRsintegrationPR made that is related to a provider partner package integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions