feat(backend): labor pricing from historical jobs (TF-IDF RAG)#190
Open
anumukul wants to merge 2 commits intoNOVUS-X:mainfrom
Open
feat(backend): labor pricing from historical jobs (TF-IDF RAG)#190anumukul wants to merge 2 commits intoNOVUS-X:mainfrom
anumukul wants to merge 2 commits intoNOVUS-X:mainfrom
Conversation
- Add POST /pricing/labor/suggest for clients/artisans: TF-IDF similarity over completed jobs, top-5 average labor reference, urgency and rating multipliers. - Add POST /pricing/labor/reindex (admin) to hydrate in-memory job rows from completed bookings (anonymized: service text, zip, costs only). - Prefer labor_cost when set, else estimated_cost; add nullable labor_cost and material_cost on Booking. - Dependencies: scikit-learn, numpy. - Tests for engine and API; fix stats import, PublicRoleEnum, artisan json. Made-with: Cursor
|
@anumukul 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! 🚀 |
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
Adds a labor pricing suggestion flow that uses completed bookings as historical context: TF‑IDF + cosine similarity over job descriptions (RAG-style retrieval), averages the top matches’ labor reference amounts, then applies urgency and optional artisan rating multipliers.
API
POST /api/v1/pricing/labor/suggest(client or artisan):sow_text,zip_code, optionalurgency(low/normal/high), optionalartisan_average_rating(1–5). Returns baseline average, suggested price,region_scope(localvsexpandedif no ZIP matches), and anonymized match metadata.POST /api/v1/pricing/labor/reindex(admin): rebuilds the in-memory index from completed jobs (service text, parsed ZIP, costs only—no client PII in vectors).Data model
labor_costandmaterial_costonbookings; pricing preferslabor_costwhen set, otherwiseestimated_cost.Dependencies
scikit-learn,numpyOther fixes (on
mainbaseline)statsrouter import inapi.py.PublicRoleEnumusesStrEnum(fixes missingEnumimport).json.loadsinstead of undefined_json.Tests
app/tests/test_labor_pricing.pycovering engine behavior and auth/admin endpoints.closes #157