File size: 963 Bytes
c44df3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from app.pipeline.graph import route_retrieve_result


def test_attempt_three_portfolio_empty_rewrites() -> None:
    state = {
        "retrieval_attempts": 3,
        "reranked_chunks": [],
        "query": "Could you tell me about his tech stack?",
    }
    assert route_retrieve_result(state) == "rewrite"


def test_attempt_three_portfolio_low_confidence_rewrites() -> None:
    state = {
        "retrieval_attempts": 3,
        "reranked_chunks": [{"text": "x", "metadata": {}}],
        "top_rerank_score": -2.0,
        "query": "Could you tell me about his tech stack?",
    }
    assert route_retrieve_result(state) == "rewrite"


def test_attempt_three_unrelated_low_confidence_generates() -> None:
    state = {
        "retrieval_attempts": 3,
        "reranked_chunks": [{"text": "x", "metadata": {}}],
        "top_rerank_score": -2.0,
        "query": "what is the weather in london",
    }
    assert route_retrieve_result(state) == "generate"