Skip to content

Added 'strict' parameter for template retrieval #1124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2025

Conversation

Lyrcaxis
Copy link
Contributor

@Lyrcaxis Lyrcaxis commented Mar 7, 2025

This PR adds an additional check to the LLamaTemplate constructor and Model.GetTemplate(), causing it to throw an exception if a valid template was expected to be returned (strict = true) but could not be found.

This aims to avoid accidental confusion for users that try to use LLamaSharp's auto-template-formatting functionalities with a model whose template is either not supported or not found (e.g. base model vs instruct model).

The default behaviour can be disabled by passing strict = false when calling to retrieve the template.

@Lyrcaxis Lyrcaxis requested a review from martindevans March 7, 2025 17:35
Copy link
Member

@martindevans martindevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@martindevans martindevans merged commit 413fb4d into SciSharp:master Mar 8, 2025
6 checks passed
@Lyrcaxis Lyrcaxis deleted the null-template-safety branch March 8, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants