Skip to content

Commit aa05029

Browse files
authored
Merge pull request #26 from dmabry/bugfix/fix-qa-validation
WebResponse QAPage/QA Validation Fix
2 parents db67eaf + e0fccfb commit aa05029

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/brave/types/web/answer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from pydantic import BaseModel
22
from pydantic import Field
3+
from typing import Optional
34

45

56
class Answer(BaseModel):
67
"""A response representing an answer to a question on a forum."""
78

89
text: str = Field(description="The main content of the answer.")
9-
author: str = Field(description="A name string for the author of the answer.")
10-
upvoteCount: int = Field(description="Number of upvotes on the answer.")
11-
downvoteCount: int = Field(description="The number of downvotes on the answer.")
10+
author: Optional[str] = Field(default=None, description="A name string for the author of the answer.")
11+
upvoteCount: Optional[int] = Field(default=None, description="Number of upvotes on the answer.")
12+
downvoteCount: Optional[int] = Field(default=None, description="The number of downvotes on the answer.")

src/brave/types/web/faq.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
from pydantic import HttpUrl
77

88
from ..shared.meta_url import MetaUrl
9+
from .answer import Answer
910

1011

1112
class QAPage(BaseModel):
1213
"""Aggreated result from a question answer page."""
1314

1415
question: str = Field(description="The question being asked.")
15-
answer: str = Field(description="The answer to the question.")
16+
answer: Answer = Field(description="The answer to the question.")
1617

1718

1819
class QA(BaseModel):

src/brave/types/web/search_result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .book import Book
2323
from .faq import FAQ
2424
from .faq import QA
25+
from .faq import QAPage
2526
from .location_result import LocationResult
2627
from .location_result import Locations
2728
from .product import Product
@@ -66,7 +67,7 @@ class SearchResult(Result):
6667
faq: Optional[FAQ] = Field(
6768
default=None, description="Any frequently asked questions associated with the web search result."
6869
)
69-
qa: Optional[QA] = Field(
70+
qa: Optional[QAPage] = Field(
7071
default=None, description="Any question answer information associated with the web search result page."
7172
)
7273
book: Optional[Book] = Field(

0 commit comments

Comments
 (0)