Skip to main content

llamaindex

Enumerations

Classes

Interfaces

Type Aliases

ChoiceSelectPrompt

Ƭ ChoiceSelectPrompt: typeof defaultChoiceSelectPrompt

Defined in

Prompt.ts:156


CompleteFileSystem

Ƭ CompleteFileSystem: GenericFileSystem & WalkableFileSystem

Defined in

storage/FileSystem.ts:49


CompletionResponse

Ƭ CompletionResponse: ChatResponse

Defined in

llm/LLM.ts:39


CondenseQuestionPrompt

Ƭ CondenseQuestionPrompt: typeof defaultCondenseQuestionPrompt

Defined in

Prompt.ts:337


ContextSystemPrompt

Ƭ ContextSystemPrompt: typeof defaultContextSystemPrompt

Defined in

Prompt.ts:358


EventTag

Ƭ EventTag: "intermediate" | "final"

Defined in

callbacks/CallbackManager.ts:10


EventType

Ƭ EventType: "retrieve" | "llmPredict" | "wrapper"

Defined in

callbacks/CallbackManager.ts:11


ListIndex

Ƭ ListIndex: SummaryIndex

Defined in

indices/summary/SummaryIndex.ts:256


ListIndexLLMRetriever

Ƭ ListIndexLLMRetriever: SummaryIndexLLMRetriever

Defined in

indices/summary/SummaryIndexRetriever.ts:134


ListIndexRetriever

Ƭ ListIndexRetriever: SummaryIndexRetriever

Defined in

indices/summary/SummaryIndexRetriever.ts:133


ListRetrieverMode

Ƭ ListRetrieverMode: SummaryRetrieverMode

Defined in

indices/summary/SummaryIndex.ts:257


MessageType

Ƭ MessageType: "user" | "assistant" | "system" | "generic" | "function"

Defined in

llm/LLM.ts:20


RefinePrompt

Ƭ RefinePrompt: typeof defaultRefinePrompt

Defined in

Prompt.ts:97


RelatedNodeType

Ƭ RelatedNodeType: RelatedNodeInfo | RelatedNodeInfo[]

Defined in

Node.ts:33


SimpleDirectoryReaderLoadDataProps

Ƭ SimpleDirectoryReaderLoadDataProps: Object

Type declaration

NameType
defaultReader?BaseReader | null
directoryPathstring
fileExtToReader?Record<string, BaseReader>
fs?CompleteFileSystem

Defined in

readers/SimpleDirectoryReader.ts:30


SimplePrompt

Ƭ SimplePrompt: (input: Record<string, string | undefined>) => string

Type declaration

▸ (input): string

A SimplePrompt is a function that takes a dictionary of inputs and returns a string. NOTE this is a different interface compared to LlamaIndex Python NOTE 2: we default to empty string to make it easy to calculate prompt sizes

Parameters
NameType
inputRecord<string, string | undefined>
Returns

string

Defined in

Prompt.ts:10


SubQuestionPrompt

Ƭ SubQuestionPrompt: typeof defaultSubQuestionPrompt

Defined in

Prompt.ts:305


SummaryPrompt

Ƭ SummaryPrompt: typeof defaultSummaryPrompt

Defined in

Prompt.ts:64


TextQaPrompt

Ƭ TextQaPrompt: typeof defaultTextQaPrompt

Defined in

Prompt.ts:37


TreeSummarizePrompt

Ƭ TreeSummarizePrompt: typeof defaultTreeSummarizePrompt

Defined in

Prompt.ts:122

Variables

ALL_AVAILABLE_LLAMADEUCE_MODELS

Const ALL_AVAILABLE_LLAMADEUCE_MODELS: Object

Type declaration

NameType
Llama-2-13b-chat{ contextWindow: number = 4096; replicateApi: string = "a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5" }
Llama-2-13b-chat.contextWindownumber
Llama-2-13b-chat.replicateApistring
Llama-2-13b-chat-4bit{ contextWindow: number = 4096; replicateApi: string = "a16z-infra/llama13b-v2-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52" }
Llama-2-13b-chat-4bit.contextWindownumber
Llama-2-13b-chat-4bit.replicateApistring
Llama-2-70b-chat-4bit{ contextWindow: number = 4096; replicateApi: string = "replicate/llama70b-v2-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" }
Llama-2-70b-chat-4bit.contextWindownumber
Llama-2-70b-chat-4bit.replicateApistring
Llama-2-70b-chat-old{ contextWindow: number = 4096; replicateApi: string = "replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48" }
Llama-2-70b-chat-old.contextWindownumber
Llama-2-70b-chat-old.replicateApistring
Llama-2-7b-chat{ contextWindow: number = 4096; replicateApi: string = "a16z-infra/llama7b-v2-chat:4f0a4744c7295c024a1de15e1a63c880d3da035fa1f49bfd344fe076074c8eea" }
Llama-2-7b-chat.contextWindownumber
Llama-2-7b-chat.replicateApistring
Llama-2-7b-chat-4bit{ contextWindow: number = 4096; replicateApi: string = "a16z-infra/llama7b-v2-chat:4f0b260b6a13eb53a6b1891f089d57c08f41003ae79458be5011303d81a394dc" }
Llama-2-7b-chat-4bit.contextWindownumber
Llama-2-7b-chat-4bit.replicateApistring

Defined in

llm/LLM.ts:222


ALL_AVAILABLE_OPENAI_MODELS

Const ALL_AVAILABLE_OPENAI_MODELS: Object

We currently support GPT-3.5 and GPT-4 models

Type declaration

NameType
gpt-3.5-turbo{ contextWindow: number = 4096 }
gpt-3.5-turbo.contextWindownumber
gpt-3.5-turbo-16k{ contextWindow: number = 16384 }
gpt-3.5-turbo-16k.contextWindownumber
gpt-4{ contextWindow: number = 8192 }
gpt-4.contextWindownumber
gpt-4-32k{ contextWindow: number = 32768 }
gpt-4-32k.contextWindownumber

Defined in

llm/LLM.ts:71


DEFAULT_CHUNK_OVERLAP

Const DEFAULT_CHUNK_OVERLAP: 20

Defined in

constants.ts:5


DEFAULT_CHUNK_OVERLAP_RATIO

Const DEFAULT_CHUNK_OVERLAP_RATIO: 0.1

Defined in

constants.ts:6


DEFAULT_CHUNK_SIZE

Const DEFAULT_CHUNK_SIZE: 1024

Defined in

constants.ts:4


DEFAULT_COLLECTION

Const DEFAULT_COLLECTION: "data"

Defined in

storage/constants.ts:1


DEFAULT_CONTEXT_WINDOW

Const DEFAULT_CONTEXT_WINDOW: 3900

Defined in

constants.ts:1


DEFAULT_DOC_STORE_PERSIST_FILENAME

Const DEFAULT_DOC_STORE_PERSIST_FILENAME: "doc_store.json"

Defined in

storage/constants.ts:4


DEFAULT_EMBEDDING_DIM

Const DEFAULT_EMBEDDING_DIM: 1536

Defined in

constants.ts:10


DEFAULT_FS

Const DEFAULT_FS: GenericFileSystem | CompleteFileSystem

Defined in

storage/FileSystem.ts:62


DEFAULT_GRAPH_STORE_PERSIST_FILENAME

Const DEFAULT_GRAPH_STORE_PERSIST_FILENAME: "graph_store.json"

Defined in

storage/constants.ts:6


DEFAULT_INDEX_STORE_PERSIST_FILENAME

Const DEFAULT_INDEX_STORE_PERSIST_FILENAME: "index_store.json"

Defined in

storage/constants.ts:3


DEFAULT_NAMESPACE

Const DEFAULT_NAMESPACE: "docstore"

Defined in

storage/constants.ts:7


DEFAULT_NUM_OUTPUTS

Const DEFAULT_NUM_OUTPUTS: 256

Defined in

constants.ts:2


DEFAULT_PADDING

Const DEFAULT_PADDING: 5

Defined in

constants.ts:11


DEFAULT_PERSIST_DIR

Const DEFAULT_PERSIST_DIR: "./storage"

Defined in

storage/constants.ts:2


DEFAULT_SIMILARITY_TOP_K

Const DEFAULT_SIMILARITY_TOP_K: 2

Defined in

constants.ts:7


DEFAULT_VECTOR_STORE_PERSIST_FILENAME

Const DEFAULT_VECTOR_STORE_PERSIST_FILENAME: "vector_store.json"

Defined in

storage/constants.ts:5


GPT4_MODELS

Const GPT4_MODELS: Object

Type declaration

NameType
gpt-4{ contextWindow: number = 8192 }
gpt-4.contextWindownumber
gpt-4-32k{ contextWindow: number = 32768 }
gpt-4-32k.contextWindownumber

Defined in

llm/LLM.ts:58


TURBO_MODELS

Const TURBO_MODELS: Object

Type declaration

NameType
gpt-3.5-turbo{ contextWindow: number = 4096 }
gpt-3.5-turbo.contextWindownumber
gpt-3.5-turbo-16k{ contextWindow: number = 16384 }
gpt-3.5-turbo-16k.contextWindownumber

Defined in

llm/LLM.ts:63


globalsHelper

Const globalsHelper: GlobalsHelper

Defined in

GlobalsHelper.ts:50


unixLineSeparator

Const unixLineSeparator: "\n"

Defined in

TextSplitter.ts:44


unixParagraphSeparator

Const unixParagraphSeparator: string

Defined in

TextSplitter.ts:46


windowsLineSeparator

Const windowsLineSeparator: "\r\n"

Defined in

TextSplitter.ts:45


windowsParagraphSeparator

Const windowsParagraphSeparator: string

Defined in

TextSplitter.ts:47

Functions

buildToolsText

buildToolsText(tools): string

Parameters

NameType
toolsToolMetadata[]

Returns

string

Defined in

Prompt.ts:234


cjkSentenceTokenizer

cjkSentenceTokenizer(text): null | RegExpMatchArray

Tokenizes sentences. Suitable for Chinese, Japanese, and Korean.

Parameters

NameType
textstring

Returns

null | RegExpMatchArray

Defined in

TextSplitter.ts:36


defaultChoiceSelectPrompt

defaultChoiceSelectPrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:124


defaultCondenseQuestionPrompt

defaultCondenseQuestionPrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:321


defaultContextSystemPrompt

defaultContextSystemPrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:351


defaultRefinePrompt

defaultRefinePrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:82


defaultSubQuestionPrompt

defaultSubQuestionPrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:275


defaultSummaryPrompt

defaultSummaryPrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:53


defaultTextQaPrompt

defaultTextQaPrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:27


defaultTreeSummarizePrompt

defaultTreeSummarizePrompt(«destructured»): string

Parameters

NameType
«destructured»Object

Returns

string

Defined in

Prompt.ts:112


englishSentenceTokenizer

englishSentenceTokenizer(text): null | RegExpMatchArray

Tokenizes sentences. Suitable for English and most European languages.

Parameters

NameType
textstring

Returns

null | RegExpMatchArray

Defined in

TextSplitter.ts:26


exists

exists(fs, path): Promise<boolean>

Checks if a file exists. Analogous to the os.path.exists function from Python.

Parameters

NameTypeDescription
fsGenericFileSystemThe filesystem to use.
pathstringThe path to the file to check.

Returns

Promise<boolean>

A promise that resolves to true if the file exists, false otherwise.

Defined in

storage/FileSystem.ts:74


getNodeFS

getNodeFS(): CompleteFileSystem

Returns

CompleteFileSystem

Defined in

storage/FileSystem.ts:51


getNodesFromDocument

getNodesFromDocument(document, textSplitter, includeMetadata?, includePrevNextRel?): TextNode[]

Generates an array of nodes from a document.

Parameters

NameTypeDefault valueDescription
documentDocumentundefinedThe document to generate nodes from.
textSplitterSentenceSplitterundefinedThe text splitter to use.
includeMetadatabooleantrueWhether to include metadata in the nodes.
includePrevNextRelbooleantrueWhether to include previous and next relationships in the nodes.

Returns

TextNode[]

An array of nodes.

Defined in

NodeParser.ts:29


getResponseBuilder

getResponseBuilder(serviceContext, responseMode?): BaseResponseBuilder

Parameters

NameType
serviceContextServiceContext
responseMode?ResponseMode

Returns

BaseResponseBuilder

Defined in

ResponseSynthesizer.ts:268


getTextSplitsFromDocument

getTextSplitsFromDocument(document, textSplitter): string[]

Splits the text of a document into smaller parts.

Parameters

NameTypeDescription
documentDocumentThe document to split.
textSplitterSentenceSplitterThe text splitter to use.

Returns

string[]

An array of text splits.

Defined in

NodeParser.ts:11


getTopKEmbeddings

getTopKEmbeddings(queryEmbedding, embeddings, similarityTopK?, embeddingIds?, similarityCutoff?): [number[], any[]]

Get the top K embeddings from a list of embeddings ordered by similarity to the query.

Parameters

NameTypeDefault valueDescription
queryEmbeddingnumber[]undefined
embeddingsnumber[][]undefinedlist of embeddings to consider
similarityTopKnumberDEFAULT_SIMILARITY_TOP_Kmax number of embeddings to return, default 2
embeddingIdsnull | any[]nullids of embeddings in the embeddings list
similarityCutoffnull | numbernullminimum similarity score

Returns

[number[], any[]]

Defined in

Embedding.ts:86


getTopKEmbeddingsLearner

getTopKEmbeddingsLearner(queryEmbedding, embeddings, similarityTopK?, embeddingsIds?, queryMode?): [number[], any[]]

Parameters

NameTypeDefault value
queryEmbeddingnumber[]undefined
embeddingsnumber[][]undefined
similarityTopK?numberundefined
embeddingsIds?any[]undefined
queryModeVectorStoreQueryModeVectorStoreQueryMode.SVM

Returns

[number[], any[]]

Defined in

Embedding.ts:128


getTopKMMREmbeddings

getTopKMMREmbeddings(queryEmbedding, embeddings, similarityFn?, similarityTopK?, embeddingIds?, _similarityCutoff?, mmrThreshold?): [number[], any[]]

Parameters

NameTypeDefault value
queryEmbeddingnumber[]undefined
embeddingsnumber[][]undefined
similarityFnnull | (...args: any[]) => numbernull
similarityTopKnull | numbernull
embeddingIdsnull | any[]null
_similarityCutoffnull | numbernull
mmrThresholdnull | numbernull

Returns

[number[], any[]]

Defined in

Embedding.ts:140


jsonToIndexStruct

jsonToIndexStruct(json): IndexStruct

Parameters

NameType
jsonany

Returns

IndexStruct

Defined in

indices/BaseIndex.ts:73


jsonToNode

jsonToNode(json): TextNode

Parameters

NameType
jsonany

Returns

TextNode

Defined in

Node.ts:271


messagesToHistoryStr

messagesToHistoryStr(messages): string

Parameters

NameType
messagesChatMessage[]

Returns

string

Defined in

Prompt.ts:339


serviceContextFromDefaults

serviceContextFromDefaults(options?): ServiceContext

Parameters

NameType
options?ServiceContextOptions

Returns

ServiceContext

Defined in

ServiceContext.ts:30


serviceContextFromServiceContext

serviceContextFromServiceContext(serviceContext, options): Object

Parameters

NameType
serviceContextServiceContext
optionsServiceContextOptions

Returns

Object

NameType
callbackManagerCallbackManager
embedModelBaseEmbedding
llmLLM
nodeParserNodeParser
promptHelperPromptHelper

Defined in

ServiceContext.ts:48


similarity

similarity(embedding1, embedding2, mode?): number

The similarity between two embeddings.

Parameters

NameTypeDefault value
embedding1number[]undefined
embedding2number[]undefined
modeSimilarityTypeSimilarityType.DEFAULT

Returns

number

similartiy score with higher numbers meaning the two embeddings are more similar

Defined in

Embedding.ts:31


storageContextFromDefaults

storageContextFromDefaults(«destructured»): Promise<StorageContext>

Parameters

NameType
«destructured»BuilderParams

Returns

Promise<StorageContext>

Defined in

storage/StorageContext.ts:24


walk

walk(fs, dirPath): AsyncIterable<string>

Recursively traverses a directory and yields all the paths to the files in it.

Parameters

NameTypeDescription
fsWalkableFileSystemThe filesystem to use.
dirPathstringThe path to the directory to traverse.

Returns

AsyncIterable<string>

Defined in

storage/FileSystem.ts:91