Version and Register Verification Prompts - #1114
Open
richardgittest wants to merge 3 commits into
Open
richardgittest wants to merge 3 commits into
richardgittest wants to merge 3 commits into
Conversation
Updated Project File
|
@richardgittest Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@richardgittest kindly fix CI |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Files Changed
New PromptVersion (frozen dataclass): name, version, description, immutable builder. Exposes content_hash(**kw) and build(**kw).
New PromptRegistry class:
register(prompt_version) — rejects duplicates → enforces no edit-in-place
set_active_version(name, version) — runtime pinning
get_active_version(name) — falls back to latest registered when config is silent
resolve(name, version=None) — explicit or active lookup
build_prompt(name, version=None, **kw) — returns {system, user, prompt_name, prompt_version, prompt_content_hash}
Default 1.0 versions for both humanitarian_primary and humanitarian_fallback are the exact original prompt texts extracted from the inline builder — semantically identical.
2. Configuration — config.py
New field humanitarian_prompt_active_versions: Dict[str, str] with JSON env var example in docstring.
3. Verification service — humanitarian_verification.py
Constructor now accepts prompt_registry: Optional[PromptRegistry] (defaults to one built from settings).
verify_claim() builds both prompts via registry.build_prompt(...), records prompt_name, prompt_version, prompt_content_hash in the returned dict alongside the existing prompt_variant label.
New get_prompt_versions_tag() → "primary=1.0|fallback=1.0" used as a cache key tag so a version bump auto-invalidates.
4. Response schemas — schemas/common.py and schemas/humanitarian.py
Common: new PromptVersionInfo(name, version, content_hash) model + new optional prompt_versions: Dict[str, PromptVersionInfo] field on ResultEnvelope.
Humanitarian legacy schema: added prompt_name, prompt_version, prompt_content_hash fields + model_config = { "extra": "ignore" } so HumanitarianVerificationResponse(success=True, **result) in the deprecated route stays permissive.
5. Humanitarian API route — api/v1/humanitarian.py
Added prompt_versions_tag to @cached_response key_tags so prompt-version changes bust the cache (no stale responses after rollback/upgrade).
Builds prompt_versions envelope map from raw["prompt_name"] / ["prompt_version"] / ["prompt_content_hash"] keyed by the prompt_variant label ("primary" or "fallback").
6. Regression harness migration — regression_harness/deterministic_provider.py
Replaced HumanitarianPromptEngine() + build_primary_prompt/build_fallback_prompt with PromptRegistry().build_prompt("humanitarian_primary"/"humanitarian_fallback", …). llm_chat still consumes prompt["system"]/prompt["user"] unchanged — behaviour preserved.
Closes #979