mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 12:15:10 +00:00
interprompt edbee70392dca692d36d136c47a61513f4a2b222
commit edbee70392dca692d36d136c47a61513f4a2b222 Author: Dominik Jain <dominik.jain@outlook.com> Date: Fri Aug 14 20:49:45 2026 +0200 Sync reframer commit 8f0e933cca9481a57ccabf1ef9419815274cdfa1 Author: Dominik Jain <dominik.jain@outlook.com> Date: Fri Aug 14 19:56:51 2026 +0200 Allow to configure name of generated class reframer/interprompt/prompt_factory.py commit 7eb3472cec8179a19e1f127ecbdeadf50becab01 Author: Dominik Jain <dominik.jain@outlook.com> Date: Fri Aug 14 19:48:49 2026 +0200 Allow to configure interprompt package name and fix imports in generated code (must include PromptList) reframer/interprompt/prompt_factory.py commit 015781ed2b6b0e2311d9938788403e0b33b19e17 Author: Dominik Jain <dominik.jain@outlook.com> Date: Fri Aug 14 19:36:07 2026 +0200 Fix: Language code was read at the wrong level reframer/interprompt/multilang_prompt.py commit 487e9eed63d435257ee03eda03e668b4e7a73019 Author: Dominik Jain <dominik.jain@outlook.com> Date: Fri Aug 14 19:08:18 2026 +0200 Use relative imports reframer/interprompt/jinja_template.py src/interprompt/jinja_template.py src/interprompt/multilang_prompt.py src/interprompt/prompt_factory.py
This commit is contained in:
1 parent
3ad624f511
commit
1814fc9a0f
5 files changed
+11
-8
No files matched your search
@@ -1 +1 @@
|
||||
80e4ea6514dc93a668931ccab94a88ade675ec2a
|
||||
edbee70392dca692d36d136c47a61513f4a2b222
|
||||
@@ -1 +0,0 @@
|
||||
17e39c9655e947ff6d6809e3638f97d113a1947e
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
\"""
|
||||
|
||||
Reference in new issue
Block a user