llamaindex
Enumerations
Classes
- BaseEmbedding
- BaseIndex
- BaseNode
- CallbackManager
- CompactAndRefine
- CondenseQuestionChatEngine
- ContextChatEngine
- Document
- InMemoryFileSystem
- IndexDict
- IndexList
- IndexNode
- IndexStruct
- LLMQuestionGenerator
- ListIndex
- ListIndexLLMRetriever
- ListIndexRetriever
- LlamaDeuce
- OpenAI
- OpenAIEmbedding
- PDFReader
- Refine
- Response
- ResponseSynthesizer
- RetrieverQueryEngine
- SentenceSplitter
- SimpleChatEngine
- SimpleDirectoryReader
- SimpleNodeParser
- SimpleResponseBuilder
- SubQuestionOutputParser
- SubQuestionQueryEngine
- TextFileReader
- TextNode
- TreeSummarize
- VectorIndexRetriever
- VectorStoreIndex
Interfaces
- BaseIndexInit
- BaseOutputParser
- BaseQueryEngine
- BaseQuestionGenerator
- BaseReader
- BaseRetriever
- BaseTool
- ChatEngine
- ChatMessage
- ChatResponse
- Event
- GenericFileSystem
- LLM
- NodeParser
- NodeWithEmbedding
- NodeWithScore
- QueryEngineTool
- RelatedNodeInfo
- RetrievalCallbackResponse
- ServiceContext
- ServiceContextOptions
- StorageContext
- StreamCallbackResponse
- StreamToken
- StructuredOutput
- SubQuestion
- ToolMetadata
- VectorIndexConstructorProps
- VectorIndexOptions
- WalkableFileSystem
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
Name | Type |
---|---|
defaultReader? | BaseReader | null |
directoryPath | string |
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
Name | Type |
---|---|
input | Record <string , string > |
Returns
string
Defined in
Prompt.ts:10
Variables
ALL_AVAILABLE_LLAMADEUCE_MODELS
• Const
ALL_AVAILABLE_LLAMADEUCE_MODELS: Object
Type declaration
Name | Type |
---|---|
Llama-2-13b-chat | { contextWindow : number = 4096; replicateApi : string = "a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5" } |
Llama-2-13b-chat.contextWindow | number |
Llama-2-13b-chat.replicateApi | string |
Llama-2-70b-chat | { contextWindow : number = 4096; replicateApi : string = "replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48" } |
Llama-2-70b-chat.contextWindow | number |
Llama-2-70b-chat.replicateApi | string |
Llama-2-7b-chat | { contextWindow : number = 4096; replicateApi : string = "a16z-infra/llama7b-v2-chat:4f0a4744c7295c024a1de15e1a63c880d3da035fa1f49bfd344fe076074c8eea" } |
Llama-2-7b-chat.contextWindow | number |
Llama-2-7b-chat.replicateApi | string |
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
Name | Type |
---|---|
gpt-3.5-turbo | { contextWindow : number = 4096 } |
gpt-3.5-turbo.contextWindow | number |
gpt-3.5-turbo-16k | { contextWindow : number = 16384 } |
gpt-3.5-turbo-16k.contextWindow | number |
gpt-4 | { contextWindow : number = 8192 } |
gpt-4.contextWindow | number |
gpt-4-32k | { contextWindow : number = 32768 } |
gpt-4-32k.contextWindow | number |
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
Name | Type |
---|---|
gpt-4 | { contextWindow : number = 8192 } |
gpt-4.contextWindow | number |
gpt-4-32k | { contextWindow : number = 32768 } |
gpt-4-32k.contextWindow | number |
Defined in
llm/LLM.ts:45
TURBO_MODELS
• Const
TURBO_MODELS: Object
Type declaration
Name | Type |
---|---|
gpt-3.5-turbo | { contextWindow : number = 4096 } |
gpt-3.5-turbo.contextWindow | number |
gpt-3.5-turbo-16k | { contextWindow : number = 16384 } |
gpt-3.5-turbo-16k.contextWindow | number |
Defined in
llm/LLM.ts:50
globalsHelper
• Const
globalsHelper: GlobalsHelper
Defined in
GlobalsHelper.ts:50
Functions
buildToolsText
▸ buildToolsText(tools
): string
Parameters
Name | Type |
---|---|
tools | ToolMetadata [] |
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
Name | Type |
---|---|
input | Record <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
Name | Type |
---|---|
input | Record <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
Name | Type |
---|---|
input | Record <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
Name | Type |
---|---|
input | Record <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
Name | Type |
---|---|
input | Record <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
Name | Type |
---|---|
input | Record <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
Name | Type |
---|---|
input | Record <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
Name | Type | Description |
---|---|---|
fs | GenericFileSystem | The filesystem to use. |
path | string | The 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
Defined in
storage/FileSystem.ts:51
getNodesFromDocument
▸ getNodesFromDocument(document
, textSplitter
, includeMetadata?
, includePrevNextRel?
): TextNode
[]
Parameters
Name | Type | Default value |
---|---|---|
document | Document | undefined |
textSplitter | SentenceSplitter | undefined |
includeMetadata | boolean | true |
includePrevNextRel | boolean | true |
Returns
TextNode
[]
Defined in
NodeParser.ts:15
getResponseBuilder
▸ getResponseBuilder(serviceContext
, responseMode?
): BaseResponseBuilder
Parameters
Name | Type |
---|---|
serviceContext | ServiceContext |
responseMode? | ResponseMode |
Returns
BaseResponseBuilder
Defined in
ResponseSynthesizer.ts:262
getTextSplitsFromDocument
▸ getTextSplitsFromDocument(document
, textSplitter
): string
[]
Parameters
Name | Type |
---|---|
document | Document |
textSplitter | SentenceSplitter |
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
Name | Type | Default value | Description |
---|---|---|---|
queryEmbedding | number [] | undefined | |
embeddings | number [][] | undefined | list of embeddings to consider |
similarityTopK | number | DEFAULT_SIMILARITY_TOP_K | max number of embeddings to return, default 2 |
embeddingIds | null | any [] | null | ids of embeddings in the embeddings list |
similarityCutoff | null | number | null | minimum similarity score |
Returns
[number
[], any
[]]
Defined in
Embedding.ts:77
getTopKEmbeddingsLearner
▸ getTopKEmbeddingsLearner(queryEmbedding
, embeddings
, similarityTopK?
, embeddingsIds?
, queryMode?
): [number
[], any
[]]
Parameters
Name | Type | Default value |
---|---|---|
queryEmbedding | number [] | undefined |
embeddings | number [][] | undefined |
similarityTopK? | number | undefined |
embeddingsIds? | any [] | undefined |
queryMode | VectorStoreQueryMode | VectorStoreQueryMode.SVM |
Returns
[number
[], any
[]]
Defined in
Embedding.ts:119
getTopKMMREmbeddings
▸ getTopKMMREmbeddings(queryEmbedding
, embeddings
, similarityFn?
, similarityTopK?
, embeddingIds?
, _similarityCutoff?
, mmrThreshold?
): [number
[], any
[]]
Parameters
Name | Type | Default value |
---|---|---|
queryEmbedding | number [] | undefined |
embeddings | number [][] | undefined |
similarityFn | null | (...args : any []) => number | null |
similarityTopK | null | number | null |
embeddingIds | null | any [] | null |
_similarityCutoff | null | number | null |
mmrThreshold | null | number | null |
Returns
[number
[], any
[]]
Defined in
Embedding.ts:131
jsonToIndexStruct
▸ jsonToIndexStruct(json
): IndexStruct
Parameters
Name | Type |
---|---|
json | any |
Returns
Defined in
indices/BaseIndex.ts:70
messagesToHistoryStr
▸ messagesToHistoryStr(messages
): string
Parameters
Name | Type |
---|---|
messages | ChatMessage [] |
Returns
string
Defined in
Prompt.ts:300
serviceContextFromDefaults
▸ serviceContextFromDefaults(options?
): ServiceContext
Parameters
Name | Type |
---|---|
options? | ServiceContextOptions |
Returns
Defined in
ServiceContext.ts:30
serviceContextFromServiceContext
▸ serviceContextFromServiceContext(serviceContext
, options
): Object
Parameters
Name | Type |
---|---|
serviceContext | ServiceContext |
options | ServiceContextOptions |
Returns
Object
Name | Type |
---|---|
callbackManager | CallbackManager |
embedModel | BaseEmbedding |
llm | LLM |
nodeParser | NodeParser |
promptHelper | PromptHelper |
Defined in
ServiceContext.ts:48
similarity
▸ similarity(embedding1
, embedding2
, mode?
): number
The similarity between two embeddings.
Parameters
Name | Type | Default value |
---|---|---|
embedding1 | number [] | undefined |
embedding2 | number [] | undefined |
mode | SimilarityType | SimilarityType.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
Name | Type |
---|---|
«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
Name | Type | Description |
---|---|---|
fs | WalkableFileSystem | The filesystem to use. |
dirPath | string | The path to the directory to traverse. |
Returns
AsyncIterable
<string
>
Defined in
storage/FileSystem.ts:91