GeneratedAnswer

This is for:

Developer

Methods

closeFeedbackModal

Closes the modal to provide feedback about why the generated answer was not relevant.

dislike

Marks the generated answer as not relevant to the end user.

hide

Hides the generated answer.

like

Indicates that the generated answer met the user expectations.

logCitationClick

Logs a custom event indicating a cited source link was clicked.

Parameters

  • id: string

    The ID of the clicked citation.

logCitationHover

Logs a custom event indicating a cited source link was hovered.

Parameters

  • citationId: string

    The ID of the clicked citation.

  • citationHoverTimeMs: number

    The number of milliseconds spent hovering over the citation.

logCopyToClipboard

Logs a custom event indicating the generated answer was copied to the clipboard.

openFeedbackModal

Opens the modal to provide feedback about why the generated answer was not relevant.

rephrase

Re-executes the query to generate the answer in the specified format.

Parameters

retry

Re-executes the last query to generate an answer.

sendDetailedFeedback

Sends detailed feedback about why the generated answer was not relevant.

Parameters

  • details: string

    Details on why the generated answer was not relevant.

sendFeedback

Sends feedback about why the generated answer was not relevant.

Parameters

  • feedback: 'irrelevant' | 'notAccurate' | 'outOfDate' | 'harmful'

    The feedback that the end user wishes to send.

show

Displays the generated answer.

subscribe

Adds a callback that’s invoked on state change.

Parameters

  • listener: () => void

    A callback that’s invoked on state change.

Returns Unsubscribe: A function to remove the listener.

Attributes

state

The state of the GeneratedAnswer controller.

Properties

  • citations: GeneratedAnswerCitation[]

    The document snippets retrieved to generate the answer.

  • disliked: boolean

    Determines if the generated answer is disliked, or downvoted by the end user.

  • feedbackModalOpen: boolean

    Determines if the feedback modal is currently opened.

  • feedbackSubmitted: boolean

    Determines if the generated answer feedback was submitted.

  • fieldsToIncludeInCitations: string[]

    A list of indexed fields to include in the citations returned with the generated answer.

  • isLoading: boolean

    Determines if the generated answer is loading.

  • isStreaming: boolean

    Determines if the generated answer is streaming.

  • isVisible: boolean

    Determines if the generated answer is visible.

  • liked: boolean

    Determines if the generated answer is liked, or upvoted by the end user.

  • responseFormat: GeneratedResponseFormat

    The desired format options for the generated answer.

  • answer?: string

    The generated answer.

  • error?: { message?: string; code?: number; isRetryable?: boolean; }

    The generated answer error.

Initialize

buildGeneratedAnswer

Creates a GeneratedAnswer controller instance.

Parameters

  • engine: SearchEngine

    The headless engine.

  • props: GeneratedAnswerProps

    The configurable GeneratedAnswer properties.

Returns GeneratedAnswer

GeneratedAnswerProps

The configurable GeneratedAnswer properties.

Properties

  • fieldsToIncludeInCitations?: string[]

    A list of indexed fields to include in the citations returned with the generated answer.

  • initialState?: { isVisible?: boolean; responseFormat?: GeneratedResponseFormat; }

GeneratedAnswerCitation

Properties

  • id: string

  • permanentid: string

  • title: string

  • uri: string

  • clickUri?: string

  • fields?: Raw

  • text?: string

GeneratedResponseFormat

Properties

  • answerStyle: (typeof generatedAnswerStyle)[number]

    The requested formatting style of the generated answer. Options: - default: Generates the answer without additional formatting instructions. - bullet: Requests the answer to be generated in bullet-points. - step: Requests the answer to be generated in step-by-step instructions. - concise: Requests the answer to be generated as concisely as possible.

Raw

Properties

  • [key: string]: unknown

    Custom keys that depend on the documents in the index.

Unsubscribe

Call signatures

  • (): void