Skip to main content

Interface: ConversationsRouterParams

Configuration for the /conversations/* routes.

Properties

addMessageToConversationCustomData

Optional addMessageToConversationCustomData: AddCustomDataFunc

Function that takes the request + response and returns any custom data you want to include in the Message persisted to the database. For example, you might want to store details about what LLM was used to generate the response. The custom data is persisted to the database with the Message in the Message.customData field inside of the Conversation.messages array.

Defined in

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


addMessageToConversationUpdateTrace

Optional addMessageToConversationUpdateTrace: UpdateTraceFunc

Defined in

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


commentMessageUpdateTrace

Optional commentMessageUpdateTrace: UpdateTraceFunc

Defined in

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


conversations

conversations: ConversationsService

Defined in

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


createConversationCustomData

Optional createConversationCustomData: AddCustomDataFunc

Function that takes the request + response and returns any custom data you want to include in the Conversation persisted to the database. For example, you might want to store the user's email address with the conversation. The custom data is persisted to the database with the Conversation in the Conversation.customData field.

Defined in

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


createConversationOnNullMessageId

Optional createConversationOnNullMessageId: boolean

Whether to create a new conversation if the message ID is "null" on the addMessageToConversation route.

Default

true

Defined in

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


filterPreviousMessages

Optional filterPreviousMessages: FilterPreviousMessages

Function to filter which previous messages are sent to the ChatLlm. 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. Defaults to sending only the system prompt.

Defined in

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


generateUserPrompt

Optional generateUserPrompt: GenerateUserPromptFunc

Function to generate the user prompt sent to the ChatLlm. You can perform any preprocessing of the user's message including retrieval augmented generation here.

Defined in

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


llm

llm: ChatLlm

Defined in

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


maxInputLengthCharacters

Optional maxInputLengthCharacters: number

Maximum number of characters in user input. Server returns 400 error if user input is longer than this.

Defined in

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


maxUserCommentLength

Optional maxUserCommentLength: number

Maximum number of characters allowed in a user's comment on an assistant Message. If not specified, user comments may be of any length.

Defined in

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


maxUserMessagesInConversation

Optional maxUserMessagesInConversation: number

Maximum number of user-sent messages in a conversation. Server returns 400 error if user tries to add a message to a conversation that has this many messages.

Defined in

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


middleware

Optional middleware: ConversationsMiddleware[]

Middleware to put in front of all the routes in the conversationsRouter. You can use this to do things like authentication, data validation, etc.

If you want the middleware to run only on certain routes, you can add conditional logic inside the middleware. For example:

const someMiddleware: ConversationsMiddleware = (req, res, next) => {
if (req.path === "/conversations") {
// Do something
}
next();
}

Defined in

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


rateLimitConfig

Optional rateLimitConfig: ConversationsRateLimitConfig

Defined in

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


rateMessageUpdateTrace

Optional rateMessageUpdateTrace: UpdateTraceFunc

Defined in

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


systemPrompt

systemPrompt: Object

Type declaration

NameTypeDescription
embedding?number[]The vector representation of the content.

Defined in

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