qanary-component-helpers/generate-clarification-question
This page is auto-generated from TSDoc output. Edit the source file, not this Markdown.
qanary-component-helpers/generate-clarification-question
Section titled “qanary-component-helpers/generate-clarification-question”- Package:
@leipzigtreechat/qanary-component-helpers - Source file:
packages/qanary-component-helpers/src/generate-clarification-question.ts
Summary
Section titled “Summary”Context describing the ambiguity that triggered a clarification request.
Functions
Section titled “Functions”generateClarificationQuestion
Section titled “generateClarificationQuestion”function generateClarificationQuestion(context: ClarificationContext, modelFactory: () => LanguageModel, generateFn: GenerateTextFn): Promise<string | null>Uses an LLM to generate a human-readable clarification question based on the provided ambiguity context.
The generated text is intended to be stored as an
AnnotationOfClarification in the Qanary knowledge graph so that the
chatbot can present it to the user.
Parameters
context(ClarificationContext): Describes the original question and what is ambiguous.modelFactory(() => LanguageModel): Optional override for the LLM model factory (for testing / DI).generateFn(GenerateTextFn): Optional override for the text-generation function. When omitted the function dynamically importsgenerateTextfromai. ReturnsPromise<string | null>: The clarification question string, ornullif generation fails. Defined at: line 51
Interfaces
Section titled “Interfaces”ClarificationContext
Section titled “ClarificationContext”interface ClarificationContextContext describing the ambiguity that triggered a clarification request.
Properties
question(string): The original user question.componentName(string): The component that encountered the ambiguity.ambiguityDescription(string): A description of what is ambiguous and why clarification is needed. Defined at: line 7
GenerateTextFn
Section titled “GenerateTextFn”type GenerateTextFn = (options: { model: LanguageModel; system: string; prompt: string;}) => Promise<{ text: string }>Signature for a text-generation function compatible with the AI SDK’s
generateText. Accepting this as a parameter allows callers (and tests)
to inject their own implementation without having to mock the ai module.
Defined at: line 21
In qanary-component-helpers
Section titled “In qanary-component-helpers”qanary-component-helpers/apiqanary-component-helpers/baseqanary-component-helpers/commonqanary-component-helpers/configurationqanary-component-helpers/create-annotationqanary-component-helpers/create-clarification-annotationqanary-component-helpers/generate-clarification-questionqanary-component-helpers/generate-object-retryqanary-component-helpers/get-domain-instancesqanary-component-helpers/get-question-uriqanary-component-helpers/get-questionqanary-component-helpers/indexqanary-component-helpers/interfaces/question-sparql-responseqanary-component-helpers/llm-providerqanary-component-helpers/message-operationsqanary-component-helpers/query-file-loaderqanary-component-helpers/query-sparqlqanary-component-helpers/utils/question-uri-query