Spaces:
Paused
Paused
added examaple schema
Browse files- app/schemas.py +37 -4
app/schemas.py
CHANGED
@@ -1,8 +1,41 @@
|
|
1 |
-
from pydantic import BaseModel
|
2 |
|
3 |
class QAQuery(BaseModel):
|
4 |
-
|
5 |
-
question
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class QAResponse(BaseModel):
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel, Field
|
2 |
|
3 |
class QAQuery(BaseModel):
|
4 |
+
"""
|
5 |
+
Schema for the question-answering input.
|
6 |
+
"""
|
7 |
+
context: str = Field(
|
8 |
+
...,
|
9 |
+
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.",
|
10 |
+
description="The text passage or document that contains the information needed to answer the question."
|
11 |
+
)
|
12 |
+
question: str = Field(
|
13 |
+
...,
|
14 |
+
example="Who designed the Eiffel Tower?",
|
15 |
+
description="The question to be answered based on the provided context."
|
16 |
+
)
|
17 |
+
|
18 |
+
class Config:
|
19 |
+
schema_extra = {
|
20 |
+
"example": {
|
21 |
+
"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.",
|
22 |
+
"question": "Who designed the Eiffel Tower?"
|
23 |
+
}
|
24 |
+
}
|
25 |
|
26 |
class QAResponse(BaseModel):
|
27 |
+
"""
|
28 |
+
Schema for the question-answering output.
|
29 |
+
"""
|
30 |
+
answer: str = Field(
|
31 |
+
...,
|
32 |
+
example="Gustave Eiffel",
|
33 |
+
description="The answer to the question based on the provided context."
|
34 |
+
)
|
35 |
+
|
36 |
+
class Config:
|
37 |
+
schema_extra = {
|
38 |
+
"example": {
|
39 |
+
"answer": "Gustave Eiffel"
|
40 |
+
}
|
41 |
+
}
|