Commits
Click on a commit to change the comparison rangefeat: Allow passing tokenizer template values to HuggingFace chat models
This commit introduces two ways for you to customize chat templating when using `ChatHuggingFace`:
1. **Custom Chat Template String**:
A new `chat_template` parameter has been added to the `ChatHuggingFace`
constructor. This allows you to provide a custom Jinja template string,
which will be assigned to `tokenizer.chat_template` after the tokenizer is
loaded. This gives you full control over the chat prompt formatting if
the default template associated with a model is not suitable or if you
want to experiment with different prompt structures.
2. **Dynamic Template Variables via `**kwargs`**:
The `_to_chat_prompt` method in `ChatHuggingFace` (which is responsible for
formatting messages using `tokenizer.apply_chat_template`) has been
modified to accept arbitrary keyword arguments (`**kwargs`). These `kwargs`
are then passed directly to `tokenizer.apply_chat_template`.
This allows you to define variables in your Jinja chat templates (either
the default one or a custom one) and provide values for these variables
dynamically during calls to `invoke`, `stream`, `generate`, etc.
Unit tests have been added to verify these new functionalities, including
setting custom templates and passing keyword arguments to `apply_chat_template`.
Documentation has been updated in the `ChatHuggingFace` class docstring and
in the HuggingFace integration notebook (`docs/docs/integrations/chat/huggingface.ipynb`)
to explain these new features with examples.
This change addresses issue #31470 by providing a flexible way for you to pass
tokenizer template values, interpreted as HuggingFace chat template strings
and variables for those Jinja templates.20 days ago
by google-labs-jules[bot] feat: Allow passing tokenizer template values to HuggingFace chat models
This commit introduces two ways for you to customize chat templating when using `ChatHuggingFace`:
1. **Custom Chat Template String**:
A new `chat_template` parameter has been added to the `ChatHuggingFace`
constructor. This allows you to provide a custom Jinja template string,
which will be assigned to `tokenizer.chat_template` after the tokenizer is
loaded. This gives you full control over the chat prompt formatting if
the default template associated with a model is not suitable or if you
want to experiment with different prompt structures.
2. **Dynamic Template Variables via `**kwargs`**:
The `_to_chat_prompt` method in `ChatHuggingFace` (which is responsible for
formatting messages using `tokenizer.apply_chat_template`) has been
modified to accept arbitrary keyword arguments (`**kwargs`). These `kwargs`
are then passed directly to `tokenizer.apply_chat_template`.
This allows you to define variables in your Jinja chat templates (either
the default one or a custom one) and provide values for these variables
dynamically during calls to `invoke`, `stream`, `generate`, etc.
Unit tests have been added to verify these new functionalities, including
setting custom templates and passing keyword arguments to `apply_chat_template`.
Documentation has been updated in the `ChatHuggingFace` class docstring and
in the HuggingFace integration notebook (`docs/docs/integrations/chat/huggingface.ipynb`)
to explain these new features with examples.
Linting errors (E501 Line too long) found in a previous CI run have been fixed.
This change addresses issue #31470 by providing a flexible way for you to pass
tokenizer template values, interpreted as HuggingFace chat template strings
and variables for those Jinja templates.20 days ago
by google-labs-jules[bot] feat: Allow passing tokenizer template values to HuggingFace chat models
This commit introduces two ways for you to customize chat templating when using `ChatHuggingFace`:
1. **Custom Chat Template String**:
A new `chat_template` parameter has been added to the `ChatHuggingFace`
constructor. This allows you to provide a custom Jinja template string,
which will be assigned to `tokenizer.chat_template` after the tokenizer is
loaded. This gives you full control over the chat prompt formatting if
the default template associated with a model is not suitable or if you
want to experiment with different prompt structures.
2. **Dynamic Template Variables via `**kwargs`**:
The `_to_chat_prompt` method in `ChatHuggingFace` (which is responsible for
formatting messages using `tokenizer.apply_chat_template`) has been
modified to accept arbitrary keyword arguments (`**kwargs`). These `kwargs`
are then passed directly to `tokenizer.apply_chat_template`.
This allows you to define variables in your Jinja chat templates (either
the default one or a custom one) and provide values for these variables
dynamically during calls to `invoke`, `stream`, `generate`, etc.
Unit tests have been added to verify these new functionalities, including
setting custom templates and passing keyword arguments to `apply_chat_template`.
Documentation has been updated in the `ChatHuggingFace` class docstring and
in the HuggingFace integration notebook (`docs/docs/integrations/chat/huggingface.ipynb`)
to explain these new features with examples.
Linting errors (E501 Line too long) found in a previous CI run have been fixed by
reformatting dictionary comprehensions and other long lines.
This change addresses issue #31470 by providing a flexible way for you to pass
tokenizer template values, interpreted as HuggingFace chat template strings
and variables for those Jinja templates.20 days ago
by google-labs-jules[bot] feat: Allow passing tokenizer template values to HuggingFace chat models
This commit introduces two ways for you to customize chat templating when using `ChatHuggingFace`:
1. **Custom Chat Template String**:
A new `chat_template` parameter has been added to the `ChatHuggingFace`
constructor. This allows you to provide a custom Jinja template string,
which will be assigned to `tokenizer.chat_template` after the tokenizer is
loaded. This gives you full control over the chat prompt formatting if
the default template associated with a model is not suitable or if you
want to experiment with different prompt structures.
2. **Dynamic Template Variables via `**kwargs`**:
The `_to_chat_prompt` method in `ChatHuggingFace` (which is responsible for
formatting messages using `tokenizer.apply_chat_template`) has been
modified to accept arbitrary keyword arguments (`**kwargs`). These `kwargs`
are then passed directly to `tokenizer.apply_chat_template`.
This allows you to define variables in your Jinja chat templates (either
the default one or a custom one) and provide values for these variables
dynamically during calls to `invoke`, `stream`, `generate`, etc.
Unit tests have been added to verify these new functionalities, including
setting custom templates and passing keyword arguments to `apply_chat_template`.
Documentation has been updated in the `ChatHuggingFace` class docstring and
in the HuggingFace integration notebook (`docs/docs/integrations/chat/huggingface.ipynb`)
to explain these new features with examples.
Further fixes for E501 (Line too long) linting errors based on CI feedback.
This change addresses issue #31470 by providing a flexible way to pass
tokenizer template values, interpreted as HuggingFace chat template strings
and variables for those Jinja templates.20 days ago
by google-labs-jules[bot] feat: Allow passing tokenizer template values to HuggingFace chat models
This commit introduces two ways you can customize chat templating when using `ChatHuggingFace`:
1. **Custom Chat Template String**:
A new `chat_template` parameter has been added to the `ChatHuggingFace`
constructor. This allows you to provide a custom Jinja template string,
which will be assigned to `tokenizer.chat_template` after the tokenizer is
loaded. This gives you full control over the chat prompt formatting if
the default template associated with a model is not suitable or if you
want to experiment with different prompt structures.
2. **Dynamic Template Variables via `**kwargs`**:
The `_to_chat_prompt` method in `ChatHuggingFace` (which is responsible for
formatting messages using `tokenizer.apply_chat_template`) has been
modified to accept arbitrary keyword arguments (`**kwargs`). These `kwargs`
are then passed directly to `tokenizer.apply_chat_template`.
This allows you to define variables in your Jinja chat templates (either
the default one or a custom one) and provide values for these variables
dynamically during calls to `invoke`, `stream`, `generate`, etc.
Unit tests have been added to verify these new functionalities, including
setting custom templates and passing keyword arguments to `apply_chat_template`.
Documentation has been updated in the `ChatHuggingFace` class docstring and
in the HuggingFace integration notebook (`docs/docs/integrations/chat/huggingface.ipynb`)
to explain these new features with examples.
This commit also includes comprehensive linting and formatting fixes for the
`libs/partners/huggingface` directory to align with project standards,
including `pyupgrade`, `ruff`, `black`, and `isort` changes.
This change addresses issue #31470 by providing a flexible way to pass
tokenizer template values, interpreted as HuggingFace chat template strings
and variables for those Jinja templates.20 days ago
by google-labs-jules[bot] feat: Allow passing tokenizer template values to HuggingFace chat models
This commit introduces two ways to customize chat templating when using `ChatHuggingFace`:
1. **Custom Chat Template String**:
A new `chat_template` parameter has been added to the `ChatHuggingFace`
constructor. This allows you to provide a custom Jinja template string,
which will be assigned to `tokenizer.chat_template` after the tokenizer is
loaded. This gives you full control over the chat prompt formatting if
the default template associated with a model is not suitable or if you
want to experiment with different prompt structures.
2. **Dynamic Template Variables via `**kwargs`**:
The `_to_chat_prompt` method in `ChatHuggingFace` (which is responsible for
formatting messages using `tokenizer.apply_chat_template`) has been
modified to accept arbitrary keyword arguments (`**kwargs`). These `kwargs`
are then passed directly to `tokenizer.apply_chat_template`.
This allows you to define variables in your Jinja chat templates (either
the default one or a custom one) and provide values for these variables
dynamically during calls to `invoke`, `stream`, `generate`, etc.
Unit tests have been added to verify these new functionalities, including
setting custom templates and passing keyword arguments to `apply_chat_template`.
Documentation has been updated in the `ChatHuggingFace` class docstring and
in the HuggingFace integration notebook (`docs/docs/integrations/chat/huggingface.ipynb`)
to explain these new features with examples.
This commit also includes comprehensive linting and formatting fixes for the
`libs/partners/huggingface` directory to align with project standards,
including `pyupgrade`, `ruff --fix`, `black`, `isort`, and `ruff format` changes.
This change addresses issue #31470 by providing a flexible way to pass
tokenizer template values, interpreted as HuggingFace chat template strings
and variables for those Jinja templates.20 days ago
by google-labs-jules[bot] feat: Allow passing tokenizer template values to HuggingFace chat models
This commit introduces two ways you can customize chat templating when using `ChatHuggingFace`:
1. **Custom Chat Template String**:
A new `chat_template` parameter has been added to the `ChatHuggingFace`
constructor. This allows you to provide a custom Jinja template string,
which will be assigned to `tokenizer.chat_template` after the tokenizer is
loaded. This gives you full control over the chat prompt formatting if
the default template associated with a model is not suitable or if you
want to experiment with different prompt structures.
2. **Dynamic Template Variables via `**kwargs`**:
The `_to_chat_prompt` method in `ChatHuggingFace` (which is responsible for
formatting messages using `tokenizer.apply_chat_template`) has been
modified to accept arbitrary keyword arguments (`**kwargs`). These `kwargs`
are then passed directly to `tokenizer.apply_chat_template`.
This allows you to define variables in your Jinja chat templates (either
the default one or a custom one) and provide values for these variables
dynamically during calls to `invoke`, `stream`, `generate`, etc.
Unit tests have been added to verify these new functionalities, including
setting custom templates and passing keyword arguments to `apply_chat_template`.
Documentation has been updated in the `ChatHuggingFace` class docstring and
in the HuggingFace integration notebook (`docs/docs/integrations/chat/huggingface.ipynb`)
to explain these new features with examples.
This commit also includes comprehensive linting and formatting fixes for the
`libs/partners/huggingface` directory to align with project standards.
This includes:
- Fixing E501 (line too long) errors.
- Correcting an invalid `type: ignore[import]` comment in `llms/huggingface_endpoint.py`.
- Resolving an `AttributeError` in mypy for `tests/unit_tests/test_chat_models.py`.
- Ensuring `pyupgrade`, `ruff`, `black`, and `isort` checks pass.
This change addresses issue #31470 by providing a flexible way to pass
tokenizer template values, interpreted as HuggingFace chat template strings
and variables for those Jinja templates.17 days ago
by google-labs-jules[bot]