diff --git a/apps/api/src/services/playbook_service.py b/apps/api/src/services/playbook_service.py index 557e187ae..4df19fafb 100644 --- a/apps/api/src/services/playbook_service.py +++ b/apps/api/src/services/playbook_service.py @@ -350,6 +350,11 @@ class PlaybookService: hybrid_by_id = {match.playbook_id: match for match in hybrid_matches} for playbook_id, jaccard_score in jaccard_results: if playbook_id in hybrid_by_id: + match = hybrid_by_id[playbook_id] + if match.similarity_score < jaccard_score: + match.similarity_score = jaccard_score + if match.match_type == "vector": + match.match_type = "hybrid" continue hybrid_matches.append( PlaybookMatch( diff --git a/apps/api/tests/test_playbook_service.py b/apps/api/tests/test_playbook_service.py index d23861508..1d25b3238 100644 --- a/apps/api/tests/test_playbook_service.py +++ b/apps/api/tests/test_playbook_service.py @@ -250,6 +250,21 @@ class TestPlaybookService: playbook = create_test_playbook() await mock_repo.create(playbook) + class LowerScoringRagService: + async def hybrid_search(self, **_kwargs): + return [ + PlaybookMatch( + playbook_id=playbook.playbook_id, + similarity_score=0.4, + match_type="hybrid", + ) + ] + + async def fake_rag_service(): + return LowerScoringRagService() + + service._get_rag_service = fake_rag_service + # Query with matching symptoms symptoms = SymptomPattern( alert_names=["HighCPU"],