File size: 1,406 Bytes
3c54dc9
e6d98e1
 
3c54dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6d98e1
 
3c54dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pydantic import BaseModel, Field

class QAQuery(BaseModel):
    """
    Schema for the question-answering input.
    """
    context: str = Field(
        ...,
        example="The Eiffel Tower is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It is named after the engineer Gustave Eiffel, whose company designed and built the tower.",
        description="The text passage or document that contains the information needed to answer the question."
    )
    question: str = Field(
        ...,
        example="Who designed the Eiffel Tower?",
        description="The question to be answered based on the provided context."
    )

    class Config:
        schema_extra = {
            "example": {
                "context": "The Eiffel Tower is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It is named after the engineer Gustave Eiffel, whose company designed and built the tower.",
                "question": "Who designed the Eiffel Tower?"
            }
        }

class QAResponse(BaseModel):
    """
    Schema for the question-answering output.
    """
    answer: str = Field(
        ...,
        example="Gustave Eiffel",
        description="The answer to the question based on the provided context."
    )

    class Config:
        schema_extra = {
            "example": {
                "answer": "Gustave Eiffel"
            }
        }