Skip to content

Commit

Permalink
Merge pull request #26 from dmabry/bugfix/fix-qa-validation
Browse files Browse the repository at this point in the history
WebResponse QAPage/QA Validation Fix
  • Loading branch information
kayvane1 authored Feb 21, 2024
2 parents db67eaf + e0fccfb commit aa05029
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/brave/types/web/answer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from pydantic import BaseModel
from pydantic import Field
from typing import Optional


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

text: str = Field(description="The main content of the answer.")
author: str = Field(description="A name string for the author of the answer.")
upvoteCount: int = Field(description="Number of upvotes on the answer.")
downvoteCount: int = Field(description="The number of downvotes on the answer.")
author: Optional[str] = Field(default=None, description="A name string for the author of the answer.")
upvoteCount: Optional[int] = Field(default=None, description="Number of upvotes on the answer.")
downvoteCount: Optional[int] = Field(default=None, description="The number of downvotes on the answer.")
3 changes: 2 additions & 1 deletion src/brave/types/web/faq.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
from pydantic import HttpUrl

from ..shared.meta_url import MetaUrl
from .answer import Answer


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

question: str = Field(description="The question being asked.")
answer: str = Field(description="The answer to the question.")
answer: Answer = Field(description="The answer to the question.")


class QA(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion src/brave/types/web/search_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .book import Book
from .faq import FAQ
from .faq import QA
from .faq import QAPage
from .location_result import LocationResult
from .location_result import Locations
from .product import Product
Expand Down Expand Up @@ -66,7 +67,7 @@ class SearchResult(Result):
faq: Optional[FAQ] = Field(
default=None, description="Any frequently asked questions associated with the web search result."
)
qa: Optional[QA] = Field(
qa: Optional[QAPage] = Field(
default=None, description="Any question answer information associated with the web search result page."
)
book: Optional[Book] = Field(
Expand Down

0 comments on commit aa05029

Please sign in to comment.