mongodb-rag-core
Interfaces
Type Aliases
DatabaseConnection
Ƭ DatabaseConnection: Object
Type declaration
Name | Type |
---|---|
close | (force? : boolean ) => Promise <void > |
drop | () => Promise <void > |
Defined in
packages/mongodb-rag-core/src/DatabaseConnection.ts:1
EmbedArgs
Ƭ EmbedArgs: Object
Type declaration
Name | Type | Description |
---|---|---|
text | string | The text to embed. |
Defined in
packages/mongodb-rag-core/src/Embedder.ts:1
EmbedResult
Ƭ EmbedResult: Object
Type declaration
Name | Type | Description |
---|---|---|
embedding | number [] | Vector embedding of the text. |
Defined in
packages/mongodb-rag-core/src/Embedder.ts:8
EmbeddedContentStore
Ƭ EmbeddedContentStore: VectorStore
<EmbeddedContent
> & { close?
: () => Promise
<void
> ; deleteEmbeddedContent
: (args
: { page
: Page
}) => Promise
<void
> ; loadEmbeddedContent
: (args
: { page
: Page
}) => Promise
<EmbeddedContent
[]> ; updateEmbeddedContent
: (args
: { embeddedContent
: EmbeddedContent
[] ; page
: Page
}) => Promise
<void
> }
Data store of the embedded content.
Defined in
packages/mongodb-rag-core/src/EmbeddedContent.ts:60
Embedder
Ƭ Embedder: Object
Takes a string of text and returns an array of numbers representing the vector embedding of the text.
Type declaration
Name | Type |
---|---|
embed | (args : EmbedArgs ) => Promise <EmbedResult > |
Defined in
packages/mongodb-rag-core/src/Embedder.ts:19
FindNearestNeighborsOptions
Ƭ FindNearestNeighborsOptions: Object
Options for performing a nearest-neighbor search.
Type declaration
Name | Type | Description |
---|---|---|
filter | Record <string , unknown > | Search filter expression. |
indexName | string | The name of the index to use. |
k | number | The number of nearest neighbors to return. |
minScore | number | The minimum nearest-neighbor score threshold between 0-1. |
numCandidates | number | Number of nearest neighbors to use during the search. Value must be less than or equal to 10000. You can't specify a number less than the number of documents to return (k). |
path | string | The keypath to the field with the vector data to use. |
Defined in
packages/mongodb-rag-core/src/VectorStore.ts:21
LoadPagesArgs
Ƭ LoadPagesArgs<QueryShape
>: Object
Type parameters
Name | Type |
---|---|
QueryShape | unknown |
Type declaration
Name | Type | Description |
---|---|---|
query? | QueryShape | A custom query to refine the pages to load. |
sources? | string [] | The names of the sources to load pages from. If undefined, loads available pages from all sources. |
updated? | Date | If specified, refines the query to load pages with an updated date later or equal to the given date. |
urls? | string [] | If specified, refines the query to only load pages where the url is included in the list. |
Defined in
packages/mongodb-rag-core/src/Page.ts:61
MakeLangChainEmbedderParams
Ƭ MakeLangChainEmbedderParams: Object
Type declaration
Name | Type | Description |
---|---|---|
langChainEmbeddings | Embeddings | LangChain.js Embeddings instance. You can configure things like caching and retry behavior in the Embeddings instance. |
Defined in
packages/mongodb-rag-core/src/LangChainEmbedder.ts:3
MakeOpenAiEmbedderArgs
Ƭ MakeOpenAiEmbedderArgs: Object
Type declaration
Name | Type | Description |
---|---|---|
backoffOptions? | BackoffOptions | Options used for automatic retry (usually due to rate limiting). |
deployment | string | The deployment key. |
openAiClient | OpenAIClient | The OpenAI client. |
Defined in
packages/mongodb-rag-core/src/OpenAiEmbedder.ts:7
MakeTypeChatJsonTranslateFuncArgs
Ƭ MakeTypeChatJsonTranslateFuncArgs: Object
Type declaration
Name | Type | Description |
---|---|---|
azureOpenAiServiceConfig | AzureOpenAiServiceConfig | Settings for using the Azure service. |
numRetries? | number | Number of times to retry the query preprocessor if it fails. |
retryDelayMs? | number | Delay between retries in milliseconds. |
schema | string | The text of a .d.ts that would inform the schema. |
schemaName | string | The name of the TypeChat schema or interface. |
Defined in
packages/mongodb-rag-core/src/TypeChatJsonTranslateFunc.ts:11
MongoDbPageStore
Ƭ MongoDbPageStore: DatabaseConnection
& Omit
<PageStore
, "loadPages"
> & { queryType
: "mongodb"
; loadPages
: (args?
: LoadPagesArgs
<Filter
<PersistedPage
>>) => Promise
<PersistedPage
[]> }
Defined in
packages/mongodb-rag-core/src/MongoDbPageStore.ts:10
Page
Ƭ Page: Object
Represents a page from a data source.
Type declaration
Name | Type | Description |
---|---|---|
body | string | The text of the page. |
format | PageFormat | The file format of the page. This format determines how the page should be chunked and vector-embedded. |
metadata? | PageMetadata | Arbitrary metadata for page. |
sourceName | string | Data source name. |
title? | string | A human-readable title. |
url | string | - |
Defined in
packages/mongodb-rag-core/src/Page.ts:6
PageAction
Ƭ PageAction: "created"
| "updated"
| "deleted"
Defined in
packages/mongodb-rag-core/src/Page.ts:44
PageFormat
Ƭ PageFormat: typeof pageFormats
[number
]
A canonical page format.
Defined in
packages/mongodb-rag-core/src/PageFormat.ts:78
PageMetadata
Ƭ PageMetadata: Object
Index signature
▪ [k: string
]: unknown
Type declaration
Name | Type | Description |
---|---|---|
tags? | string [] | Arbitrary tags. |
Defined in
packages/mongodb-rag-core/src/Page.ts:36
PageStore
Ƭ PageStore: Object
Data store for Page objects.
Type declaration
Name | Type | Description |
---|---|---|
close? | () => Promise <void > | Close connection to data store. |
queryType? | "mongodb" | string | The format that the store uses for custom queries. If not specified, the store does not allow custom queries. |
loadPages | (args? : LoadPagesArgs <unknown >) => Promise <PersistedPage []> | Loads pages from the Page store. |
updatePages | (pages : PersistedPage []) => Promise <void > | Updates or adds the given pages in the store. |
Defined in
packages/mongodb-rag-core/src/Page.ts:89
PersistedPage
Ƭ PersistedPage: Page
& { action
: PageAction
; updated
: Date
}
Represents a Page stored in the database.
Defined in
packages/mongodb-rag-core/src/Page.ts:49
Question
Ƭ Question: z.infer
<typeof Question
>
Defined in
packages/mongodb-rag-core/src/VerifiedAnswer.ts:5
packages/mongodb-rag-core/src/VerifiedAnswer.ts:12
Reference
Ƭ Reference: z.infer
<typeof Reference
>
A formatted reference for an assistant message.
For example, a Reference might be a docs page, dev center article, or a MongoDB University module.
Defined in
packages/mongodb-rag-core/src/services/conversations.ts:9
packages/mongodb-rag-core/src/services/conversations.ts:10
References
Ƭ References: z.infer
<typeof References
>
Defined in
packages/mongodb-rag-core/src/services/conversations.ts:15
packages/mongodb-rag-core/src/services/conversations.ts:16
VectorStore
Ƭ VectorStore<T
>: Object
Generic vector store for vector-searchable data.
Type parameters
Name |
---|
T |
Type declaration
Name | Type |
---|---|
close? | () => Promise <void > |
findNearestNeighbors | (vector : number [], options? : Partial <FindNearestNeighborsOptions >) => Promise <WithScore <T >[]> |
Defined in
packages/mongodb-rag-core/src/VectorStore.ts:4
VerifiedAnswer
Ƭ VerifiedAnswer: z.infer
<typeof VerifiedAnswer
>
Defined in
packages/mongodb-rag-core/src/VerifiedAnswer.ts:14
packages/mongodb-rag-core/src/VerifiedAnswer.ts:25
VerifiedAnswerStore
Ƭ VerifiedAnswerStore: VectorStore
<VerifiedAnswer
>
Defined in
packages/mongodb-rag-core/src/VerifiedAnswer.ts:26
WithScore
Ƭ WithScore<T
>: T
& { score
: number
}
Type parameters
Name |
---|
T |
Defined in
packages/mongodb-rag-core/src/VectorStore.ts:16
Variables
CORE_ENV_VARS
• Const
CORE_ENV_VARS: Object
Type declaration
Name | Type |
---|---|
MONGODB_CONNECTION_URI | string |
MONGODB_DATABASE_NAME | string |
NODE_ENV | string |
OPENAI_API_KEY | string |
OPENAI_CHAT_COMPLETION_DEPLOYMENT | string |
OPENAI_CHAT_COMPLETION_MODEL_VERSION | string |
OPENAI_EMBEDDING_DEPLOYMENT | string |
OPENAI_EMBEDDING_MODEL | string |
OPENAI_EMBEDDING_MODEL_VERSION | string |
OPENAI_ENDPOINT | string |
VECTOR_SEARCH_INDEX_NAME | string |
Defined in
packages/mongodb-rag-core/src/CoreEnvVars.ts:1
Question
• Const
Question: ZodObject
<{ embedding
: ZodArray
<ZodNumber
, "many"
> ; embedding_model
: ZodString
; embedding_model_version
: ZodString
; text
: ZodString
}, "strip"
, ZodTypeAny
, { embedding
: number
[] ; embedding_model
: string
; embedding_model_version
: string
; text
: string
}, { embedding
: number
[] ; embedding_model
: string
; embedding_model_version
: string
; text
: string
}>
Defined in
packages/mongodb-rag-core/src/VerifiedAnswer.ts:5
packages/mongodb-rag-core/src/VerifiedAnswer.ts:12
Reference
• Reference: ZodObject
<{ title
: ZodString
; url
: ZodString
}, "strip"
, ZodTypeAny
, { title
: string
; url
: string
}, { title
: string
; url
: string
}>
Defined in
packages/mongodb-rag-core/src/services/conversations.ts:9
packages/mongodb-rag-core/src/services/conversations.ts:10
References
• References: ZodArray
<ZodObject
<{ title
: ZodString
; url
: ZodString
}, "strip"
, ZodTypeAny
, { title
: string
; url
: string
}, { title
: string
; url
: string
}>, "many"
>
Defined in
packages/mongodb-rag-core/src/services/conversations.ts:15
packages/mongodb-rag-core/src/services/conversations.ts:16
VerifiedAnswer
• Const
VerifiedAnswer: ZodObject
<{ _id
: ZodString
; answer
: ZodString
; author_email
: ZodString
; created
: ZodDate
; hidden
: ZodOptional
<ZodBoolean
> ; question
: ZodObject
<{ embedding
: ZodArray
<ZodNumber
, "many"
> ; embedding_model
: ZodString
; embedding_model_version
: ZodString
; text
: ZodString
}, "strip"
, ZodTypeAny
, { embedding
: number
[] ; embedding_model
: string
; embedding_model_version
: string
; text
: string
}, { embedding
: number
[] ; embedding_model
: string
; embedding_model_version
: string
; text
: string
}> = Question; references
: ZodArray
<ZodObject
<{ title
: ZodString
; url
: ZodString
}, "strip"
, ZodTypeAny
, { title
: string
; url
: string
}, { title
: string
; url
: string
}>, "many"
> ; updated
: ZodOptional
<ZodDate
> }, "strip"
, ZodTypeAny
, { _id
: string
; answer
: string
; author_email
: string
; created
: Date
; hidden?
: boolean
; question
: { text: string; embedding: number[]; embedding_model: string; embedding_model_version: string; } = Question; references
: { url: string; title: string; }[] ; updated?
: Date
}, { _id
: string
; answer
: string
; author_email
: string
; created
: Date
; hidden?
: boolean
; question
: { text: string; embedding: number[]; embedding_model: string; embedding_model_version: string; } = Question; references
: { url: string; title: string; }[] ; updated?
: Date
}>
Defined in
packages/mongodb-rag-core/src/VerifiedAnswer.ts:14
packages/mongodb-rag-core/src/VerifiedAnswer.ts:25
logger
• Const
logger: Logger
Defined in
packages/mongodb-rag-core/src/services/logger.ts:42
pageFormats
• Const
pageFormats: ("txt"
| "md"
| "mdx"
| "restructuredtext"
| "csv"
| "json"
| "yaml"
| "toml"
| "xml"
| "openapi-yaml"
| "openapi-json"
| "graphql"
| "c"
| "cpp"
| "csharp"
| "go"
| "html"
| "java"
| "javascript"
| "kotlin"
| "latex"
| "objective-c"
| "php"
| "python"
| "ruby"
| "rust"
| "scala"
| "shell"
| "swift"
| "typescript"
)[]
The list of canonical file formats that we support for pages.
Defined in
packages/mongodb-rag-core/src/PageFormat.ts:49