Skip to main content

llamaindex

Enumerations

Classes

Interfaces

Type Aliases

CompleteFileSystem

Ƭ CompleteFileSystem: GenericFileSystem & WalkableFileSystem

Defined in

storage/FileSystem.ts:49


CompletionResponse

Ƭ CompletionResponse: ChatResponse

Defined in

llm/LLM.ts:26


EventTag

Ƭ EventTag: "intermediate" | "final"

Defined in

callbacks/CallbackManager.ts:10


EventType

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

Defined in

callbacks/CallbackManager.ts:11


MessageType

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

Defined in

llm/LLM.ts:7


RelatedNodeType

Ƭ RelatedNodeType: RelatedNodeInfo | RelatedNodeInfo[]

Defined in

Node.ts:32


SimpleDirectoryReaderLoadDataProps

Ƭ SimpleDirectoryReaderLoadDataProps: Object

Type declaration

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

Defined in

readers/SimpleDirectoryReader.ts:26


SimplePrompt

Ƭ SimplePrompt: (input: Record<string, string>) => 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>
Returns

string

Defined in

Prompt.ts:10

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-70b-chat{ contextWindow: number = 4096; replicateApi: string = "replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48" }
Llama-2-70b-chat.contextWindownumber
Llama-2-70b-chat.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

Defined in

llm/LLM.ts:162


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:58


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: "docstore.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:45


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:50


globalsHelper

Const globalsHelper: GlobalsHelper

Defined in

GlobalsHelper.ts:50

Functions

buildToolsText

buildToolsText(tools): string

Parameters

NameType
toolsToolMetadata[]

Returns

string

Defined in

Prompt.ts:198


contextSystemPrompt

contextSystemPrompt(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>

Returns

string

Defined in

Prompt.ts:10


defaultChoiceSelectPrompt

defaultChoiceSelectPrompt(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>

Returns

string

Defined in

Prompt.ts:10


defaultCondenseQuestionPrompt

defaultCondenseQuestionPrompt(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>

Returns

string

Defined in

Prompt.ts:10


defaultRefinePrompt

defaultRefinePrompt(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>

Returns

string

Defined in

Prompt.ts:10


defaultSubQuestionPrompt

defaultSubQuestionPrompt(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>

Returns

string

Defined in

Prompt.ts:10


defaultSummaryPrompt

defaultSummaryPrompt(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>

Returns

string

Defined in

Prompt.ts:10


defaultTextQaPrompt

defaultTextQaPrompt(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>

Returns

string

Defined in

Prompt.ts:10


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[]

Parameters

NameTypeDefault value
documentDocumentundefined
textSplitterSentenceSplitterundefined
includeMetadatabooleantrue
includePrevNextRelbooleantrue

Returns

TextNode[]

Defined in

NodeParser.ts:15


getResponseBuilder

getResponseBuilder(serviceContext, responseMode?): BaseResponseBuilder

Parameters

NameType
serviceContextServiceContext
responseMode?ResponseMode

Returns

BaseResponseBuilder

Defined in

ResponseSynthesizer.ts:262


getTextSplitsFromDocument

getTextSplitsFromDocument(document, textSplitter): string[]

Parameters

NameType
documentDocument
textSplitterSentenceSplitter

Returns

string[]

Defined in

NodeParser.ts:5


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:77


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:119


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:131


jsonToIndexStruct

jsonToIndexStruct(json): IndexStruct

Parameters

NameType
jsonany

Returns

IndexStruct

Defined in

indices/BaseIndex.ts:70


messagesToHistoryStr

messagesToHistoryStr(messages): string

Parameters

NameType
messagesChatMessage[]

Returns

string

Defined in

Prompt.ts:300


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:22


storageContextFromDefaults

storageContextFromDefaults(«destructured»): Promise<StorageContext>

Parameters

NameType
«destructured»BuilderParams

Returns

Promise<StorageContext>

Defined in

storage/StorageContext.ts:28


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