mirror of
https://github.com/tiennm99/serena.git
synced 2026-06-18 07:34:41 +00:00
61f7c15b15
* Add LLM prompt factory (yaml-based)
* Add list_dir tool
* Add onboarding tool (which returns prompt only, as registered MCP prompts
do not appear to be usable by Claude Desktop)
22 lines
932 B
Python
22 lines
932 B
Python
from .multilang_prompt import MultiLangContainer, MultiLangPromptTemplateCollection, PromptList
|
|
|
|
|
|
class PromptFactory:
|
|
# NOTE: This class is auto-generated by gen_prompt_factory.py
|
|
|
|
def __init__(self, lang_shortcode: str = "en", fallback_mode=MultiLangContainer.FallbackMode.EXCEPTION):
|
|
self.lang_shortcode = lang_shortcode
|
|
self.collection = MultiLangPromptTemplateCollection()
|
|
self.fallback_mode = fallback_mode
|
|
|
|
def _format_prompt(self, prompt_name: str, kwargs) -> str:
|
|
del kwargs["self"]
|
|
mpt = self.collection.get_multilang_prompt_template(prompt_name)
|
|
return mpt.get_item(self.lang_shortcode, self.fallback_mode).instantiate(**kwargs)
|
|
|
|
def _get_list(self, prompt_name: str) -> PromptList:
|
|
mpl = self.collection.get_multilang_prompt_list(prompt_name)
|
|
return mpl.get_item(self.lang_shortcode, self.fallback_mode)
|
|
|
|
# methods
|