llamaindex
Enumerations
- DeuceChatStrategy
- IndexStructType
- MetadataMode
- NodeRelationship
- ObjectType
- SimilarityType
- SummaryRetrieverMode
- VectorStoreQueryMode
Classes
- Anthropic
- BaseDocumentStore
- BaseEmbedding
- BaseInMemoryKVStore
- BaseIndex
- BaseIndexStore
- BaseKVStore
- BaseNode
- CallbackManager
- CompactAndRefine
- CondenseQuestionChatEngine
- ContextChatEngine
- Document
- InMemoryFileSystem
- IndexDict
- IndexList
- IndexNode
- IndexStruct
- LLMQuestionGenerator
- LlamaDeuce
- MarkdownReader
- NotionReader
- OpenAI
- OpenAIEmbedding
- PDFReader
- PapaCSVReader
- Refine
- Response
- ResponseSynthesizer
- RetrieverQueryEngine
- SentenceSplitter
- SimpleChatEngine
- SimpleDirectoryReader
- SimpleDocumentStore
- SimpleIndexStore
- SimpleKVStore
- SimpleNodeParser
- SimpleResponseBuilder
- SimpleVectorStore
- SubQuestionOutputParser
- SubQuestionQueryEngine
- SummaryIndex
- SummaryIndexLLMRetriever
- SummaryIndexRetriever
- TextFileReader
- TextNode
- TreeSummarize
- VectorIndexRetriever
- VectorStoreIndex
Interfaces
- BaseIndexInit
- BaseOutputParser
- BaseQueryEngine
- BaseQuestionGenerator
- BaseReader
- BaseRetriever
- BaseTool
- ChatEngine
- ChatMessage
- ChatResponse
- Event
- ExactMatchFilter
- GenericFileSystem
- LLM
- MetadataFilters
- MetadataInfo
- NodeParser
- NodeWithScore
- QueryEngineTool
- RefDocInfo
- RelatedNodeInfo
- RetrievalCallbackResponse
- ServiceContext
- ServiceContextOptions
- StorageContext
- StreamCallbackResponse
- StreamToken
- StructuredOutput
- SubQuestion
- ToolMetadata
- VectorStore
- VectorStoreInfo
- VectorStoreQuery
- VectorStoreQueryResult
- VectorStoreQuerySpec
- WalkableFileSystem
Type Aliases
ChoiceSelectPrompt
Ƭ ChoiceSelectPrompt: typeof defaultChoiceSelectPrompt
Defined in
CompleteFileSystem
Ƭ CompleteFileSystem: GenericFileSystem
& WalkableFileSystem
Defined in
CompletionResponse
Ƭ CompletionResponse: ChatResponse
Defined in
CondenseQuestionPrompt
Ƭ CondenseQuestionPrompt: typeof defaultCondenseQuestionPrompt
Defined in
ContextSystemPrompt
Ƭ ContextSystemPrompt: typeof defaultContextSystemPrompt
Defined in
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
RefinePrompt
Ƭ RefinePrompt: typeof defaultRefinePrompt
Defined in
RelatedNodeType
Ƭ RelatedNodeType: RelatedNodeInfo
| RelatedNodeInfo
[]
Defined in
SimpleDirectoryReaderLoadDataProps
Ƭ SimpleDirectoryReaderLoadDataProps: Object
Type declaration
Name | Type |
---|---|
defaultReader? | BaseReader | null |
directoryPath | string |
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
Name | Type |
---|---|
input | Record <string , string | undefined > |
Returns
string
Defined in
SubQuestionPrompt
Ƭ SubQuestionPrompt: typeof defaultSubQuestionPrompt
Defined in
SummaryPrompt
Ƭ SummaryPrompt: typeof defaultSummaryPrompt
Defined in
TextQaPrompt
Ƭ TextQaPrompt: typeof defaultTextQaPrompt
Defined in
TreeSummarizePrompt
Ƭ TreeSummarizePrompt: typeof defaultTreeSummarizePrompt
Defined in
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-13b-chat-4bit | { contextWindow : number = 4096; replicateApi : string = "a16z-infra/llama13b-v2-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52" } |
Llama-2-13b-chat-4bit.contextWindow | number |
Llama-2-13b-chat-4bit.replicateApi | string |
Llama-2-70b-chat-4bit | { contextWindow : number = 4096; replicateApi : string = "replicate/llama70b-v2-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" } |
Llama-2-70b-chat-4bit.contextWindow | number |
Llama-2-70b-chat-4bit.replicateApi | string |
Llama-2-70b-chat-old | { contextWindow : number = 4096; replicateApi : string = "replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48" } |
Llama-2-70b-chat-old.contextWindow | number |
Llama-2-70b-chat-old.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 |
Llama-2-7b-chat-4bit | { contextWindow : number = 4096; replicateApi : string = "a16z-infra/llama7b-v2-chat:4f0b260b6a13eb53a6b1891f089d57c08f41003ae79458be5011303d81a394dc" } |
Llama-2-7b-chat-4bit.contextWindow | number |
Llama-2-7b-chat-4bit.replicateApi | string |
Defined in
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
DEFAULT_CHUNK_OVERLAP
• Const
DEFAULT_CHUNK_OVERLAP: 20
Defined in
DEFAULT_CHUNK_OVERLAP_RATIO
• Const
DEFAULT_CHUNK_OVERLAP_RATIO: 0.1
Defined in
DEFAULT_CHUNK_SIZE
• Const
DEFAULT_CHUNK_SIZE: 1024
Defined in
DEFAULT_COLLECTION
• Const
DEFAULT_COLLECTION: "data"
Defined in
DEFAULT_CONTEXT_WINDOW
• Const
DEFAULT_CONTEXT_WINDOW: 3900
Defined in
DEFAULT_DOC_STORE_PERSIST_FILENAME
• Const
DEFAULT_DOC_STORE_PERSIST_FILENAME: "doc_store.json"
Defined in
DEFAULT_EMBEDDING_DIM
• Const
DEFAULT_EMBEDDING_DIM: 1536
Defined in
DEFAULT_FS
• Const
DEFAULT_FS: GenericFileSystem
| CompleteFileSystem
Defined in
DEFAULT_GRAPH_STORE_PERSIST_FILENAME
• Const
DEFAULT_GRAPH_STORE_PERSIST_FILENAME: "graph_store.json"
Defined in
DEFAULT_INDEX_STORE_PERSIST_FILENAME
• Const
DEFAULT_INDEX_STORE_PERSIST_FILENAME: "index_store.json"
Defined in
DEFAULT_NAMESPACE
• Const
DEFAULT_NAMESPACE: "docstore"
Defined in
DEFAULT_NUM_OUTPUTS
• Const
DEFAULT_NUM_OUTPUTS: 256
Defined in
DEFAULT_PADDING
• Const
DEFAULT_PADDING: 5
Defined in
DEFAULT_PERSIST_DIR
• Const
DEFAULT_PERSIST_DIR: "./storage"
Defined in
DEFAULT_SIMILARITY_TOP_K
• Const
DEFAULT_SIMILARITY_TOP_K: 2
Defined in
DEFAULT_VECTOR_STORE_PERSIST_FILENAME
• Const
DEFAULT_VECTOR_STORE_PERSIST_FILENAME: "vector_store.json"
Defined in
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
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
globalsHelper
• Const
globalsHelper: GlobalsHelper
Defined in
unixLineSeparator
• Const
unixLineSeparator: "\n"
Defined in
unixParagraphSeparator
• Const
unixParagraphSeparator: string
Defined in
windowsLineSeparator
• Const
windowsLineSeparator: "\r\n"
Defined in
windowsParagraphSeparator
• Const
windowsParagraphSeparator: string
Defined in
Functions
buildToolsText
▸ buildToolsText(tools
): string
Parameters
Name | Type |
---|---|
tools | ToolMetadata [] |
Returns
string
Defined in
cjkSentenceTokenizer
▸ cjkSentenceTokenizer(text
): null
| RegExpMatchArray
Tokenizes sentences. Suitable for Chinese, Japanese, and Korean.
Parameters
Name | Type |
---|---|
text | string |
Returns
null
| RegExpMatchArray
Defined in
defaultChoiceSelectPrompt
▸ defaultChoiceSelectPrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
defaultCondenseQuestionPrompt
▸ defaultCondenseQuestionPrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
defaultContextSystemPrompt
▸ defaultContextSystemPrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
defaultRefinePrompt
▸ defaultRefinePrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
defaultSubQuestionPrompt
▸ defaultSubQuestionPrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
defaultSummaryPrompt
▸ defaultSummaryPrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
defaultTextQaPrompt
▸ defaultTextQaPrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
defaultTreeSummarizePrompt
▸ defaultTreeSummarizePrompt(«destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
englishSentenceTokenizer
▸ englishSentenceTokenizer(text
): null
| RegExpMatchArray
Tokenizes sentences. Suitable for English and most European languages.
Parameters
Name | Type |
---|---|
text | string |
Returns
null
| RegExpMatchArray
Defined in
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
getNodeFS
▸ getNodeFS(): CompleteFileSystem
Returns
Defined in
getNodesFromDocument
▸ getNodesFromDocument(document
, textSplitter
, includeMetadata?
, includePrevNextRel?
): TextNode
[]
Generates an array of nodes from a document.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
document | Document | undefined | The document to generate nodes from. |
textSplitter | SentenceSplitter | undefined | The text splitter to use. |
includeMetadata | boolean | true | Whether to include metadata in the nodes. |
includePrevNextRel | boolean | true | Whether to include previous and next relationships in the nodes. |
Returns
TextNode
[]
An array of nodes.
Defined in
getResponseBuilder
▸ getResponseBuilder(serviceContext
, responseMode?
): BaseResponseBuilder
Parameters
Name | Type |
---|---|
serviceContext | ServiceContext |
responseMode? | ResponseMode |
Returns
BaseResponseBuilder
Defined in
getTextSplitsFromDocument
▸ getTextSplitsFromDocument(document
, textSplitter
): string
[]
Splits the text of a document into smaller parts.
Parameters
Name | Type | Description |
---|---|---|
document | Document | The document to split. |
textSplitter | SentenceSplitter | The text splitter to use. |
Returns
string
[]
An array of text splits.
Defined in
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
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
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
jsonToIndexStruct
▸ jsonToIndexStruct(json
): IndexStruct
Parameters
Name | Type |
---|---|
json | any |
Returns
Defined in
jsonToNode
▸ jsonToNode(json
): TextNode
Parameters
Name | Type |
---|---|
json | any |
Returns
Defined in
messagesToHistoryStr
▸ messagesToHistoryStr(messages
): string
Parameters
Name | Type |
---|---|
messages | ChatMessage [] |
Returns
string
Defined in
serviceContextFromDefaults
▸ serviceContextFromDefaults(options?
): ServiceContext
Parameters
Name | Type |
---|---|
options? | ServiceContextOptions |
Returns
Defined in
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
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
storageContextFromDefaults
▸ storageContextFromDefaults(«destructured»
): Promise
<StorageContext
>
Parameters
Name | Type |
---|---|
«destructured» | BuilderParams |
Returns
Promise
<StorageContext
>
Defined in
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
>