diff --git a/src/interprompt/.syncCommitId.remote b/src/interprompt/.syncCommitId.remote index 5a40a2ff..f7383b65 100644 --- a/src/interprompt/.syncCommitId.remote +++ b/src/interprompt/.syncCommitId.remote @@ -1 +1 @@ -80e4ea6514dc93a668931ccab94a88ade675ec2a \ No newline at end of file +edbee70392dca692d36d136c47a61513f4a2b222 \ No newline at end of file diff --git a/src/interprompt/.syncCommitId.this b/src/interprompt/.syncCommitId.this deleted file mode 100644 index 1c4b3691..00000000 --- a/src/interprompt/.syncCommitId.this +++ /dev/null @@ -1 +0,0 @@ -17e39c9655e947ff6d6809e3638f97d113a1947e \ No newline at end of file diff --git a/src/interprompt/jinja_template.py b/src/interprompt/jinja_template.py index 85dec9fe..174b38ef 100644 --- a/src/interprompt/jinja_template.py +++ b/src/interprompt/jinja_template.py @@ -6,7 +6,7 @@ import jinja2.nodes import jinja2.visitor from jinja2.sandbox import SandboxedEnvironment -from interprompt.util.class_decorators import singleton +from .util.class_decorators import singleton class ParameterizedTemplateInterface: diff --git a/src/interprompt/multilang_prompt.py b/src/interprompt/multilang_prompt.py index ba953b4c..48b1ebe3 100644 --- a/src/interprompt/multilang_prompt.py +++ b/src/interprompt/multilang_prompt.py @@ -325,7 +325,8 @@ class MultiLangPromptCollection: except KeyError as e: raise KeyError(f"Invalid yaml structure (missing 'prompts' key) in file {path}") from e - lang_code = prompts_data.get("lang", DEFAULT_LANG_CODE) + lang_code = data.get("lang", DEFAULT_LANG_CODE) + # add the data to the collection for prompt_name, prompt_template_or_list in prompts_data.items(): if isinstance(prompt_template_or_list, list): diff --git a/src/interprompt/prompt_factory.py b/src/interprompt/prompt_factory.py index 647b0ed2..599be189 100644 --- a/src/interprompt/prompt_factory.py +++ b/src/interprompt/prompt_factory.py @@ -40,7 +40,8 @@ class PromptFactoryBase: return self._prompt_collection.get_prompt_list(prompt_name, self.lang_code) -def autogenerate_prompt_factory_module(prompts_dir: str, target_module_path: str) -> None: +def autogenerate_prompt_factory_module(prompts_dir: str, target_module_path: str, interprompt_library_package: str = "interprompt", + class_name: str = "PromptFactory") -> None: """ Auto-generates a prompt factory module for the given prompt directory. The generated `PromptFactory` class is meant to be the central entry class for retrieving and rendering prompt templates and prompt @@ -49,18 +50,20 @@ def autogenerate_prompt_factory_module(prompts_dir: str, target_module_path: str :param prompts_dir: the directory containing the prompt templates and prompt lists :param target_module_path: the path to the target module file (.py). Important: The module will be overwritten! + :param interprompt_library_package: the package name of the interprompt library + :param class_name: the name of the generated prompt factory class """ - generated_code = """# ruff: noqa + generated_code = f"""# ruff: noqa # black: skip # mypy: ignore-errors # NOTE: This module is auto-generated from interprompt.autogenerate_prompt_factory_module, do not edit manually! -from interprompt.prompt_factory import PromptFactoryBase +from {interprompt_library_package}.prompt_factory import * from typing import Any -class PromptFactory(PromptFactoryBase): +class {class_name}(PromptFactoryBase): \""" A class for retrieving and rendering prompt templates and prompt lists. \"""