"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from neuralseek.types import BaseModel
import pydantic
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class PassagesTypedDict(TypedDict):
    passage: NotRequired[str]
    r"""The passage text, summarized to the length set by sourceResultsSummaryLength"""
    id: NotRequired[str]
    r"""The id of the source document in the KB."""
    score: NotRequired[int]
    r"""The score of the passage."""
    url: NotRequired[str]
    r"""The URL (if available) of the source document."""
    document: NotRequired[str]
    r"""The name of the source document."""
    train: NotRequired[str]
    r"""The training token for the document. Use this when calling the /train endpoint."""


class Passages(BaseModel):
    passage: Optional[str] = ""
    r"""The passage text, summarized to the length set by sourceResultsSummaryLength"""

    id: Optional[str] = ""
    r"""The id of the source document in the KB."""

    score: Optional[int] = None
    r"""The score of the passage."""

    url: Optional[str] = ""
    r"""The URL (if available) of the source document."""

    document: Optional[str] = ""
    r"""The name of the source document."""

    train: Optional[str] = ""
    r"""The training token for the document. Use this when calling the /train endpoint."""


class VariablesTypedDict(TypedDict):
    r"""The returned variable."""


class Variables(BaseModel):
    r"""The returned variable."""


class VariablesExpandedTypedDict(TypedDict):
    name: NotRequired[str]
    r"""The variable name"""
    value: NotRequired[str]
    r"""The variable value"""


class VariablesExpanded(BaseModel):
    name: Optional[str] = ""
    r"""The variable name"""

    value: Optional[str] = ""
    r"""The variable value"""


class SeekResponseTypedDict(TypedDict):
    score: int
    r"""The final confidence score of the answer (0-100)"""
    answer: NotRequired[str]
    r"""The generated answer"""
    answer_id: NotRequired[str]
    r"""The id of the answer. Use this to refer to it from other endpoints, such as the Rating endpoint"""
    thumbs: NotRequired[str]
    r"""The URL of a rating HTML page with an SVG to embed with the answer to allow easy rating."""
    thumbs_svg: NotRequired[str]
    r"""The URL of a rating SVG to display with the answer to allow easy rating."""
    intent: NotRequired[str]
    r"""The intent of the answer."""
    category: NotRequired[int]
    r"""The category id of the answer."""
    category_name: NotRequired[str]
    r"""The category name of the answer."""
    k_bscore: NotRequired[int]
    r"""The KnowledgeBase confidence of the answer's source documentation  (0-100)"""
    cached_result: NotRequired[str]
    r"""If the result came from cache, will be set to the string 'true'"""
    lang_code: NotRequired[str]
    r"""The language code of the answer. If you set the input language code to 'xx' to identify the language, this is useful to condition of the found language and response."""
    url: NotRequired[str]
    r"""The top scoring URL (if available) used to train the answer. Set the field you want returned here in on the Configure tab. The field must contain a URL, or it will be ignored."""
    document: NotRequired[str]
    r"""The top document (if available) used to train the answer. Set the field you want returned here in on the Configure tab"""
    time: NotRequired[int]
    r"""Total processing time in milliseconds"""
    kb_time: NotRequired[int]
    r"""KnowledgeBase response time in milliseconds"""
    source_results_formatted: NotRequired[str]
    r"""A listing of the passages used for answer summarization. This will only return if includeSourceResultsFormatted is set to true on the request"""
    passages: NotRequired[List[PassagesTypedDict]]
    r"""A listing of the passages used for answer summarization. This will only return if includeSourceResults is set to true on the request"""
    kb_coverage: NotRequired[int]
    r"""KnowledgeBase coverage score. How much content was returned from the KnowledgeBase on the subject asked as compared to benchmarks. Low coverage is not necessarily indicitive of bad content."""
    sentiment: NotRequired[int]
    r"""Sentiment score"""
    semantic_score: NotRequired[int]
    r"""Semantic score (if enabled)"""
    variables: NotRequired[VariablesTypedDict]
    r"""The returned variable."""
    variables_expanded: NotRequired[List[VariablesExpandedTypedDict]]
    r"""The returned variable, in the format of the input params"""


class SeekResponse(BaseModel):
    score: int
    r"""The final confidence score of the answer (0-100)"""

    answer: Optional[str] = ""
    r"""The generated answer"""

    answer_id: Annotated[Optional[str], pydantic.Field(alias="answerId")] = ""
    r"""The id of the answer. Use this to refer to it from other endpoints, such as the Rating endpoint"""

    thumbs: Optional[str] = ""
    r"""The URL of a rating HTML page with an SVG to embed with the answer to allow easy rating."""

    thumbs_svg: Annotated[Optional[str], pydantic.Field(alias="thumbsSVG")] = ""
    r"""The URL of a rating SVG to display with the answer to allow easy rating."""

    intent: Optional[str] = ""
    r"""The intent of the answer."""

    category: Optional[int] = None
    r"""The category id of the answer."""

    category_name: Annotated[Optional[str], pydantic.Field(alias="categoryName")] = ""
    r"""The category name of the answer."""

    k_bscore: Annotated[Optional[int], pydantic.Field(alias="KBscore")] = None
    r"""The KnowledgeBase confidence of the answer's source documentation  (0-100)"""

    cached_result: Annotated[Optional[str], pydantic.Field(alias="cachedResult")] = ""
    r"""If the result came from cache, will be set to the string 'true'"""

    lang_code: Annotated[Optional[str], pydantic.Field(alias="langCode")] = ""
    r"""The language code of the answer. If you set the input language code to 'xx' to identify the language, this is useful to condition of the found language and response."""

    url: Optional[str] = ""
    r"""The top scoring URL (if available) used to train the answer. Set the field you want returned here in on the Configure tab. The field must contain a URL, or it will be ignored."""

    document: Optional[str] = ""
    r"""The top document (if available) used to train the answer. Set the field you want returned here in on the Configure tab"""

    time: Optional[int] = None
    r"""Total processing time in milliseconds"""

    kb_time: Annotated[Optional[int], pydantic.Field(alias="kbTime")] = None
    r"""KnowledgeBase response time in milliseconds"""

    source_results_formatted: Annotated[
        Optional[str], pydantic.Field(alias="sourceResultsFormatted")
    ] = ""
    r"""A listing of the passages used for answer summarization. This will only return if includeSourceResultsFormatted is set to true on the request"""

    passages: Optional[List[Passages]] = None
    r"""A listing of the passages used for answer summarization. This will only return if includeSourceResults is set to true on the request"""

    kb_coverage: Annotated[Optional[int], pydantic.Field(alias="kbCoverage")] = None
    r"""KnowledgeBase coverage score. How much content was returned from the KnowledgeBase on the subject asked as compared to benchmarks. Low coverage is not necessarily indicitive of bad content."""

    sentiment: Optional[int] = None
    r"""Sentiment score"""

    semantic_score: Annotated[Optional[int], pydantic.Field(alias="semanticScore")] = (
        None
    )
    r"""Semantic score (if enabled)"""

    variables: Optional[Variables] = None
    r"""The returned variable."""

    variables_expanded: Annotated[
        Optional[List[VariablesExpanded]], pydantic.Field(alias="variablesExpanded")
    ] = None
    r"""The returned variable, in the format of the input params"""
