Add standalone .prompt file handler, opt-in folder loading, and lookup for Python Genkit "issue-3282" #3742
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.
Summary
Introduce a standalone
.promptfile handler for Python Genkit with:Scope of Changes
genkit/dotprompt/:file_loader.py: load.promptfiles/dirs, register partials, compute definition keys, async metadata rendering; supports current engine API naming.__init__.py: export loader/metadata functions.types.py: prompt identity and loaded prompt types.Registry.load_prompt_folder(dir, ns)caches loaded prompts in-memory.Registry.list_loaded_prompts(),Registry.get_loaded_prompt(key),Registry.lookup_loaded_prompt(name, variant, ns).GenkitRegistry.load_prompt_dir,aload_prompt_dir,load_prompt_file,aload_prompt_file(no auto-registration).file_loader_test.py: directory scan, partials, variant parsing, subdir prefixing, metadata rendering, definition-key and lookup.genkit/dotprompt/exceptions.py.Behavior and Compatibility
.promptloading is opt-in (invoked by API orRegistry.load_prompt_folder).How to Test
uv(recommended):py/:uv syncuv run pytest packages/genkit/tests/genkit/dotprompt/file_loader_test.py -qdotpromptzanddotprompt-handlebarsperpy/pyproject.toml(uv.lock has the commit)pytest packages/genkit/tests/genkit/dotprompt/file_loader_test.py -qFollow-ups (not included here)
ai.prompt('name', { variant })to use loaded prompts behind a flag.Checklist
dotpromptz) supported (camelCase/snake_case compatibility)genkit/dotprompt/exceptions.py)