Skip to content

Commit 21bebfc

Browse files
authored
docs: add missing links (#1754)
1 parent 91a18e7 commit 21bebfc

File tree

12 files changed

+59
-34
lines changed

12 files changed

+59
-34
lines changed

.changeset/calm-eggs-type.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@llamaindex/readers": patch
3+
"@llamaindex/core": patch
4+
"@llamaindex/doc": patch
5+
---
6+
7+
Expose more content to fix the issue with unavailable documentation links, and adjust the documentation based on the latest code.

apps/next/scripts/validate-links.mts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ async function validateLinks(): Promise<LinkValidationResult[]> {
162162
const invalidLinks = links.filter(({ link }) => {
163163
// Check if the link exists in valid routes
164164
// First normalize the link (remove any query string or hash)
165-
const normalizedLink = link.split("#")[0].split("?")[0];
165+
const baseLink = link.split("?")[0].split("#")[0];
166+
// Remove the trailing slash if present.
167+
// This works with links like "api/interfaces/MetadataFilter#operator" and "api/interfaces/MetadataFilter/#operator".
168+
const normalizedLink = baseLink.endsWith("/")
169+
? baseLink.slice(0, -1)
170+
: baseLink;
166171

167172
// Remove llamaindex/ prefix if it exists as it's the root of the docs
168173
let routePath = normalizedLink;
@@ -192,8 +197,7 @@ async function main() {
192197

193198
try {
194199
// Check for invalid internal links
195-
const validationResults: LinkValidationResult[] = [];
196-
await validateLinks();
200+
const validationResults: LinkValidationResult[] = await validateLinks();
197201
// Check for relative links
198202
const relativeLinksResults = await findRelativeLinks();
199203

apps/next/src/content/docs/llamaindex/modules/data_loaders/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Currently, the following readers are mapped to specific file types:
3535

3636
- [TextFileReader](/docs/api/classes/TextFileReader): `.txt`
3737
- [PDFReader](/docs/api/classes/PDFReader): `.pdf`
38-
- [PapaCSVReader](/docs/api/classes/PapaCSVReader): `.csv`
38+
- [CSVReader](/docs/api/classes/CSVReader): `.csv`
3939
- [MarkdownReader](/docs/api/classes/MarkdownReader): `.md`
4040
- [DocxReader](/docs/api/classes/DocxReader): `.docx`
4141
- [HTMLReader](/docs/api/classes/HTMLReader): `.htm`, `.html`

apps/next/src/content/docs/llamaindex/modules/data_stores/chat_stores/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Check the [LlamaIndexTS Github](https://github.com/run-llama/LlamaIndexTS) for t
1212

1313
## API Reference
1414

15-
- [BaseChatStore](/docs/api/interfaces/BaseChatStore)
15+
- [BaseChatStore](/docs/api/classes/BaseChatStore)
1616

apps/next/src/content/docs/llamaindex/modules/evaluation/correctness.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ the response is not correct with a score of 2.5
7474

7575
## API Reference
7676

77-
- [CorrectnessEvaluator](/docs/api/classes/CorrectnessEvaluator)
77+
- [CorrectnessEvaluator](/docs/api/classes/CorrectnessEvaluator)

apps/next/src/content/docs/llamaindex/modules/prompt/index.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ Answer:`;
2828

2929
### 1. Customizing the default prompt on initialization
3030

31-
The first method is to create a new instance of `ResponseSynthesizer` (or the module you would like to update the prompt) and pass the custom prompt to the `responseBuilder` parameter. Then, pass the instance to the `asQueryEngine` method of the index.
31+
The first method is to create a new instance of a Response Synthesizer (or the module you would like to update the prompt) by using the getResponseSynthesizer function. Instead of passing the custom prompt to the deprecated responseBuilder parameter, call getResponseSynthesizer with the mode as the first argument and supply the new prompt via the options parameter.
3232

3333
```ts
34-
// Create an instance of response synthesizer
34+
// Create an instance of Response Synthesizer
35+
36+
// Deprecated usage:
3537
const responseSynthesizer = new ResponseSynthesizer({
3638
responseBuilder: new CompactAndRefine(undefined, newTextQaPrompt),
3739
});
3840

41+
// Current usage:
42+
const responseSynthesizer = getResponseSynthesizer('compact', {
43+
textQATemplate: newTextQaPrompt
44+
})
45+
3946
// Create index
4047
const index = await VectorStoreIndex.fromDocuments([document]);
4148

@@ -75,5 +82,5 @@ const response = await queryEngine.query({
7582

7683
## API Reference
7784

78-
- [ResponseSynthesizer](/docs/api/classes/ResponseSynthesizer)
85+
- [Response Synthesizer](/docs/llamaindex/modules/response_synthesizer)
7986
- [CompactAndRefine](/docs/api/classes/CompactAndRefine)

apps/next/src/content/docs/llamaindex/modules/response_synthesizer.mdx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: ResponseSynthesizer
2+
title: Response Synthesizer
33
---
44

55
The ResponseSynthesizer is responsible for sending the query, nodes, and prompt templates to the LLM to generate a response. There are a few key modes for generating a response:
@@ -12,15 +12,17 @@ The ResponseSynthesizer is responsible for sending the query, nodes, and prompt
1212
multiple compact prompts. The same as `refine`, but should result in less LLM calls.
1313
- `TreeSummarize`: Given a set of text chunks and the query, recursively construct a tree
1414
and return the root node as the response. Good for summarization purposes.
15-
- `SimpleResponseBuilder`: Given a set of text chunks and the query, apply the query to each text
16-
chunk while accumulating the responses into an array. Returns a concatenated string of all
17-
responses. Good for when you need to run the same query separately against each text
18-
chunk.
15+
- `MultiModal`: Combines textual inputs with additional modality-specific metadata to generate an integrated response.
16+
It leverages a text QA template to build a prompt that incorporates various input types and produces either streaming or complete responses.
17+
This approach is ideal for use cases where enriching the answer with multi-modal context (such as images, audio, or other data)
18+
can enhance the output quality.
1919

2020
```typescript
21-
import { NodeWithScore, TextNode, ResponseSynthesizer } from "llamaindex";
21+
import { NodeWithScore, TextNode, getResponseSynthesizer, responseModeSchema } from "llamaindex";
2222

23-
const responseSynthesizer = new ResponseSynthesizer();
23+
// you can also use responseModeSchema.Enum.refine, responseModeSchema.Enum.tree_summarize, responseModeSchema.Enum.multi_modal
24+
// or you can use the CompactAndRefine, Refine, TreeSummarize, or MultiModal classes directly
25+
const responseSynthesizer = getResponseSynthesizer(responseModeSchema.Enum.compact);
2426

2527
const nodesWithScore: NodeWithScore[] = [
2628
{
@@ -55,8 +57,9 @@ for await (const chunk of stream) {
5557

5658
## API Reference
5759

58-
- [ResponseSynthesizer](/docs/api/classes/ResponseSynthesizer)
60+
- [getResponseSynthesizer](/docs/api/functions/getResponseSynthesizer)
61+
- [responseModeSchema](/docs/api/variables/responseModeSchema)
5962
- [Refine](/docs/api/classes/Refine)
6063
- [CompactAndRefine](/docs/api/classes/CompactAndRefine)
6164
- [TreeSummarize](/docs/api/classes/TreeSummarize)
62-
- [SimpleResponseBuilder](/docs/api/classes/SimpleResponseBuilder)
65+
- [MultiModal](/docs/api/classes/MultiModal)

apps/next/typedoc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules"],
3-
"entryPoints": ["../../packages/**/src/index.ts"],
3+
"entryPoints": [
4+
"../../packages/{,**/}index.ts",
5+
"../../packages/readers/src/*.ts",
6+
"../../packages/cloud/src/{reader,utils}.ts"
7+
],
48
"exclude": [
59
"../../packages/autotool/**/src/index.ts",
10+
"../../packages/cloud/src/client/index.ts",
611
"**/node_modules/**",
712
"**/dist/**",
813
"**/test/**",

packages/core/src/response-synthesizers/factory.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from "./base-synthesizer";
2424
import { createMessageContent } from "./utils";
2525

26-
const responseModeSchema = z.enum([
26+
export const responseModeSchema = z.enum([
2727
"refine",
2828
"compact",
2929
"tree_summarize",
@@ -35,7 +35,7 @@ export type ResponseMode = z.infer<typeof responseModeSchema>;
3535
/**
3636
* A response builder that uses the query to ask the LLM generate a better response using multiple text chunks.
3737
*/
38-
class Refine extends BaseSynthesizer {
38+
export class Refine extends BaseSynthesizer {
3939
textQATemplate: TextQAPrompt;
4040
refineTemplate: RefinePrompt;
4141

@@ -213,7 +213,7 @@ class Refine extends BaseSynthesizer {
213213
/**
214214
* CompactAndRefine is a slight variation of Refine that first compacts the text chunks into the smallest possible number of chunks.
215215
*/
216-
class CompactAndRefine extends Refine {
216+
export class CompactAndRefine extends Refine {
217217
async getResponse(
218218
query: MessageContent,
219219
nodes: NodeWithScore[],
@@ -267,7 +267,7 @@ class CompactAndRefine extends Refine {
267267
/**
268268
* TreeSummarize repacks the text chunks into the smallest possible number of chunks and then summarizes them, then recursively does so until there's one chunk left.
269269
*/
270-
class TreeSummarize extends BaseSynthesizer {
270+
export class TreeSummarize extends BaseSynthesizer {
271271
summaryTemplate: TreeSummarizePrompt;
272272

273273
constructor(
@@ -370,7 +370,7 @@ class TreeSummarize extends BaseSynthesizer {
370370
}
371371
}
372372

373-
class MultiModal extends BaseSynthesizer {
373+
export class MultiModal extends BaseSynthesizer {
374374
metadataMode: MetadataMode;
375375
textQATemplate: TextQAPrompt;
376376

packages/core/src/response-synthesizers/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ export {
22
BaseSynthesizer,
33
type BaseSynthesizerOptions,
44
} from "./base-synthesizer";
5-
export { getResponseSynthesizer, type ResponseMode } from "./factory";
5+
export {
6+
CompactAndRefine,
7+
MultiModal,
8+
Refine,
9+
TreeSummarize,
10+
getResponseSynthesizer,
11+
responseModeSchema,
12+
type ResponseMode,
13+
} from "./factory";
614
export type {
715
SynthesizeEndEvent,
816
SynthesizeQuery,

0 commit comments

Comments
 (0)