Skip to main content

mongodb-chatbot-server

Namespaces

Interfaces

References

AddAssistantMessageParams

Re-exports AddAssistantMessageParams


AddConversationMessageParams

Re-exports AddConversationMessageParams


AddFunctionMessageParams

Re-exports AddFunctionMessageParams


AddManyConversationMessagesParams

Re-exports AddManyConversationMessagesParams


AddMessageParams

Re-exports AddMessageParams


AddSomeMessageParams

Re-exports AddSomeMessageParams


AddSystemMessageParams

Re-exports AddSystemMessageParams


AddUserMessageParams

Re-exports AddUserMessageParams


AssistantMessage

Re-exports AssistantMessage


AssistantMessageMetadata

Re-exports AssistantMessageMetadata


CallToolResponse

Re-exports CallToolResponse


ChatLlm

Re-exports ChatLlm


ChunkFunc

Re-exports ChunkFunc


ChunkMetadataGetter

Re-exports ChunkMetadataGetter


ChunkOptions

Re-exports ChunkOptions


ChunkTransformer

Re-exports ChunkTransformer


CommentMessageParams

Re-exports CommentMessageParams


ContentChunk

Re-exports ContentChunk


Conversation

Re-exports Conversation


ConversationConstants

Re-exports ConversationConstants


ConversationCustomData

Re-exports ConversationCustomData


ConversationsService

Re-exports ConversationsService


CreateConversationParams

Re-exports CreateConversationParams


DbMessage

Re-exports DbMessage


DeleteEmbeddedContentArgs

Re-exports DeleteEmbeddedContentArgs


DeletePagesArgs

Re-exports DeletePagesArgs


EmbedArgs

Re-exports EmbedArgs


EmbedConcurrencyOptions

Re-exports EmbedConcurrencyOptions


EmbedResult

Re-exports EmbedResult


EmbeddedContent

Re-exports EmbeddedContent


EmbeddedContentStore

Re-exports EmbeddedContentStore


Embedder

Re-exports Embedder


FindByIdParams

Re-exports FindByIdParams


FindContentFunc

Re-exports FindContentFunc


FindContentFuncArgs

Re-exports FindContentFuncArgs


FindContentResult

Re-exports FindContentResult


FindVerifiedAnswerFunc

Re-exports FindVerifiedAnswerFunc


FindVerifiedAnswerFuncArgs

Re-exports FindVerifiedAnswerFuncArgs


FindVerifiedAnswerResult

Re-exports FindVerifiedAnswerResult


FunctionMessage

Re-exports FunctionMessage


LlmAnswerQuestionParams

Re-exports LlmAnswerQuestionParams


LlmCallToolParams

Re-exports LlmCallToolParams


LoadPagesArgs

Re-exports LoadPagesArgs


MakeDefaultFindContentFuncArgs

Re-exports MakeDefaultFindContentFuncArgs


MakeDefaultFindVerifiedAnswerFuncArgs

Re-exports MakeDefaultFindVerifiedAnswerFuncArgs


MakeLangChainEmbedderParams

Re-exports MakeLangChainEmbedderParams


MakeLangchainChatLlmProps

Re-exports MakeLangchainChatLlmProps


MakeMongoDbEmbeddedContentStoreParams

Re-exports MakeMongoDbEmbeddedContentStoreParams


MakeMongoDbPageStoreParams

Re-exports MakeMongoDbPageStoreParams


MakeOpenAiChatLlmParams

Re-exports MakeOpenAiChatLlmParams


MakeOpenAiEmbedderArgs

Re-exports MakeOpenAiEmbedderArgs


Message

Re-exports Message


MessageBase

Re-exports MessageBase


MongoDbEmbeddedContentStore

Re-exports MongoDbEmbeddedContentStore


MongoDbPageStore

Re-exports MongoDbPageStore


OpenAIChatCompletionWithoutUsage

Re-exports OpenAIChatCompletionWithoutUsage


OpenAiAwaitedResponse

Re-exports OpenAiAwaitedResponse


OpenAiChatMessage

Re-exports OpenAiChatMessage


OpenAiMessageRole

Re-exports OpenAiMessageRole


OpenAiStreamingResponse

Re-exports OpenAiStreamingResponse


Page

Re-exports Page


PageAction

Re-exports PageAction


PageConcurrencyOptions

Re-exports PageConcurrencyOptions


PageFormat

Re-exports PageFormat


PageMetadata

Re-exports PageMetadata


PageStore

Re-exports PageStore


PersistedPage

Re-exports PersistedPage


Question

Re-exports Question


RateMessageParams

Re-exports RateMessageParams


SearchBooster

Re-exports SearchBooster


SomeMessage

Re-exports SomeMessage


SomeTokenizer

Re-exports SomeTokenizer


SystemMessage

Re-exports SystemMessage


SystemPrompt

Re-exports SystemPrompt


Tool

Re-exports Tool


ToolCallDirective

Re-exports ToolCallDirective


ToolCallParams

Re-exports ToolCallParams


UserMessage

Re-exports UserMessage


VerifiedAnswer

Re-exports VerifiedAnswer


VerifiedAnswerEventData

Re-exports VerifiedAnswerEventData


VerifiedAnswerStore

Re-exports VerifiedAnswerStore


WithFilterAndK

Re-exports WithFilterAndK


asPageFormat

Re-exports asPageFormat


chunkCode

Re-exports chunkCode


chunkMd

Re-exports chunkMd


chunkOpenApiSpecYaml

Re-exports chunkOpenApiSpecYaml


chunkPage

Re-exports chunkPage


createMessage

Re-exports createMessage


createMessageFromOpenAIChatMessage

Re-exports createMessageFromOpenAIChatMessage


defaultConversationConstants

Re-exports defaultConversationConstants


defaultOpenApiSpecYamlChunkOptions

Re-exports defaultOpenApiSpecYamlChunkOptions


extractFrontMatter

Re-exports extractFrontMatter


getChangedPages

Re-exports getChangedPages


isPageFormat

Re-exports isPageFormat


isSupportedLanguage

Re-exports isSupportedLanguage


makeBoostOnAtlasSearchFilter

Re-exports makeBoostOnAtlasSearchFilter


makeChunkFrontMatterUpdater

Re-exports makeChunkFrontMatterUpdater


makeDefaultFindContent

Re-exports makeDefaultFindContent


makeDefaultFindVerifiedAnswer

Re-exports makeDefaultFindVerifiedAnswer


makeLangChainEmbedder

Re-exports makeLangChainEmbedder


makeLangchainChatLlm

Re-exports makeLangchainChatLlm


makeMongoDbConversationsService

Re-exports makeMongoDbConversationsService


makeMongoDbEmbeddedContentStore

Re-exports makeMongoDbEmbeddedContentStore


makeMongoDbPageStore

Re-exports makeMongoDbPageStore


makeMongoDbVerifiedAnswerStore

Re-exports makeMongoDbVerifiedAnswerStore


makeOpenAiChatLlm

Re-exports makeOpenAiChatLlm


makeOpenAiEmbedder

Re-exports makeOpenAiEmbedder


pageFormat

Re-exports pageFormat


pageFormatToLanguage

Re-exports pageFormatToLanguage


pageFormats

Re-exports pageFormats


pageIdentity

Re-exports pageIdentity


persistPages

Re-exports persistPages


removeFrontMatter

Re-exports removeFrontMatter


standardChunkFrontMatterUpdater

Re-exports standardChunkFrontMatterUpdater


standardMetadataGetter

Re-exports standardMetadataGetter


updateEmbeddedContent

Re-exports updateEmbeddedContent


updateEmbeddedContentForPage

Re-exports updateEmbeddedContentForPage


updateFrontMatter

Re-exports updateFrontMatter


updatePages

Re-exports updatePages

Type Aliases

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


AwaitGenerateResponseParams

Ƭ AwaitGenerateResponseParams: Omit<BaseGenerateResponseMessageParams, "dataStreamer">

Defined in

packages/mongodb-chatbot-server/src/routes/generateResponse.ts:170


Classification

Ƭ Classification: z.infer<typeof Classification>

Defined in

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

packages/mongodb-rag-core/build/makeClassifier.d.ts:41


Classifier

Ƭ Classifier: ({ input }: { input: string }) => Promise<{ classification: Classification ; inputMessages: OpenAI.ChatCompletionMessageParam[] }>

Type declaration

▸ ({ input }): Promise<{ classification: Classification ; inputMessages: OpenAI.ChatCompletionMessageParam[] }>

Parameters
NameType
{ input }Object
{ input }.inputstring
Returns

Promise<{ classification: Classification ; inputMessages: OpenAI.ChatCompletionMessageParam[] }>

Defined in

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


ConversationIdStreamEvent

Ƭ ConversationIdStreamEvent: StreamEvent & { data: string ; type: "conversationId" }

Event when server streams the conversation ID to the client.

Defined in

packages/mongodb-rag-core/build/DataStreamer.d.ts:55


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


ConversationsRouterResponse

Ƭ ConversationsRouterResponse: Response<any, ConversationsRouterLocals>

Express.js Response from the app's ConversationsService.

Defined in

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


DatabaseConnection

Ƭ DatabaseConnection: Object

Type declaration

NameType
close(force?: boolean) => Promise<void>
drop() => Promise<void>
init?() => 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-rag-core/build/DataStreamer.d.ts:16


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


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


FinishedStreamEvent

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

Event denoting the end of streaming.

Defined in

packages/mongodb-rag-core/build/DataStreamer.d.ts:48


GenerateResponse

Ƭ GenerateResponse: (params: GenerateResponseParams) => Promise<GenerateResponseReturnValue>

Type declaration

▸ (params): Promise<GenerateResponseReturnValue>

Parameters
NameType
paramsGenerateResponseParams
Returns

Promise<GenerateResponseReturnValue>

Defined in

packages/mongodb-chatbot-server/src/routes/generateResponse.ts:38


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


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


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


MetadataStreamEvent

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

Event when server streams a metadata object to the client.

Defined in

packages/mongodb-rag-core/build/DataStreamer.d.ts:41


ProcessingStreamEvent

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

Event for when the server is processing a request.

Defined in

packages/mongodb-rag-core/build/DataStreamer.d.ts:23


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


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/References.d.ts:8

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


References

Ƭ References: z.infer<typeof References>

Defined in

packages/mongodb-rag-core/build/References.d.ts:42

packages/mongodb-rag-core/build/References.d.ts:43


ReferencesStreamEvent

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

Event when server streams single References object to the client.

Defined in

packages/mongodb-rag-core/build/DataStreamer.d.ts:34


SomeStreamEvent

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

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

Defined in

packages/mongodb-rag-core/build/DataStreamer.d.ts:62


StreamGenerateResponseParams

Ƭ StreamGenerateResponseParams: BaseGenerateResponseMessageParams & Required<Pick<GenerateResponseParams, "dataStreamer">> & { metadata?: Record<string, unknown> }

Defined in

packages/mongodb-chatbot-server/src/routes/generateResponse.ts:275


UpdateTraceFunc

Ƭ UpdateTraceFunc: (params: UpdateTraceFuncParams) => Promise<void>

Type declaration

▸ (params): Promise<void>

Parameters
NameType
paramsUpdateTraceFuncParams
Returns

Promise<void>

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/UpdateTraceFunc.ts:11


UpdateTraceFuncParams

Ƭ UpdateTraceFuncParams: Object

Type declaration

NameType
conversationConversation
loggertypeof braintrustLogger
traceIdstring

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/UpdateTraceFunc.ts:5


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


WithScore

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

Type parameters

Name
T

Defined in

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

Variables

CORE_CHATBOT_APP_ENV_VARS

Const CORE_CHATBOT_APP_ENV_VARS: Object

Type declaration

NameType
MONGODB_CONNECTION_URIstring
MONGODB_DATABASE_NAMEstring

Defined in

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


CORE_ENV_VARS

Const CORE_ENV_VARS: Object

Type declaration

NameType
MONGODB_CONNECTION_URIstring
MONGODB_DATABASE_NAMEstring
OPENAI_API_KEYstring
OPENAI_API_VERSIONstring
OPENAI_CHAT_COMPLETION_DEPLOYMENTstring
OPENAI_CHAT_COMPLETION_MODEL_VERSIONstring
OPENAI_ENDPOINTstring
OPENAI_RETRIEVAL_EMBEDDING_DEPLOYMENTstring
OPENAI_VERIFIED_ANSWER_EMBEDDING_DEPLOYMENTstring
VECTOR_SEARCH_INDEX_NAMEstring

Defined in

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


CORE_OPENAI_CHAT_COMPLETION_ENV_VARS

Const CORE_OPENAI_CHAT_COMPLETION_ENV_VARS: Object

Type declaration

NameType
OPENAI_API_KEYstring
OPENAI_API_VERSIONstring
OPENAI_CHAT_COMPLETION_DEPLOYMENTstring
OPENAI_CHAT_COMPLETION_MODEL_VERSIONstring
OPENAI_ENDPOINTstring

Defined in

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


CORE_OPENAI_CONNECTION_ENV_VARS

Const CORE_OPENAI_CONNECTION_ENV_VARS: Object

Type declaration

NameType
OPENAI_API_KEYstring
OPENAI_API_VERSIONstring
OPENAI_ENDPOINTstring

Defined in

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


CORE_OPENAI_ENV_VARS

Const CORE_OPENAI_ENV_VARS: Object

Type declaration

NameType
OPENAI_API_KEYstring
OPENAI_API_VERSIONstring
OPENAI_CHAT_COMPLETION_DEPLOYMENTstring
OPENAI_CHAT_COMPLETION_MODEL_VERSIONstring
OPENAI_ENDPOINTstring
OPENAI_RETRIEVAL_EMBEDDING_DEPLOYMENTstring
OPENAI_VERIFIED_ANSWER_EMBEDDING_DEPLOYMENTstring
VECTOR_SEARCH_INDEX_NAMEstring

Defined in

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


CORE_OPENAI_RETRIEVAL_ENV_VARS

Const CORE_OPENAI_RETRIEVAL_ENV_VARS: Object

Type declaration

NameType
OPENAI_API_KEYstring
OPENAI_API_VERSIONstring
OPENAI_ENDPOINTstring
OPENAI_RETRIEVAL_EMBEDDING_DEPLOYMENTstring
VECTOR_SEARCH_INDEX_NAMEstring

Defined in

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


CORE_OPENAI_VERIFIED_ANSWERS_ENV_VARS

Const CORE_OPENAI_VERIFIED_ANSWERS_ENV_VARS: Object

Type declaration

NameType
OPENAI_API_KEYstring
OPENAI_API_VERSIONstring
OPENAI_ENDPOINTstring
OPENAI_VERIFIED_ANSWER_EMBEDDING_DEPLOYMENTstring

Defined in

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


CUSTOM_REQUEST_ORIGIN_HEADER

Const CUSTOM_REQUEST_ORIGIN_HEADER: "X-Request-Origin"

Defined in

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


Classification

Classification: ZodObject<{ reason: ZodOptional<ZodString> ; type: ZodString }, "strip", ZodTypeAny, { reason?: string ; type: string }, { reason?: string ; type: string }>

Defined in

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

packages/mongodb-rag-core/build/makeClassifier.d.ts:41


DEFAULT_API_PREFIX

Const DEFAULT_API_PREFIX: "/api/v1"

Defined in

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


DEFAULT_MAX_REQUEST_TIMEOUT_MS

Const DEFAULT_MAX_REQUEST_TIMEOUT_MS: 60000

Defined in

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


Reference

Reference: ZodObject<{ metadata: ZodOptional<ZodObject<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, "passthrough", ZodTypeAny, objectOutputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough">, objectInputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough">>> ; title: ZodString ; url: ZodString }, "strip", ZodTypeAny, { metadata?: objectOutputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough"> ; title: string ; url: string }, { metadata?: objectInputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough"> ; title: string ; url: string }>

Defined in

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

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


References

References: ZodArray<ZodObject<{ metadata: ZodOptional<ZodObject<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, "passthrough", ZodTypeAny, objectOutputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough">, objectInputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough">>> ; title: ZodString ; url: ZodString }, "strip", ZodTypeAny, { metadata?: objectOutputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough"> ; title: string ; url: string }, { metadata?: objectInputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough"> ; title: string ; url: string }>, "many">

Defined in

packages/mongodb-rag-core/build/References.d.ts:42

packages/mongodb-rag-core/build/References.d.ts:43


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


logger

Const logger: Logger

Defined in

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


rateLimitResponse

Const rateLimitResponse: Object

Type declaration

NameType
errorstring

Defined in

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

Functions

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


awaitGenerateResponseMessage

awaitGenerateResponseMessage(«destructured»): Promise<GenerateResponseReturnValue>

Parameters

NameType
«destructured»AwaitGenerateResponseParams

Returns

Promise<GenerateResponseReturnValue>

Defined in

packages/mongodb-chatbot-server/src/routes/generateResponse.ts:175


convertMessageFromLlmToDb

convertMessageFromLlmToDb(message): SomeMessage

Parameters

NameType
messageChatCompletionMessageParam & { content: null | string ; embedding?: number[] ; role: OpenAiMessageRole }

Returns

SomeMessage

Defined in

packages/mongodb-chatbot-server/src/routes/generateResponse.ts:466


createLoggerMessage

createLoggerMessage(«destructured»): Object

Parameters

NameType
«destructured»CreateMessageParams

Returns

Object

NameType
ipAddressundefined | string
messagestring
requestBodyunknown
requestIdundefined | string

Defined in

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


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-rag-core/build/DataStreamer.d.ts:4


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


generateResponse

generateResponse(«destructured»): Promise<GenerateResponseReturnValue>

Generate a response with/without streaming. Supports tool calling and standard response generation. Response includes the user message with any data mutations and the assistant response message, plus any intermediate tool calls.

Parameters

NameType
«destructured»GenerateResponseParams

Returns

Promise<GenerateResponseReturnValue>

Defined in

packages/mongodb-chatbot-server/src/routes/generateResponse.ts:48


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


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


makeClassifier

makeClassifier(«destructured»): Classifier

Parameters

NameTypeDescription
«destructured»Object-
› chainOfThought?booleanIf set to true, the classification will include a reason field that performs chain-of-thought reasoning before determining the classification type..
› classificationTypesClassificationType[]A list of valid classification types.
› modelstring-
› openAiClientOpenAI-

Returns

Classifier

Defined in

packages/mongodb-rag-core/build/makeClassifier.d.ts:51


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


makeDataStreamer

makeDataStreamer(): DataStreamer

Create a DataStreamer that streams data to the client.

Returns

DataStreamer

Defined in

packages/mongodb-rag-core/build/DataStreamer.d.ts:76


makeDefaultReferenceLinks(chunks): { metadata?: objectOutputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough"> ; 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

{ metadata?: objectOutputType<{ sourceName: ZodOptional<ZodString> ; sourceType: ZodOptional<ZodString> ; tags: ZodOptional<ZodArray<ZodString, "many">> }, ZodTypeAny, "passthrough"> ; 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:94


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


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


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


streamGenerateResponseMessage

streamGenerateResponseMessage(«destructured»): Promise<GenerateResponseReturnValue>

Parameters

NameType
«destructured»StreamGenerateResponseParams

Returns

Promise<GenerateResponseReturnValue>

Defined in

packages/mongodb-chatbot-server/src/routes/generateResponse.ts:283


updateTraceIfExists

updateTraceIfExists(«destructured»): Promise<void>

Parameters

NameType
«destructured»Object
› assistantResponseMessageIdObjectId
› conversationIdObjectId
› conversationsConversationsService
› updateTrace?UpdateTraceFunc

Returns

Promise<void>

Defined in

packages/mongodb-chatbot-server/src/routes/conversations/UpdateTraceFunc.ts:13