Skip to main content

mongodb-chatbot-server

Interfaces

Type Aliases

AddAssistantMessageParams

Ƭ AddAssistantMessageParams: Omit<AssistantMessage, "id" | "createdAt">

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:184


AddConversationMessageParams

Ƭ AddConversationMessageParams: Object

Type declaration

NameType
conversationIdObjectId
messageAddSomeMessageParams

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:195


AddCustomDataFunc

Ƭ AddCustomDataFunc: (request: Request, response: ConversationsRouterResponse) => Promise<ConversationCustomData>

Type declaration

▸ (request, response): Promise<ConversationCustomData>

Function to add custom data to the Conversation persisted to the database. Has access to the Express.js request and response plus the ConversationsRouterLocals from the Response.locals object.

Parameters
NameType
requestRequest
responseConversationsRouterResponse
Returns

Promise<ConversationCustomData>

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:69


AddFunctionMessageParams

Ƭ AddFunctionMessageParams: Omit<FunctionMessage, "id" | "createdAt"> & { customData?: Record<string, unknown> }

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:177


AddManyConversationMessagesParams

Ƭ AddManyConversationMessagesParams: Object

Type declaration

NameType
conversationIdObjectId
messagesAddSomeMessageParams[]

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:200


AddSomeMessageParams

Ƭ AddSomeMessageParams: AddSystemMessageParams | AddUserMessageParams | AddAssistantMessageParams | AddFunctionMessageParams

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:189


AddSystemMessageParams

Ƭ AddSystemMessageParams: Omit<SystemMessage, "id" | "createdAt">

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:171


AddUserMessageParams

Ƭ AddUserMessageParams: Omit<UserMessage, "id" | "createdAt"> & { customData?: Record<string, unknown> }

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:173


AssistantMessage

Ƭ AssistantMessage: MessageBase & { functionCall?: FunctionCall ; metadata?: AssistantMessageMetadata ; rating?: boolean ; references?: any[] ; role: "assistant" ; userComment?: string }

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:37


AssistantMessageMetadata

Ƭ AssistantMessageMetadata: Object

Index signature

▪ [k: string]: unknown

Type declaration

NameTypeDescription
verifiedAnswer?VerifiedAnswerEventDataIf the message came from the verified answers collection, contains the metadata about the verified answer.

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:64


ConversationCustomData

Ƭ ConversationCustomData: Record<string, unknown> | undefined

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:144


ConversationsMiddleware

Ƭ ConversationsMiddleware: RequestHandler<ParamsDictionary, any, any, any, ConversationsRouterLocals>

Middleware to put in front of all the routes in the conversationsRouter. This middleware is useful for things like authentication, data validation, etc. It exposes the app's ConversationsService. It also lets you access ConversationsRouterLocals via Response.locals (docs). You can use the locals in other middleware or persist when you create the conversation with the POST /conversations endpoint with the AddCustomDataFunc.

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:102


ConversationsRouterResponse

Ƭ ConversationsRouterResponse: Response<any, ConversationsRouterLocals>

Express.js Response from the app's ConversationsService.

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:87


CreateConversationParams

Ƭ CreateConversationParams: Object

Type declaration

NameType
customData?ConversationCustomData
initialMessages?SomeMessage[]

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:166


DatabaseConnection

Ƭ DatabaseConnection: Object

Type declaration

NameType
close(force?: boolean) => Promise<void>
drop() => Promise<void>

Defined in

packages/mongodb-rag-core/build/DatabaseConnection.d.ts:1


DeltaStreamEvent

Ƭ DeltaStreamEvent: StreamEvent & { data: string ; type: "delta" }

Event when server streams additional message response to the client.

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:54


EmbedArgs

Ƭ EmbedArgs: Object

Type declaration

NameTypeDescription
textstringThe text to embed.

Defined in

packages/mongodb-rag-core/build/Embedder.d.ts:1


EmbedResult

Ƭ EmbedResult: Object

Type declaration

NameTypeDescription
embeddingnumber[]Vector embedding of the text.

Defined in

packages/mongodb-rag-core/build/Embedder.d.ts:7


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/build/EmbeddedContent.d.ts:53


Embedder

Ƭ Embedder: Object

Takes a string of text and returns an array of numbers representing the vector embedding of the text.

Type declaration

NameType
embed(args: EmbedArgs) => Promise<EmbedResult>

Defined in

packages/mongodb-rag-core/build/Embedder.d.ts:17


FilterPreviousMessages

Ƭ FilterPreviousMessages: (conversation: Conversation) => Promise<Message[]>

Type declaration

▸ (conversation): Promise<Message[]>

Filters which previous conversation messages are sent to the LLM along with the user prompt. For example, you may only want to send the system prompt to the LLM with the user message or the system prompt and X prior messages.

Parameters
NameType
conversationConversation
Returns

Promise<Message[]>

Defined in

packages/mongodb-chatbot-server/src/processors/FilterPreviousMessages.ts:9


FindContentFunc

Ƭ FindContentFunc: (args: FindContentFuncArgs) => Promise<FindContentResult>

Type declaration

▸ (args): Promise<FindContentResult>

Parameters
NameType
argsFindContentFuncArgs
Returns

Promise<FindContentResult>

Defined in

packages/mongodb-chatbot-server/src/processors/FindContentFunc.ts:7


FindContentFuncArgs

Ƭ FindContentFuncArgs: Object

Type declaration

NameType
querystring

Defined in

packages/mongodb-chatbot-server/src/processors/FindContentFunc.ts:3


FindContentResult

Ƭ FindContentResult: Object

Type declaration

NameType
contentWithScore<EmbeddedContent>[]
queryEmbeddingnumber[]

Defined in

packages/mongodb-chatbot-server/src/processors/FindContentFunc.ts:11


FindNearestNeighborsOptions

Ƭ FindNearestNeighborsOptions: Object

Options for performing a nearest-neighbor search.

Type declaration

NameTypeDescription
filterRecord<string, unknown>Search filter expression.
indexNamestringThe name of the index to use.
knumberThe number of nearest neighbors to return.
minScorenumberThe minimum nearest-neighbor score threshold between 0-1.
numCandidatesnumberNumber 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).
pathstringThe keypath to the field with the vector data to use.

Defined in

packages/mongodb-rag-core/build/VectorStore.d.ts:17


FindVerifiedAnswerFunc

Ƭ FindVerifiedAnswerFunc: (args: FindVerifiedAnswerFuncArgs) => Promise<FindVerifiedAnswerResult>

Type declaration

▸ (args): Promise<FindVerifiedAnswerResult>

Parameters
NameType
argsFindVerifiedAnswerFuncArgs
Returns

Promise<FindVerifiedAnswerResult>

Defined in

packages/mongodb-chatbot-server/src/processors/FindVerifiedAnswerFunc.ts:7


FindVerifiedAnswerFuncArgs

Ƭ FindVerifiedAnswerFuncArgs: Object

Type declaration

NameType
querystring

Defined in

packages/mongodb-chatbot-server/src/processors/FindVerifiedAnswerFunc.ts:3


FindVerifiedAnswerResult

Ƭ FindVerifiedAnswerResult: Object

Type declaration

NameType
answer?WithScore<VerifiedAnswer>
queryEmbeddingnumber[]

Defined in

packages/mongodb-chatbot-server/src/processors/FindVerifiedAnswerFunc.ts:11


FinishedStreamEvent

Ƭ FinishedStreamEvent: StreamEvent & { data: string ; type: "finished" }

Event denoting the end of streaming.

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:87


FunctionMessage

Ƭ FunctionMessage: MessageBase & { name: string ; role: "function" }

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:79


GenerateUserPromptFunc

Ƭ GenerateUserPromptFunc: (params: GenerateUserPromptFuncParams) => Promise<GenerateUserPromptFuncReturnValue>

Type declaration

▸ (params): Promise<GenerateUserPromptFuncReturnValue>

Generate the user prompt sent to the ChatLlm. This function is a flexible construct that you can use to customize the chatbot behavior. For example, you can use this function to perform retrieval augmented generation (RAG) or chain of thought prompting. Include whatever logic in here to construct the user message that the LLM responds to.

If you are doing RAG, this can include the content from vector search.

Parameters
NameType
paramsGenerateUserPromptFuncParams
Returns

Promise<GenerateUserPromptFuncReturnValue>

Defined in

packages/mongodb-chatbot-server/src/processors/GenerateUserPromptFunc.ts:66


GenerateUserPromptFuncParams

Ƭ GenerateUserPromptFuncParams: Object

Type declaration

NameTypeDescription
conversation?ConversationConversation with preceding messages
customData?ConversationCustomDataCustom data for the message request.
reqIdstringString Id for request
userMessageTextstringOriginal user message

Defined in

packages/mongodb-chatbot-server/src/processors/GenerateUserPromptFunc.ts:9


LoadPagesArgs

Ƭ LoadPagesArgs<QueryShape>: Object

Type parameters

NameType
QueryShapeunknown

Type declaration

NameTypeDescription
query?QueryShapeA 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?DateIf 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/build/Page.d.ts:50


MakeDefaultFindContentFuncArgs

Ƭ MakeDefaultFindContentFuncArgs: Object

Type declaration

NameType
embedderEmbedder
findNearestNeighborsOptions?Partial<FindNearestNeighborsOptions>
searchBoosters?SearchBooster[]
storeEmbeddedContentStore

Defined in

packages/mongodb-chatbot-server/src/processors/makeDefaultFindContent.ts:9


MakeDefaultFindVerifiedAnswerFuncArgs

Ƭ MakeDefaultFindVerifiedAnswerFuncArgs: Object

Type declaration

NameType
embedderEmbedder
findNearestNeighborsOptions?Partial<FindNearestNeighborsOptions>
storeVerifiedAnswerStore

Defined in

packages/mongodb-chatbot-server/src/processors/makeDefaultFindVerifiedAnswer.ts:8


MakeLangChainEmbedderParams

Ƭ MakeLangChainEmbedderParams: Object

Type declaration

NameTypeDescription
langChainEmbeddingsEmbeddingsLangChain.js Embeddings instance. You can configure things like caching and retry behavior in the Embeddings instance.

Defined in

packages/mongodb-rag-core/build/LangChainEmbedder.d.ts:3


MakeOpenAiEmbedderArgs

Ƭ MakeOpenAiEmbedderArgs: Object

Type declaration

NameTypeDescription
backoffOptions?BackoffOptionsOptions used for automatic retry (usually due to rate limiting).
deploymentstringThe deployment key.
openAiClientOpenAIClientThe OpenAI client.

Defined in

packages/mongodb-rag-core/build/OpenAiEmbedder.d.ts:4


MakeReferenceLinksFunc

Ƭ MakeReferenceLinksFunc: (chunks: EmbeddedContent[]) => any[]

Type declaration

▸ (chunks): any[]

Function that generates the references in the response to user.

Parameters
NameType
chunksEmbeddedContent[]
Returns

any[]

Defined in

packages/mongodb-chatbot-server/src/processors/MakeReferenceLinksFunc.ts:6


MakeTypeChatJsonTranslateFuncArgs

Ƭ MakeTypeChatJsonTranslateFuncArgs: Object

Type declaration

NameTypeDescription
azureOpenAiServiceConfigAzureOpenAiServiceConfigSettings for using the Azure service.
numRetries?numberNumber of times to retry the query preprocessor if it fails.
retryDelayMs?numberDelay between retries in milliseconds.
schemastringThe text of a .d.ts that would inform the schema.
schemaNamestringThe name of the TypeChat schema or interface.

Defined in

packages/mongodb-rag-core/build/TypeChatJsonTranslateFunc.d.ts:7


MakeUserMessageFunc

Ƭ MakeUserMessageFunc: (params: MakeUserMessageFuncParams) => Promise<UserMessage>

Type declaration

▸ (params): Promise<UserMessage>

Parameters
NameType
paramsMakeUserMessageFuncParams
Returns

Promise<UserMessage>

Defined in

packages/mongodb-chatbot-server/src/processors/makeRagGenerateUserPrompt.ts:48


Message

Ƭ Message: SomeMessage & { createdAt: Date ; id: ObjectId }

Message stored in the database.

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:132


MessageBase

Ƭ MessageBase: Object

Type declaration

NameTypeDescription
contentstringMessage that occurs in the conversation.
customData?Record<string, unknown>Custom data received from the client to include in the Message persisted to the database.
metadata?Record<string, unknown>Arbitrary data about the message that should be sent to the client.
rolestringThe role of the message in the conversation.

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:10


MetadataStreamEvent

Ƭ MetadataStreamEvent: StreamEvent & { data: Record<string, unknown> ; type: "metadata" }

Event when server streams a metadata object to the client.

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:79


MongoDbPageStore

Ƭ MongoDbPageStore: DatabaseConnection & Omit<PageStore, "loadPages"> & { queryType: "mongodb" ; loadPages: (args?: LoadPagesArgs<Filter<PersistedPage>>) => Promise<PersistedPage[]> }

Defined in

packages/mongodb-rag-core/build/MongoDbPageStore.d.ts:5


OpenAIChatCompletionWithoutUsage

Ƭ OpenAIChatCompletionWithoutUsage: Omit<ChatCompletions, "usage">

Defined in

packages/mongodb-chatbot-server/src/services/ChatLlm.ts:85


OpenAiAwaitedResponse

Ƭ OpenAiAwaitedResponse: ChatRequestAssistantMessage

Defined in

packages/mongodb-chatbot-server/src/services/ChatLlm.ts:89


OpenAiChatMessage

Ƭ OpenAiChatMessage: ChatRequestMessage & { content: string | null ; embedding?: number[] ; role: OpenAiMessageRole }

Defined in

packages/mongodb-chatbot-server/src/services/ChatLlm.ts:21


OpenAiMessageRole

Ƭ OpenAiMessageRole: "system" | "assistant" | "user" | "function"

Defined in

packages/mongodb-chatbot-server/src/services/ChatLlm.ts:19


OpenAiStreamingResponse

Ƭ OpenAiStreamingResponse: AsyncIterable<OpenAIChatCompletionWithoutUsage>

Defined in

packages/mongodb-chatbot-server/src/services/ChatLlm.ts:87


Page

Ƭ Page: Object

Represents a page from a data source.

Type declaration

NameTypeDescription
bodystringThe text of the page.
formatPageFormatThe file format of the page. This format determines how the page should be chunked and vector-embedded.
metadata?PageMetadataArbitrary metadata for page.
sourceNamestringData source name.
title?stringA human-readable title.
urlstring-

Defined in

packages/mongodb-rag-core/build/Page.d.ts:5


PageAction

Ƭ PageAction: "created" | "updated" | "deleted"

Defined in

packages/mongodb-rag-core/build/Page.d.ts:36


PageFormat

Ƭ PageFormat: typeof pageFormats[number]

A canonical page format.

Defined in

packages/mongodb-rag-core/build/PageFormat.d.ts:15


PageMetadata

Ƭ PageMetadata: Object

Index signature

▪ [k: string]: unknown

Type declaration

NameTypeDescription
tags?string[]Arbitrary tags.

Defined in

packages/mongodb-rag-core/build/Page.d.ts:29


PageStore

Ƭ PageStore: Object

Data store for Page objects.

Type declaration

NameTypeDescription
close?() => Promise<void>Close connection to data store.
queryType?"mongodb" | stringThe 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/build/Page.d.ts:74


PersistedPage

Ƭ PersistedPage: Page & { action: PageAction ; updated: Date }

Represents a Page stored in the database.

Defined in

packages/mongodb-rag-core/build/Page.d.ts:40


ProcessingStreamEvent

Ƭ ProcessingStreamEvent: StreamEvent & { data: string ; type: "processing" }

Event for when the server is processing a request.

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:59


QueryPreprocessorFunc

Ƭ QueryPreprocessorFunc<ReturnType>: (params: QueryProcessorFuncParams) => Promise<ReturnType>

Type parameters

NameType
ReturnTypeextends QueryPreprocessorResult = QueryPreprocessorResult

Type declaration

▸ (params): Promise<ReturnType>

Query preprocessors transform an input query to a new query based on your business logic.

If the preprocessor can't transform the query, it may return undefined. The preprocessor may also suggest not answering with the rejectQuery field in the return value (for example, if the query disparages your company, you might want to send a canned response).

Parameters
NameType
paramsQueryProcessorFuncParams
Returns

Promise<ReturnType>

Defined in

packages/mongodb-chatbot-server/src/processors/QueryPreprocessorFunc.ts:17


QueryPreprocessorResult

Ƭ QueryPreprocessorResult: Object

Type declaration

NameType
query?string
rejectQuery?boolean

Defined in

packages/mongodb-chatbot-server/src/processors/QueryPreprocessorFunc.ts:21


QueryProcessorFuncParams

Ƭ QueryProcessorFuncParams: Object

Type declaration

NameType
messages?Message[]
querystring

Defined in

packages/mongodb-chatbot-server/src/processors/QueryPreprocessorFunc.ts:3


Question

Ƭ Question: z.infer<typeof Question>

Defined in

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:3

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:19


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/build/services/conversations.d.ts:8

packages/mongodb-rag-core/build/services/conversations.d.ts:9


References

Ƭ References: z.infer<typeof References>

Defined in

packages/mongodb-rag-core/build/services/conversations.d.ts:19

packages/mongodb-rag-core/build/services/conversations.d.ts:20


ReferencesStreamEvent

Ƭ ReferencesStreamEvent: StreamEvent & { data: any[] ; type: "references" }

Event when server streams single References object to the client.

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:71


SomeMessage

Ƭ SomeMessage: UserMessage | AssistantMessage | SystemMessage | FunctionMessage

Message in the Conversation.

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:123


SomeStreamEvent

Ƭ SomeStreamEvent: DeltaStreamEvent | MetadataStreamEvent | ProcessingStreamEvent | ReferencesStreamEvent | FinishedStreamEvent

The event types streamed from the chat server to the client.

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:95


SystemMessage

Ƭ SystemMessage: MessageBase & { role: "system" }

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:33


SystemPrompt

Ƭ SystemPrompt: OpenAiChatMessage & { content: string ; role: "system" }

Defined in

packages/mongodb-chatbot-server/src/services/ChatLlm.ts:34


ToolCallDirective

Ƭ ToolCallDirective: FunctionCallPreset | FunctionName

Defined in

packages/mongodb-chatbot-server/src/services/ChatLlm.ts:110


UserMessage

Ƭ UserMessage: MessageBase & { contentForLlm?: string ; contextContent?: Partial<WithScore<EmbeddedContent>>[] ; embedding?: number[] ; preprocessedContent?: string ; rejectQuery?: boolean ; role: "user" }

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:84


VectorStore

Ƭ VectorStore<T>: Object

Generic vector store for vector-searchable data.

Type parameters

Name
T

Type declaration

NameType
close?() => Promise<void>
findNearestNeighbors(vector: number[], options?: Partial<FindNearestNeighborsOptions>) => Promise<WithScore<T>[]>

Defined in

packages/mongodb-rag-core/build/VectorStore.d.ts:4


VerifiedAnswer

Ƭ VerifiedAnswer: z.infer<typeof VerifiedAnswer>

Defined in

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:20

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:88


VerifiedAnswerEventData

Ƭ VerifiedAnswerEventData: Pick<VerifiedAnswer, "_id" | "created" | "updated">

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:74


VerifiedAnswerStore

Ƭ VerifiedAnswerStore: VectorStore<VerifiedAnswer>

Defined in

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:89


WithFilterAndK

Ƭ WithFilterAndK<T>: T & { filter: Record<string, unknown> ; k: number }

Type parameters

Name
T

Defined in

packages/mongodb-chatbot-server/src/processors/makeBoostOnAtlasSearchFilter.ts:9


WithScore

Ƭ WithScore<T>: T & { score: number }

Type parameters

Name
T

Defined in

packages/mongodb-rag-core/build/VectorStore.d.ts:11

Variables

CORE_ENV_VARS

Const CORE_ENV_VARS: Object

Type declaration

NameType
MONGODB_CONNECTION_URIstring
MONGODB_DATABASE_NAMEstring
NODE_ENVstring
OPENAI_API_KEYstring
OPENAI_CHAT_COMPLETION_DEPLOYMENTstring
OPENAI_CHAT_COMPLETION_MODEL_VERSIONstring
OPENAI_EMBEDDING_DEPLOYMENTstring
OPENAI_EMBEDDING_MODELstring
OPENAI_EMBEDDING_MODEL_VERSIONstring
OPENAI_ENDPOINTstring
VECTOR_SEARCH_INDEX_NAMEstring

Defined in

packages/mongodb-rag-core/build/CoreEnvVars.d.ts:1


CUSTOM_REQUEST_ORIGIN_HEADER

Const CUSTOM_REQUEST_ORIGIN_HEADER: "X-Request-Origin"

Defined in

packages/mongodb-chatbot-server/src/middleware/requireRequestOrigin.ts:4


DEFAULT_API_PREFIX

Const DEFAULT_API_PREFIX: "/api/v1"

Defined in

packages/mongodb-chatbot-server/src/app.ts:108


DEFAULT_MAX_REQUEST_TIMEOUT_MS

Const DEFAULT_MAX_REQUEST_TIMEOUT_MS: 60000

Defined in

packages/mongodb-chatbot-server/src/app.ts:110


Question

Const Question: z.ZodObject<{ embedding: z.ZodArray<z.ZodNumber, "many"> ; embedding_model: z.ZodString ; embedding_model_version: z.ZodString ; text: z.ZodString }, "strip", z.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/build/VerifiedAnswer.d.ts:3

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:19


Reference

Reference: ZodObject<{ title: ZodString ; url: ZodString }, "strip", ZodTypeAny, { title: string ; url: string }, { title: string ; url: string }>

Defined in

packages/mongodb-rag-core/build/services/conversations.d.ts:8

packages/mongodb-rag-core/build/services/conversations.d.ts:9


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/build/services/conversations.d.ts:19

packages/mongodb-rag-core/build/services/conversations.d.ts:20


SomeExpressRequest

Const SomeExpressRequest: ZodObject<{ body: ZodOptional<ZodObject<, "strip", ZodTypeAny, , >> ; headers: ZodOptional<ZodObject<, "strip", ZodTypeAny, , >> ; params: ZodOptional<ZodObject<, "strip", ZodTypeAny, , >> ; query: ZodOptional<ZodObject<, "strip", ZodTypeAny, , >> }, "strip", ZodTypeAny, { body?: {} ; headers?: {} ; params?: {} ; query?: {} }, { body?: {} ; headers?: {} ; params?: {} ; query?: {} }>

Defined in

packages/mongodb-chatbot-server/src/middleware/validateRequestSchema.ts:6


VerifiedAnswer

Const VerifiedAnswer: z.ZodObject<{ _id: z.ZodString ; answer: z.ZodString ; author_email: z.ZodString ; created: z.ZodDate ; hidden: z.ZodOptional<z.ZodBoolean> ; question: z.ZodObject<{ embedding: z.ZodArray<z.ZodNumber, "many"> ; embedding_model: z.ZodString ; embedding_model_version: z.ZodString ; text: z.ZodString }, "strip", z.ZodTypeAny, { embedding: number[] ; embedding_model: string ; embedding_model_version: string ; text: string }, { embedding: number[] ; embedding_model: string ; embedding_model_version: string ; text: string }> ; references: z.ZodArray<z.ZodObject<{ title: z.ZodString ; url: z.ZodString }, "strip", z.ZodTypeAny, { title: string ; url: string }, { title: string ; url: string }>, "many"> ; updated: z.ZodOptional<z.ZodDate> }, "strip", z.ZodTypeAny, { _id: string ; answer: string ; author_email: string ; created: Date ; hidden?: boolean ; question: { embedding: number[] ; embedding_model: string ; embedding_model_version: string ; text: string } ; references: { title: string ; url: string }[] ; updated?: Date }, { _id: string ; answer: string ; author_email: string ; created: Date ; hidden?: boolean ; question: { embedding: number[] ; embedding_model: string ; embedding_model_version: string ; text: string } ; references: { title: string ; url: string }[] ; updated?: Date }>

Defined in

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:20

packages/mongodb-rag-core/build/VerifiedAnswer.d.ts:88


defaultConversationConstants

Const defaultConversationConstants: ConversationConstants

Defined in

packages/mongodb-chatbot-server/src/services/ConversationsService.ts:277


logger

Const logger: Logger

Defined in

packages/mongodb-rag-core/build/services/logger.d.ts:13


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/build/PageFormat.d.ts:4


rateLimitResponse

Const rateLimitResponse: Object

Type declaration

NameType
errorstring

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:194

Functions

asPageFormat

asPageFormat(str): undefined | "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"

Maps a string to the canonical page format it represents.

Parameters

NameType
strstring

Returns

undefined | "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 canonical page format, or undefined if the string is not a recognized page format.

Defined in

packages/mongodb-rag-core/build/PageFormat.d.ts:11


assertEnvVars

assertEnvVars<T>(ENV_VARS): T

Type parameters

NameType
Textends Record<string, string>

Parameters

NameType
ENV_VARST

Returns

T

Defined in

packages/mongodb-rag-core/build/assertEnvVars.d.ts:1


createLoggerMessage

createLoggerMessage(«destructured»): Object

Parameters

NameType
«destructured»CreateMessageParams

Returns

Object

NameType
ipAddressundefined | string
messagestring
requestBodyunknown
requestIdundefined | string

Defined in

packages/mongodb-rag-core/build/services/logger.d.ts:7


createMessage

createMessage(messageParams): { content: string ; createdAt: Date ; customData?: Record<string, unknown> ; id: ObjectId ; metadata?: Record<string, unknown> ; role: "system" } | { content: string ; contentForLlm?: string ; contextContent?: Partial<WithScore<EmbeddedContent>>[] ; createdAt: Date ; customData?: Record<string, unknown> ; embedding?: number[] ; id: ObjectId ; metadata?: Record<string, unknown> ; preprocessedContent?: string ; rejectQuery?: boolean ; role: "user" } | { content: string ; createdAt: Date ; customData?: Record<string, unknown> ; id: ObjectId ; metadata?: Record<string, unknown> ; name: string ; role: "function" } | { content: string ; createdAt: Date ; customData?: Record<string, unknown> ; functionCall?: FunctionCall ; id: ObjectId ; metadata?: Record<string, unknown> & AssistantMessageMetadata ; rating?: boolean ; references?: { title: string ; url: string }[] ; role: "assistant" ; userComment?: string }

Parameters

NameType
messageParamsAddSomeMessageParams

Returns

{ content: string ; createdAt: Date ; customData?: Record<string, unknown> ; id: ObjectId ; metadata?: Record<string, unknown> ; role: "system" } | { content: string ; contentForLlm?: string ; contextContent?: Partial<WithScore<EmbeddedContent>>[] ; createdAt: Date ; customData?: Record<string, unknown> ; embedding?: number[] ; id: ObjectId ; metadata?: Record<string, unknown> ; preprocessedContent?: string ; rejectQuery?: boolean ; role: "user" } | { content: string ; createdAt: Date ; customData?: Record<string, unknown> ; id: ObjectId ; metadata?: Record<string, unknown> ; name: string ; role: "function" } | { content: string ; createdAt: Date ; customData?: Record<string, unknown> ; functionCall?: FunctionCall ; id: ObjectId ; metadata?: Record<string, unknown> & AssistantMessageMetadata ; rating?: boolean ; references?: { title: string ; url: string }[] ; role: "assistant" ; userComment?: string }

Defined in

packages/mongodb-chatbot-server/src/services/mongodbConversations.ts:165


createMessageFromOpenAIChatMessage

createMessageFromOpenAIChatMessage(chatMessage): Message

Create a Message object from the OpenAiChatMessage object.

Parameters

NameType
chatMessageAddSomeMessageParams

Returns

Message

Defined in

packages/mongodb-chatbot-server/src/services/mongodbConversations.ts:183


errorHandler

errorHandler(err, req, res, next): void

General error handler. Called at usage of next() in routes.

Parameters

NameType
errany
reqRequest<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
resResponse<any, Record<string, any>, number>
nextNextFunction

Returns

void

Defined in

node_modules/@types/express-serve-static-core/index.d.ts:73


escapeNewlines

escapeNewlines(str): string

Parameters

NameType
strstring

Returns

string

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:5


extractFrontMatter

extractFrontMatter<T>(text, language?, delimiter?): Object

This function extracts frontmatter from a string. The generic type does not validate that the frontmatter conforms to the type. It just provides the type for developer convenience.

Type parameters

NameType
Textends Record<string, unknown>

Parameters

NameType
textstring
language?string
delimiter?string

Returns

Object

NameType
bodystring
metadata?T

Defined in

packages/mongodb-rag-core/build/extractFrontMatter.d.ts:7


filterDefined

filterDefined<T>(array): Exclude<T, undefined>[]

Given an array of possibly undefined T, return those that are defined.

Type parameters

Name
T

Parameters

NameType
arrayT[]

Returns

Exclude<T, undefined>[]

Defined in

packages/mongodb-rag-core/build/arrayFilters.d.ts:8


filterFulfilled

filterFulfilled<T>(array): PromiseFulfilledResult<T>[]

Given an array of PromiseSettledResults, return those that are fulfilled as PromiseFulfilledResults.

Type parameters

Name
T

Parameters

NameType
arrayPromiseSettledResult<T>[]

Returns

PromiseFulfilledResult<T>[]

Defined in

packages/mongodb-rag-core/build/arrayFilters.d.ts:4


filterOnlySystemPrompt

filterOnlySystemPrompt(conversation): Promise<Message[]>

Only include the initial system prompt.

Parameters

NameType
conversationConversation<ConversationCustomData>

Returns

Promise<Message[]>

Defined in

packages/mongodb-chatbot-server/src/processors/FilterPreviousMessages.ts:9


includeChunksForMaxTokensPossible

includeChunksForMaxTokensPossible(«destructured»): EmbeddedContent[]

This function returns the chunks that can fit in the maxTokens. It limits the number of tokens that are sent to the LLM.

Parameters

NameType
«destructured»Object
› contentEmbeddedContent[]
› maxTokensnumber

Returns

EmbeddedContent[]

Defined in

packages/mongodb-chatbot-server/src/processors/makeRagGenerateUserPrompt.ts:202


isPageFormat

isPageFormat(str): str is "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"

Type guard to check if a string is a canonical page format.

Parameters

NameType
strstring

Returns

str is "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"

Defined in

packages/mongodb-rag-core/build/PageFormat.d.ts:19


makeApp

makeApp(config): Promise<Express>

Constructor function to make the Express.js app.

Parameters

NameType
configAppConfig

Returns

Promise<Express>

Defined in

packages/mongodb-chatbot-server/src/app.ts:115


makeBoostOnAtlasSearchFilter

makeBoostOnAtlasSearchFilter(«destructured»): SearchBooster

Boost certain results in search results from Atlas Search.

Parameters

NameType
«destructured»MakeBoostOnAtlasSearchFilterArgs

Returns

SearchBooster

Defined in

packages/mongodb-chatbot-server/src/processors/makeBoostOnAtlasSearchFilter.ts:37


makeConversationsRouter

makeConversationsRouter(«destructured»): Router

Constructor function to make the /conversations/* Express.js router.

Parameters

NameType
«destructured»ConversationsRouterParams

Returns

Router

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:217


makeDataStreamer

makeDataStreamer(): DataStreamer

Create a DataStreamer that streams data to the client.

Returns

DataStreamer

Defined in

packages/mongodb-chatbot-server/src/services/dataStreamer.ts:116


makeDefaultFindContent

makeDefaultFindContent(«destructured»): FindContentFunc

Basic implementation of FindContentFunc with search boosters.

Parameters

NameType
«destructured»MakeDefaultFindContentFuncArgs

Returns

FindContentFunc

Defined in

packages/mongodb-chatbot-server/src/processors/makeDefaultFindContent.ts:19


makeDefaultFindVerifiedAnswer

makeDefaultFindVerifiedAnswer(«destructured»): FindVerifiedAnswerFunc

Basic implementation of FindVerifiedAnswerFunc.

Parameters

NameType
«destructured»MakeDefaultFindVerifiedAnswerFuncArgs

Returns

FindVerifiedAnswerFunc

Defined in

packages/mongodb-chatbot-server/src/processors/makeDefaultFindVerifiedAnswer.ts:17


makeDefaultReferenceLinks(chunks): { title: string ; url: string }[]

The default reference format returns the following for chunks from unique pages:

{
title: chunk.metadata.pageTitle ?? chunk.url, // if title doesn't exist, just put url
url: chunk.url // this always exists
}

Parameters

NameType
chunksEmbeddedContent[]

Returns

{ title: string ; url: string }[]

Defined in

packages/mongodb-chatbot-server/src/processors/MakeReferenceLinksFunc.ts:6


makeFilterNPreviousMessages

makeFilterNPreviousMessages(n): FilterPreviousMessages

Creates a filter that only includes the previous n messages in the conversations. The first message in the conversation must be the system prompt.

Parameters

NameTypeDescription
nnumberNumber of previous messages to include.

Returns

FilterPreviousMessages

Defined in

packages/mongodb-chatbot-server/src/processors/makeFilterNPreviousMessages.ts:8


makeHandleTimeoutMiddleware

makeHandleTimeoutMiddleware(apiTimeout): (req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction) => void

Parameters

NameType
apiTimeoutnumber

Returns

fn

▸ (req, res, next): void

Parameters
NameType
reqRequest<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
resResponse<any, Record<string, any>>
nextNextFunction
Returns

void

Defined in

packages/mongodb-chatbot-server/src/app.ts:93


makeLangChainEmbedder

makeLangChainEmbedder(«destructured»): Embedder

Constructor for implementation of the Embedder using a LangChain.js Embeddings class.

Parameters

NameType
«destructured»MakeLangChainEmbedderParams

Returns

Embedder

Defined in

packages/mongodb-rag-core/build/LangChainEmbedder.d.ts:13


makeLangchainChatLlm

makeLangchainChatLlm(«destructured»): ChatLlm

Use any Langchain JS ChatModel to talk to an LLM.

Note: This ChatLLM does not currently support tool calling.

Parameters

NameType
«destructured»MakeLangchainChatLlmProps

Returns

ChatLlm

Defined in

packages/mongodb-chatbot-server/src/services/LangchainChatLlm.ts:23


makeMongoDbConversationsService

makeMongoDbConversationsService(database, conversationConstants?): ConversationsService

Create ConversationsService that uses MongoDB as a data store.

Parameters

NameTypeDefault value
databaseDbundefined
conversationConstantsConversationConstantsdefaultConversationConstants

Returns

ConversationsService

Defined in

packages/mongodb-chatbot-server/src/services/mongodbConversations.ts:24


makeMongoDbEmbeddedContentStore

makeMongoDbEmbeddedContentStore(«destructured»): EmbeddedContentStore & DatabaseConnection

Parameters

NameType
«destructured»MakeMongoDbDatabaseConnectionParams

Returns

EmbeddedContentStore & DatabaseConnection

Defined in

packages/mongodb-rag-core/build/MongoDbEmbeddedContentStore.d.ts:4


makeMongoDbPageStore

makeMongoDbPageStore(«destructured»): MongoDbPageStore

Data store for Page objects using MongoDB.

Parameters

NameType
«destructured»MakeMongoDbDatabaseConnectionParams

Returns

MongoDbPageStore

Defined in

packages/mongodb-rag-core/build/MongoDbPageStore.d.ts:12


makeMongoDbVerifiedAnswerStore

makeMongoDbVerifiedAnswerStore(«destructured»): VerifiedAnswerStore & DatabaseConnection

Parameters

NameType
«destructured»MakeMongoDbDatabaseConnectionParams & { collectionName: string }

Returns

VerifiedAnswerStore & DatabaseConnection

Defined in

packages/mongodb-rag-core/build/MongoDbVerifiedAnswerStore.d.ts:4


makeOpenAiChatLlm

makeOpenAiChatLlm(«destructured»): Required<ChatLlm>

Construct the ChatLlm service using the OpenAI ChatGPT API. The ChatLlm wraps the @azure/openai package.

Parameters

NameType
«destructured»MakeOpenAiChatLlmParams

Returns

Required<ChatLlm>

Defined in

packages/mongodb-chatbot-server/src/services/openAiChatLlm.ts:24


makeOpenAiEmbedder

makeOpenAiEmbedder(«destructured»): Embedder

Constructor for implementation of the Embedder using OpenAI Embeddings API.

Parameters

NameType
«destructured»MakeOpenAiEmbedderArgs

Returns

Embedder

Defined in

packages/mongodb-rag-core/build/OpenAiEmbedder.d.ts:22


makeRagGenerateUserPrompt

makeRagGenerateUserPrompt(«destructured»): GenerateUserPromptFunc

Construct a GenerateUserPromptFunc function that uses retrieval augmented generation (RAG) to generate the user prompt and return references to use in the answer. The returned RAG user prompt generator performs the following steps:

  1. Preprocess the user's message using the query preprocessor.
  2. Find content using vector search.
  3. Removes any chunks that would exceed the max context tokens.
  4. Generate the user message using the make user message function.
  5. Return the user message and references.

Parameters

NameType
«destructured»MakeRagGenerateUserPromptParams

Returns

GenerateUserPromptFunc

Defined in

packages/mongodb-chatbot-server/src/processors/makeRagGenerateUserPrompt.ts:64


makeStaticSite

makeStaticSite(app): Express

Middleware that serves the static site from the root path (GET https://my-site.com/).

Parameters

NameType
appExpress

Returns

Express

Defined in

packages/mongodb-chatbot-server/src/routes/staticSite.ts:8


makeTypeChatJsonTranslateFunc

makeTypeChatJsonTranslateFunc<SchemaType>(«destructured»): (prompt: string) => Promise<SchemaType>

Type parameters

NameType
SchemaTypeextends object

Parameters

NameType
«destructured»MakeTypeChatJsonTranslateFuncArgs

Returns

fn

▸ (prompt): Promise<SchemaType>

Parameters
NameType
promptstring
Returns

Promise<SchemaType>

Defined in

packages/mongodb-rag-core/build/TypeChatJsonTranslateFunc.d.ts:29


makeVerifiedAnswerGenerateUserPrompt

makeVerifiedAnswerGenerateUserPrompt(«destructured»): GenerateUserPromptFunc

Constructs a GenerateUserPromptFunc that searches for verified answers for the user query. If no verified answer can be found for the given query, the onNoVerifiedAnswerFound GenerateUserPromptFunc is called instead.

Parameters

NameType
«destructured»MakeVerifiedAnswerGenerateUserPromptParams

Returns

GenerateUserPromptFunc

Defined in

packages/mongodb-chatbot-server/src/processors/makeVerifiedAnswerGenerateUserPrompt.ts:21


pageFormat

pageFormat(str, defaultPageFormat?): PageFormat

Converts a string to a canonical page format. If the string is not a recognized page format or a synonym for one, this returns a default page format.

Parameters

NameType
strstring
defaultPageFormat?"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"

Returns

PageFormat

Defined in

packages/mongodb-rag-core/build/PageFormat.d.ts:25


removeFrontMatter

removeFrontMatter(content, options?): string

Parameters

NameType
contentstring
options?FrontMatterOptions

Returns

string

Defined in

packages/mongodb-rag-core/build/removeFrontMatter.d.ts:2


reqHandler

reqHandler(req, res, next): void

Parameters

NameType
reqRequest<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
resResponse<any, Record<string, any>, number>
nextNextFunction

Returns

void

Defined in

node_modules/@types/express-serve-static-core/index.d.ts:60


requireRequestOrigin

requireRequestOrigin(): ConversationsMiddleware

Returns

ConversationsMiddleware

Defined in

packages/mongodb-chatbot-server/src/middleware/requireRequestOrigin.ts:6


requireValidIpAddress

requireValidIpAddress(): ConversationsMiddleware

Returns

ConversationsMiddleware

Defined in

packages/mongodb-chatbot-server/src/middleware/requireValidIpAddress.ts:5


updateFrontMatter

updateFrontMatter(text, metadataIn): string

Parameters

NameType
textstring
metadataInRecord<string, unknown>

Returns

string

Defined in

packages/mongodb-rag-core/build/updateFrontMatter.d.ts:1