From 213430a122879632f59322cdab000cb54855770e Mon Sep 17 00:00:00 2001 From: kingbri Date: Sun, 12 May 2024 22:24:28 -0400 Subject: [PATCH] Model/Grammar: Remove lmfe checks lmfe is a required dependency, so checks are no longer needed. Signed-off-by: kingbri --- backends/exllamav2/grammar.py | 36 ++--------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/backends/exllamav2/grammar.py b/backends/exllamav2/grammar.py index f34c112..1b2ed3c 100644 --- a/backends/exllamav2/grammar.py +++ b/backends/exllamav2/grammar.py @@ -2,6 +2,8 @@ import traceback from exllamav2 import ExLlamaV2, ExLlamaV2Tokenizer from exllamav2.generator import ExLlamaV2Sampler from exllamav2.generator.filters import ExLlamaV2Filter, ExLlamaV2PrefixFilter +from lmformatenforcer import JsonSchemaParser, RegexParser +from lmformatenforcer.integrations.exllamav2 import ExLlamaV2TokenEnforcerFilter from loguru import logger @@ -61,23 +63,6 @@ class ExLlamaV2Grammar: ): """Adds an ExllamaV2 filter based on a JSON schema.""" - # Import optional dependencies - try: - from lmformatenforcer import JsonSchemaParser - from lmformatenforcer.integrations.exllamav2 import ( - ExLlamaV2TokenEnforcerFilter, - ) - except ImportError: - logger.error( - "Skipping JSON schema parsing because " - "lm-format-enforcer is not installed.\n" - "Please run the following command in your environment " - "to reinstall dependencies:\n" - "pip install -U ." - ) - - return - # Create the parser try: schema_parser = JsonSchemaParser(json_schema) @@ -105,23 +90,6 @@ class ExLlamaV2Grammar: ): """Adds an ExllamaV2 filter based on regular expressions.""" - # Import optional dependencies - try: - from lmformatenforcer import RegexParser - from lmformatenforcer.integrations.exllamav2 import ( - ExLlamaV2TokenEnforcerFilter, - ) - except ImportError: - logger.error( - "Skipping regex parsing because " - "lm-format-enforcer is not installed.\n" - "Please run the following command in your environment " - "to reinstall dependencies:\n" - "pip install -U ." - ) - - return - # Create the parser try: pattern_parser = RegexParser(pattern)