From 607bab39eb8d9d1da6b5b673b5110d94cf2a3e3a Mon Sep 17 00:00:00 2001 From: Ludwik Trammer Date: Thu, 9 Jan 2025 16:28:57 +0100 Subject: [PATCH] Fix linter errors --- packages/ragbits-core/src/ragbits/core/prompt/promptfoo.py | 2 +- .../src/ragbits/core/utils/dict_transformations.py | 2 +- .../src/ragbits/evaluate/dataset_generator/prompts/qa.py | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/ragbits-core/src/ragbits/core/prompt/promptfoo.py b/packages/ragbits-core/src/ragbits/core/prompt/promptfoo.py index 73d5f679..ea9a4193 100644 --- a/packages/ragbits-core/src/ragbits/core/prompt/promptfoo.py +++ b/packages/ragbits-core/src/ragbits/core/prompt/promptfoo.py @@ -46,5 +46,5 @@ def generate_configs( target_path.mkdir() for prompt in prompts: with open(target_path / f"{prompt.__qualname__}.yaml", "w", encoding="utf-8") as f: - prompt_path = f'file://{prompt.__module__.replace(".", os.sep)}.py:{prompt.__qualname__}.to_promptfoo' + prompt_path = f"file://{prompt.__module__.replace('.', os.sep)}.py:{prompt.__qualname__}.to_promptfoo" yaml.dump({"prompts": [prompt_path]}, f) diff --git a/packages/ragbits-core/src/ragbits/core/utils/dict_transformations.py b/packages/ragbits-core/src/ragbits/core/utils/dict_transformations.py index ae58fc62..617cce76 100644 --- a/packages/ragbits-core/src/ragbits/core/utils/dict_transformations.py +++ b/packages/ragbits-core/src/ragbits/core/utils/dict_transformations.py @@ -98,7 +98,7 @@ def _decompose_key(key: str) -> tuple[str | int | None, str | int | None]: _current_subkey = int(_key[start_subscript_index:end_subscript_index]) if len(_key[end_subscript_index:]) > 1: - _current_subkey = f"{_current_subkey}.{_key[end_subscript_index + 2:]}" + _current_subkey = f"{_current_subkey}.{_key[end_subscript_index + 2 :]}" break elif char == ".": split_work = _key.split(".", 1) diff --git a/packages/ragbits-evaluate/src/ragbits/evaluate/dataset_generator/prompts/qa.py b/packages/ragbits-evaluate/src/ragbits/evaluate/dataset_generator/prompts/qa.py index 40e29078..d9295ae3 100644 --- a/packages/ragbits-evaluate/src/ragbits/evaluate/dataset_generator/prompts/qa.py +++ b/packages/ragbits-evaluate/src/ragbits/evaluate/dataset_generator/prompts/qa.py @@ -23,7 +23,7 @@ class BasicAnswerGenPrompt(Prompt[BasicAnswerGenInput, str]): "If you don't know the answer just say: I don't know." ) - user_prompt: str = "Text:\n<|text_start|>\n {{ chunk }} \n<|text_end|>\n\nQuestion:\n " "{{ question }} \n\nAnswer:" + user_prompt: str = "Text:\n<|text_start|>\n {{ chunk }} \n<|text_end|>\n\nQuestion:\n {{ question }} \n\nAnswer:" class PassagesGenInput(BaseModel): @@ -49,9 +49,7 @@ class PassagesGenPrompt(Prompt[PassagesGenInput, str]): "FULL SENTENCES" ) - user_prompt: str = ( - "Question:\n {{ question }} \nAnswer:\n {{ basic_answer }} \nChunk:\n " "{{ chunk }}\n\nPassages:" - ) + user_prompt: str = "Question:\n {{ question }} \nAnswer:\n {{ basic_answer }} \nChunk:\n {{ chunk }}\n\nPassages:" class QueryGenInput(BaseModel):