-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: unify prompts and skills into shared templates and registry #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SalemBajjali
wants to merge
38
commits into
main
Choose a base branch
from
issue-17
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
694119b
fix: update execute() to execute_prompt() across codebase
SalemBajjali 158684e
feat: add skill engineering support
SalemBajjali f0331d2
test: add unit tests for skills
SalemBajjali 42501e1
chore: update notes and comments for maintainer review
SalemBajjali 076b70e
fix: update skill_path in test_skill_registry.py to correct path
SalemBajjali 6dc4393
fix: clean up build_user_prompt docstring in BaseSkillTemplate
SalemBajjali 584e18c
refactor: add _check_cache helper and CacheCheckResult to StructuredT…
SalemBajjali 72380af
chore: rename entity_detection.md to test_skill_v1.md and update format
SalemBajjali 22d1f9a
chore: clean up comments in SkillRegistry
SalemBajjali 300d0d5
feat: derive name/version from filename via regex and add build_syste…
SalemBajjali 6f73db7
test: update skill tests based on PR feedback
SalemBajjali 2152e05
refactor: update CacheLookupResult based on PR feedback
SalemBajjali 47771d0
fix: handle UnicodeDecodeError in load_skill and rename _get_skill_na…
SalemBajjali ddd220e
feat: add unified registry replacing PromptRegistry and SkillRegistry
SalemBajjali 124eea4
feat: add unified templates directory replacing prompts and skills di…
SalemBajjali 9bd8891
refactor: remove prompts and skills directories in favor of unified t…
SalemBajjali 18b7aff
refactor: update StructuredTaskRunner to use unified registry
SalemBajjali 28aac05
test: update tests to reflect new templates and registry structure
SalemBajjali 6446ada
chore: update example notebook to reflect new structure
SalemBajjali 3d742f3
refactor: update _get_skill_name_and_version to return tuple[str, str]
SalemBajjali c8cff35
Use full skill path in filename error message
SalemBajjali d79b88e
Merge branch 'main' into feat/skills
korikuzma 913aa5f
Merge remote-tracking branch 'origin/feat/skills' into issue-17
SalemBajjali ab91299
refactor: simplify StructuredTaskRunner with unified _execute() method
SalemBajjali 75b5204
chore: add test skill fixture using semantic versioning
SalemBajjali 30f4c8e
test: update skill tests to use semantic versioning format
SalemBajjali fdcef2a
chore: update integration tests and notebook to reflect new structure
SalemBajjali 1b92e09
Merge remote-tracking branch 'origin/main' into issue-17
SalemBajjali f73d43e
chore: update module docstrings for clarity
SalemBajjali 59f728e
feat: implement TaskKind enum for structured task execution
SalemBajjali c8cf01e
Merge remote-tracking branch 'origin/main' into issue-17
SalemBajjali be6eef2
fix: update notebook examples to match refactored code structure
SalemBajjali 8966f74
Add task type to registry keys
SalemBajjali 26fec9a
Update tests for task-type registry lookup
SalemBajjali a384589
test: move shared example file to tests/examples
SalemBajjali 6c64064
test: combine prompt and skill registry tests
SalemBajjali a52d93c
refactor: split prompt template into base template and updated paths
SalemBajjali f109c0b
feat: add template type to registry for duplicate skill and prompt en…
SalemBajjali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| """Registry module. | ||
|
|
||
| Store and retrieve versioned prompt and skill templates. | ||
| """ | ||
|
|
||
| from wags_llm.registry.base import Registry, build_empty_registry | ||
|
|
||
| __all__ = [ | ||
| "Registry", | ||
| "build_empty_registry", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| """Registry. | ||
|
|
||
| Maps (name, version, TemplateType) -> template instance. | ||
| Template instances can be either prompts or skills. | ||
|
|
||
| Users typically: | ||
| * create prompts or skills in their project | ||
| * register them here or pass a custom registry | ||
| """ | ||
|
|
||
| import logging | ||
| from types import MappingProxyType | ||
|
|
||
| from wags_llm.templates.base import TemplateType | ||
| from wags_llm.templates.prompt_template import PromptTemplate | ||
| from wags_llm.templates.skill_template import SkillTemplate | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
| _TEMPLATE_CLASS_TO_TYPE = MappingProxyType( | ||
| { | ||
| SkillTemplate: TemplateType.SKILL, | ||
| PromptTemplate: TemplateType.PROMPT, | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| class Registry: | ||
| """Store and retrieve prompt and skill templates.""" | ||
|
|
||
| def __init__(self) -> None: | ||
| """Initialize an empty template registry.""" | ||
| self._templates: dict[ | ||
| tuple[str, str, TemplateType], PromptTemplate | SkillTemplate | ||
| ] = {} | ||
|
|
||
| def register(self, template: PromptTemplate | SkillTemplate) -> None: | ||
| """Register a template. | ||
|
|
||
| :param template: Template instance to register. | ||
| :raise TypeError: If the template type is unsupported. | ||
| :raise ValueError: If a template with the same name, version, and template type is already registered. | ||
| """ | ||
| for cls, mapped_type in _TEMPLATE_CLASS_TO_TYPE.items(): | ||
| if isinstance(template, cls): | ||
| template_type = mapped_type | ||
| break | ||
| else: | ||
| msg = f"Unsupported template type: {type(template)}" | ||
| raise TypeError(msg) | ||
|
|
||
| key = (template.name, template.version, template_type) | ||
|
|
||
| _logger.debug( | ||
| "Registering template: name='%s', version='%s', template_type='%s'", | ||
| template.name, | ||
| template.version, | ||
| template_type.value, | ||
| ) | ||
|
|
||
| if key in self._templates: | ||
|
SalemBajjali marked this conversation as resolved.
|
||
| msg = f"Template already registered:({template.name}, {template.version}, {template_type.value})" | ||
| _logger.error(msg) | ||
| raise ValueError(msg) | ||
|
|
||
| self._templates[key] = template | ||
|
|
||
| def get( | ||
| self, | ||
| name: str, | ||
| version: str, | ||
| template_type: TemplateType, | ||
| ) -> PromptTemplate | SkillTemplate: | ||
| """Retrieve a template by name and version. | ||
|
|
||
| :param name: Template name. | ||
| :param version: Template version. | ||
| :param template_type: Template type. | ||
| :return: Registered template. | ||
| :raise KeyError: If template not found. | ||
| """ | ||
| key = (name, version, template_type) | ||
|
|
||
| try: | ||
| return self._templates[key] | ||
| except KeyError as exc: | ||
| msg = f"Template not found: ({name}, {version}, {template_type.value})" | ||
| _logger.exception(msg) | ||
| raise KeyError(msg) from exc | ||
|
|
||
|
|
||
| def build_empty_registry() -> Registry: | ||
| """Create an empty registry. | ||
|
|
||
| :return: New Registry instance. | ||
| """ | ||
| return Registry() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.