Interface: DocsQAWithCitationsProps<ChunkMetadata>
batteries/docs.DocsQAWithCitationsProps
Properties to be passed to the DocsQA component.
Type parameters
Name | Type |
---|---|
ChunkMetadata | extends Jsonifiable = Jsonifiable |
Hierarchy
DocsQAProps
<ChunkMetadata
>↳
DocsQAWithCitationsProps
Properties
corpus
• corpus: Corpus
<ChunkMetadata
>
The corpus of documents that may be relevant to a query.
Inherited from
Defined in
ai-jsx/src/batteries/docs.tsx:775
question
• question: string
The question to answer.
Inherited from
Defined in
ai-jsx/src/batteries/docs.tsx:780
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
Inherited from
Defined in
ai-jsx/src/batteries/docs.tsx:804
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.
Inherited from
Defined in
ai-jsx/src/batteries/docs.tsx:788
resultFormatter
• Optional
resultFormatter: (result
: Partial
<{ answer
: string
; sources
: string
[] }>) => Node
Type declaration
▸ (result
): Node
The component used to format results from a DocsQAWithCitations query.
function FormatQAResult(result: QAWithCitationsResult) {
if (result.sources?.length) {
return `${result.answer}\n\nSources:\n${result.sources.join('\n')}`;
}
return result.answer;
}
Parameters
Name | Type |
---|---|
result | Partial <{ answer : string ; sources : string [] }> |