feat(ai-service): implement humanitarian verification prompt engine with Sphere criteria and fallback flow#228
Merged
Cedarich merged 2 commits intoPulsefy:mainfrom Mar 29, 2026
Conversation
…ith Sphere criteria and fallback flow Adds a standardized Humanitarian Standard prompt template engine for LLM verification workflows. Integrates Sphere Handbook criteria into primary verification prompts to improve consistency and objectivity of aid-claim assessment. Introduces backend-driven context_factors support so NestJS can pass operational context that influences prompt construction and evaluation framing. Implements resilient fallback behavior across prompt variants (primary to fallback) and configured providers (OpenAI and Groq) with structured error capture. Adds humanitarian verification API contracts and endpoint wiring, plus Celery task integration for asynchronous processing. Extends configuration with model/timeout settings and updates environment examples and README documentation. Includes test coverage for prompt rendering, context-factor inclusion, fallback execution path, endpoint success/failure behavior, and environment-stable OCR testing. Validation: full test suite passed locally (63 passed).
|
@rachealkenny 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
Author
|
@Cedarich done. |
Contributor
|
Please help star our repo |
Initialize Celery app lazily on first use instead of at module import time. This allows the AI service to start and serve requests (including health checks) even when Redis is unavailable, fixing the Docker CI health check failure. Benefits: - Docker health checks pass during CI testing without Redis - Production functionality unchanged when Redis is available - Graceful degradation - tasks fail with clear error messages when Redis missing - All existing callers work identically Changes: - Wrapped Celery initialization in get_celery_app() function - Task decorator deferred via get_process_heavy_inference_task() - create_task() now handles missing Redis gracefully - Dummy Celery app created as fallback to prevent crashes Fixes: CI failure 'curl: (7) Failed to connect to localhost port 8000'
Cedarich
approved these changes
Mar 29, 2026
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.
Summary
Implements a standardized humanitarian verification prompt engine for LLMs (OpenAI/Grok) that integrates Sphere Handbook criteria, supports backend-driven context factors, and provides resilient fallback behavior across providers.
Changes
context_factorsto influence prompt constructionValidation
Closes #159