mongodb-chatbot-server
Namespaces
Interfaces
- AppConfig
- ClassificationType
- ConversationsRateLimitConfig
- ConversationsRouterLocals
- ConversationsRouterParams
- DataStreamer
- GenerateResponseParams
- GenerateUserPromptFuncReturnValue
- MakeRagGenerateUserPromptParams
- MakeUserMessageFuncParams
- MakeVerifiedAnswerGenerateUserPromptParams
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
Name | Type |
---|---|
request | Request |
response | ConversationsRouterResponse |
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
Name | Type |
---|---|
{ input } | Object |
{ input }.input | string |
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
Name | Type |
---|---|
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
Name | Type |
---|---|
conversation | Conversation |
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
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/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
Name | Type |
---|---|
params | GenerateResponseParams |
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
Name | Type |
---|---|
params | GenerateUserPromptFuncParams |
Returns
Promise
<GenerateUserPromptFuncReturnValue
>
Defined in
packages/mongodb-chatbot-server/src/processors/GenerateUserPromptFunc.ts:66
GenerateUserPromptFuncParams
Ƭ GenerateUserPromptFuncParams: Object
Type declaration
Name | Type | Description |
---|---|---|
conversation? | Conversation | Conversation with preceding messages |
customData? | ConversationCustomData | Custom data for the message request. |
reqId | string | String Id for request |
userMessageText | string | Original 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
Name | Type |
---|---|
chunks | EmbeddedContent [] |
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
Name | Type |
---|---|
params | MakeUserMessageFuncParams |
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
Name | Type |
---|---|
ReturnType | extends 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
Name | Type |
---|---|
params | QueryProcessorFuncParams |
Returns
Promise
<ReturnType
>
Defined in
packages/mongodb-chatbot-server/src/processors/QueryPreprocessorFunc.ts:17
QueryPreprocessorResult
Ƭ QueryPreprocessorResult: Object
Type declaration
Name | Type |
---|---|
query? | string |
rejectQuery? | boolean |
Defined in
packages/mongodb-chatbot-server/src/processors/QueryPreprocessorFunc.ts:21
QueryProcessorFuncParams
Ƭ QueryProcessorFuncParams: Object
Type declaration
Name | Type |
---|---|
messages? | Message [] |
query | string |
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
Name | Type |
---|---|
params | UpdateTraceFuncParams |
Returns
Promise
<void
>
Defined in
packages/mongodb-chatbot-server/src/routes/conversations/UpdateTraceFunc.ts:11
UpdateTraceFuncParams
Ƭ UpdateTraceFuncParams: Object
Type declaration
Name | Type |
---|---|
conversation | Conversation |
logger | typeof braintrustLogger |
traceId | string |
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
Name | Type |
---|---|
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
Name | Type |
---|---|
MONGODB_CONNECTION_URI | string |
MONGODB_DATABASE_NAME | string |
Defined in
packages/mongodb-rag-core/build/CoreEnvVars.d.ts:36
CORE_ENV_VARS
• Const
CORE_ENV_VARS: Object
Type declaration
Name | Type |
---|---|
MONGODB_CONNECTION_URI | string |
MONGODB_DATABASE_NAME | string |
OPENAI_API_KEY | string |
OPENAI_API_VERSION | string |
OPENAI_CHAT_COMPLETION_DEPLOYMENT | string |
OPENAI_CHAT_COMPLETION_MODEL_VERSION | string |
OPENAI_ENDPOINT | string |
OPENAI_RETRIEVAL_EMBEDDING_DEPLOYMENT | string |
OPENAI_VERIFIED_ANSWER_EMBEDDING_DEPLOYMENT | string |
VECTOR_SEARCH_INDEX_NAME | string |
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
Name | Type |
---|---|
OPENAI_API_KEY | string |
OPENAI_API_VERSION | string |
OPENAI_CHAT_COMPLETION_DEPLOYMENT | string |
OPENAI_CHAT_COMPLETION_MODEL_VERSION | string |
OPENAI_ENDPOINT | string |
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
Name | Type |
---|---|
OPENAI_API_KEY | string |
OPENAI_API_VERSION | string |
OPENAI_ENDPOINT | string |
Defined in
packages/mongodb-rag-core/build/CoreEnvVars.d.ts:1
CORE_OPENAI_ENV_VARS
• Const
CORE_OPENAI_ENV_VARS: Object
Type declaration
Name | Type |
---|---|
OPENAI_API_KEY | string |
OPENAI_API_VERSION | string |
OPENAI_CHAT_COMPLETION_DEPLOYMENT | string |
OPENAI_CHAT_COMPLETION_MODEL_VERSION | string |
OPENAI_ENDPOINT | string |
OPENAI_RETRIEVAL_EMBEDDING_DEPLOYMENT | string |
OPENAI_VERIFIED_ANSWER_EMBEDDING_DEPLOYMENT | string |
VECTOR_SEARCH_INDEX_NAME | string |
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
Name | Type |
---|---|
OPENAI_API_KEY | string |
OPENAI_API_VERSION | string |
OPENAI_ENDPOINT | string |
OPENAI_RETRIEVAL_EMBEDDING_DEPLOYMENT | string |
VECTOR_SEARCH_INDEX_NAME | string |
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
Name | Type |
---|---|
OPENAI_API_KEY | string |
OPENAI_API_VERSION | string |
OPENAI_ENDPOINT | string |
OPENAI_VERIFIED_ANSWER_EMBEDDING_DEPLOYMENT | string |
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
Name | Type |
---|---|
error | string |
Defined in
packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:211
Functions
assertEnvVars
▸ assertEnvVars<T
>(ENV_VARS
): T
Type parameters
Name | Type |
---|---|
T | extends Record <string , string > |
Parameters
Name | Type |
---|---|
ENV_VARS | T |
Returns
T
Defined in
packages/mongodb-rag-core/build/assertEnvVars.d.ts:1
awaitGenerateResponseMessage
▸ awaitGenerateResponseMessage(«destructured»
): Promise
<GenerateResponseReturnValue
>
Parameters
Name | Type |
---|---|
«destructured» | AwaitGenerateResponseParams |
Returns
Promise
<GenerateResponseReturnValue
>
Defined in
packages/mongodb-chatbot-server/src/routes/generateResponse.ts:175
convertMessageFromLlmToDb
▸ convertMessageFromLlmToDb(message
): SomeMessage
Parameters
Name | Type |
---|---|
message | ChatCompletionMessageParam & { content : null | string ; embedding? : number [] ; role : OpenAiMessageRole } |
Returns
Defined in
packages/mongodb-chatbot-server/src/routes/generateResponse.ts:466
createLoggerMessage
▸ createLoggerMessage(«destructured»
): Object
Parameters
Name | Type |
---|---|
«destructured» | CreateMessageParams |
Returns
Object
Name | Type |
---|---|
ipAddress | undefined | string |
message | string |
requestBody | unknown |
requestId | undefined | 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
Name | Type |
---|---|
err | any |
req | Request <ParamsDictionary , any , any , ParsedQs , Record <string , any >> |
res | Response <any , Record <string , any >, number > |
next | NextFunction |
Returns
void
Defined in
node_modules/@types/express-serve-static-core/index.d.ts:73
escapeNewlines
▸ escapeNewlines(str
): string
Parameters
Name | Type |
---|---|
str | string |
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
Name | Type |
---|---|
array | T [] |
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
Name | Type |
---|---|
array | PromiseSettledResult <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
Name | Type |
---|---|
conversation | Conversation <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
Name | Type |
---|---|
«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
Name | Type |
---|---|
«destructured» | Object |
› content | EmbeddedContent [] |
› maxTokens | number |
Returns
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
Name | Type |
---|---|
config | AppConfig |
Returns
Promise
<Express
>
Defined in
packages/mongodb-chatbot-server/src/app.ts:116
makeClassifier
▸ makeClassifier(«destructured»
): Classifier
Parameters
Name | Type | Description |
---|---|---|
«destructured» | Object | - |
› chainOfThought? | boolean | If set to true , the classification will include a reason field that performs chain-of-thought reasoning before determining the classification type.. |
› classificationTypes | ClassificationType [] | A list of valid classification types. |
› model | string | - |
› openAiClient | OpenAI | - |
Returns
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
Name | Type |
---|---|
«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
Defined in
packages/mongodb-rag-core/build/DataStreamer.d.ts:76
makeDefaultReferenceLinks
▸ 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
Name | Type |
---|---|
chunks | EmbeddedContent [] |
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
Name | Type | Description |
---|---|---|
n | number | Number of previous messages to include. |
Returns
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
Name | Type |
---|---|
apiTimeout | number |
Returns
fn
▸ (req
, res
, next
): void
Parameters
Name | Type |
---|---|
req | Request <ParamsDictionary , any , any , ParsedQs , Record <string , any >> |
res | Response <any , Record <string , any >> |
next | NextFunction |
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:
- Preprocess the user's message using the query preprocessor.
- Find content using vector search.
- Removes any chunks that would exceed the max context tokens.
- Generate the user message using the make user message function.
- Return the user message and references.
Parameters
Name | Type |
---|---|
«destructured» | MakeRagGenerateUserPromptParams |
Returns
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
Name | Type |
---|---|
«destructured» | MakeVerifiedAnswerGenerateUserPromptParams |
Returns
Defined in
packages/mongodb-chatbot-server/src/processors/makeVerifiedAnswerGenerateUserPrompt.ts:26
reqHandler
▸ reqHandler(req
, res
, next
): void
Parameters
Name | Type |
---|---|
req | Request <ParamsDictionary , any , any , ParsedQs , Record <string , any >> |
res | Response <any , Record <string , any >, number > |
next | NextFunction |
Returns
void
Defined in
node_modules/@types/express-serve-static-core/index.d.ts:60
requireRequestOrigin
▸ requireRequestOrigin(): ConversationsMiddleware
Returns
Defined in
packages/mongodb-chatbot-server/src/middleware/requireRequestOrigin.ts:6
requireValidIpAddress
▸ requireValidIpAddress(): ConversationsMiddleware
Returns
Defined in
packages/mongodb-chatbot-server/src/middleware/requireValidIpAddress.ts:5
streamGenerateResponseMessage
▸ streamGenerateResponseMessage(«destructured»
): Promise
<GenerateResponseReturnValue
>
Parameters
Name | Type |
---|---|
«destructured» | StreamGenerateResponseParams |
Returns
Promise
<GenerateResponseReturnValue
>
Defined in
packages/mongodb-chatbot-server/src/routes/generateResponse.ts:283
updateTraceIfExists
▸ updateTraceIfExists(«destructured»
): Promise
<void
>
Parameters
Name | Type |
---|---|
«destructured» | Object |
› assistantResponseMessageId | ObjectId |
› conversationId | ObjectId |
› conversations | ConversationsService |
› updateTrace? | UpdateTraceFunc |
Returns
Promise
<void
>
Defined in
packages/mongodb-chatbot-server/src/routes/conversations/UpdateTraceFunc.ts:13