File size: 2,217 Bytes
c3674d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from __future__ import annotations

from typing import List

from pydantic import BaseModel, Field

from backend.schema.cqGen import ClarifyingQuestion


class InputContext(BaseModel):
    """
    Represents one interaction block containing the query and associated Q&A.
    """
    user_query: str = Field(
        ...,
        alias="user query",
        description="The initial query provided by the user."
    )
    clarified_qa: List[ClarifyingQuestion] = Field(
        ...,
        alias="clarified Q&A",
        description="List of clarifying questions and answers associated with this query."
    )


class CompromiseDetails(BaseModel):
    """
    Breakdown of the user's willingness to compromise.
    """
    willing_to_compromise: bool = Field(
        ...,
        description="True if the user indicates flexibility or willingness to change plans."
    )
    compromise_factors: List[str] = Field(
        default_factory=list,
        description="Specific list of factors the user is willing to compromise on (e.g., ['budget', 'travel dates', "
                    "'airline'])."
    )


class IntentClassificationOutput(BaseModel):
    session_id: str = Field(
        ...,
        description="Unique identifier for the session this intent classification belongs to."
    )
    input_data: List[InputContext] = Field(
        ...,
        alias="input",
        description="A history of the user's queries and the resulting clarified Q&A contexts."
    )
    user_travel_persona: str = Field(
        ...,
        description="A synthesized summary of the user's travel preferences, likes, and dislikes based on the input."
    )
    travel_intent: str = Field(
        ...,
        description="The specific goal or intention of the user's trip (e.g., 'Business trip with leisure', "
                    "'Budget backpacking')."
    )
    compromise: CompromiseDetails = Field(
        ...,
        description="Analysis of whether the user allows flexibility and on which specific aspects."
    )
    db_ingestion_status: bool = Field(
        default=False,
        description="Status indicating whether the intent classification response was successfully ingested into the database."
    )