Interface: DocsQAProps<ChunkMetadata>
batteries/docs.DocsQAProps
Properties to be passed to the DocsQA component.
Type parameters
Name | Type |
---|---|
ChunkMetadata | extends Jsonifiable = Jsonifiable |
Properties
corpus
• corpus: Corpus
<ChunkMetadata
>
The corpus of documents that may be relevant to a query.
Defined in
packages/ai-jsx/src/batteries/docs.tsx:739
question
• question: string
The question to answer.
Defined in
packages/ai-jsx/src/batteries/docs.tsx:744
chunkFormatter
• Optional
chunkFormatter: (props
: { doc
: ScoredChunk
<ChunkMetadata
> }) => Node
Type declaration
▸ (props
): Node
The component used to format document chunks when they're presented to the model. This can be used to present the model with some metadata about the chunk, in a format that is appropriate to the type of document.
function FormatChunk({ chunk }: { chunk: ScoredChunk }) {
return <>
Title: {chunk.chunk.documentName}
Content: {chunk.chunk.content}
</>
}
Parameters
Name | Type |
---|---|
props | Object |
props.doc | ScoredChunk <ChunkMetadata > |
Returns
Defined in
packages/ai-jsx/src/batteries/docs.tsx:768
chunkLimit
• Optional
chunkLimit: number
When processing a DocsQA query, the most relevent chunks are presented to the model. This field limits the number of chunks to consider. If this value is too large, the size of the chunks may exceed the token limit of the model.
Defined in
packages/ai-jsx/src/batteries/docs.tsx:752
resultFormatter
• Optional
resultFormatter: (result
: {}) => Node
Type declaration
▸ (result
): Node
The component used to format results from a DocsQAWithSources query.
function FormatQAResult(result: QAWithSourcesResult) {
if (result.sources?.length) {
return `${result.answer}\n\nSources:\n${result.sources.join('\n')}`;
}
return result.answer;
}
Parameters
Name | Type |
---|---|
result | Object |