From dd19fb2e5aa39a035c0a319959d1e0ce7111ee5d Mon Sep 17 00:00:00 2001 From: Shroominic Date: Fri, 1 Dec 2023 21:02:59 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix=20pre-commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/funcchain/_llms.py | 4 ++-- src/funcchain/streaming.py | 3 ++- src/funcchain/utils/json_schema_to_grammar.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/funcchain/_llms.py b/src/funcchain/_llms.py index 4aed78a..8390d6e 100644 --- a/src/funcchain/_llms.py +++ b/src/funcchain/_llms.py @@ -123,8 +123,8 @@ class _LlamaCppCommon(BaseLanguageModel): """ grammar: Optional[str] = None """ - grammar: formal grammar for constraining model outputs. For instance, the grammar - can be used to force the model to generate valid JSON or to speak exclusively in + grammar: formal grammar for constraining model outputs. For instance, the grammar + can be used to force the model to generate valid JSON or to speak exclusively in emojis. At most one of grammar_path and grammar should be passed in. """ diff --git a/src/funcchain/streaming.py b/src/funcchain/streaming.py index 34b3c68..2697400 100644 --- a/src/funcchain/streaming.py +++ b/src/funcchain/streaming.py @@ -85,7 +85,8 @@ def stream_to( >>> with stream_to(print): ... # your chain calls here """ - import builtins, rich + import builtins + import rich # TODO: set streaming to true specifically in this context if (fn is builtins.print or fn is rich.print) and kwargs == {}: diff --git a/src/funcchain/utils/json_schema_to_grammar.py b/src/funcchain/utils/json_schema_to_grammar.py index bb5a3b9..eb86c4f 100644 --- a/src/funcchain/utils/json_schema_to_grammar.py +++ b/src/funcchain/utils/json_schema_to_grammar.py @@ -31,7 +31,8 @@ def __init__(self, prop_order: dict, defs: dict) -> None: def _format_literal(self, literal: str) -> str: escaped = GRAMMAR_LITERAL_ESCAPE_RE.sub( - lambda m: GRAMMAR_LITERAL_ESCAPES.get(m.group(0)), json.dumps(literal) # type: ignore + lambda m: GRAMMAR_LITERAL_ESCAPES.get(m.group(0)), # type: ignore + json.dumps(literal), ) return f'"{escaped}"'