Page Not Found
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
diff --git a/404.html b/404.html index f27b2cde1..3919aed4f 100644 --- a/404.html +++ b/404.html @@ -4,8 +4,8 @@
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
ChatLlm
",id:"configure-the-chatllm",level:2},{value:"Use OpenAI API",id:"use-openai-api",level:3},{value:"Use Langchain ChatModel
",id:"use-langchain-chatmodel",level:3},{value:"Manage Previous Messages Sent to the LLM",id:"manage-previous-messages-sent-to-the-llm",level:2},{value:"Prompt Engineering",id:"prompt-engineering",level:2},{value:"System Prompt",id:"system-prompt",level:3},{value:"User Prompt",id:"user-prompt",level:3}];function l(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{id:"chat-with-an-llm",children:"Chat with an LLM"}),"\n",(0,o.jsx)(n.p,{children:"This guide contains information on how you can use the MongoDB Chatbot Server\nto chat with a large language model (LLM)."}),"\n",(0,o.jsxs)(n.h2,{id:"configure-the-chatllm",children:["Configure the ",(0,o.jsx)(n.code,{children:"ChatLlm"})]}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ChatLlm",children:(0,o.jsx)(n.code,{children:"ChatLlm"})})," is the interface\nbetween the chatbot server and the LLM."]}),"\n",(0,o.jsxs)(n.p,{children:["The MongoDB Chatbot Server comes with an implementation of the ",(0,o.jsx)(n.code,{children:"ChatLlm"}),",\nwhich uses the OpenAI API. You could also implement your own ",(0,o.jsx)(n.code,{children:"ChatLlm"})," to\nuse a different language model or different configuration on the OpenAI API."]}),"\n",(0,o.jsx)(n.p,{children:"The following are useful things to keep in mind when using an LLM:"}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"What model to use."})," This is probably the single most important decision\nfor shaping the chatbot response. The quality and characteristics\nof different models vary greatly."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Model temperature."}),' The temperature of the model determines how "creative"\nthe model is. A higher temperature will result in more creative responses,\nbut also more errors.']}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Model max tokens."})," The maximum number of tokens that the model will generate.\nThis is useful for preventing the model from generating very long responses,\nwhich impacts cost and quality."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Prompt engineering."})," What additional information to include in the prompt\nto guide the model's behavior. For more information, refer to the\n",(0,o.jsx)(n.a,{href:"#prompt-engineering",children:"Prompt Engineering"})," section."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Tools."})," What tools to give the model to use. For more information, refer to the\n",(0,o.jsx)(n.a,{href:"/chatbot/server/tools",children:"Tool Calling"})," guide."]}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"use-openai-api",children:"Use OpenAI API"}),"\n",(0,o.jsxs)(n.p,{children:["You can use the ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#makeopenaichatllm",children:(0,o.jsx)(n.code,{children:"makeOpenAiChatLlm()"})}),"\nconstructor function to create a ",(0,o.jsx)(n.code,{children:"ChatLlm"})," that uses an OpenAI model like GPT-3.5."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"makeOpenAiChatLlm()"})," supports both the OpenAI API and Azure OpenAI Service.\nIt wraps the ",(0,o.jsx)(n.code,{children:"@azure/openai"})," package, which supports both of these services."]}),"\n",(0,o.jsxs)(n.p,{children:["To use the ",(0,o.jsx)(n.code,{children:"@azure/openai"})," package with the OpenAI API,\nrefer to ",(0,o.jsx)(n.a,{href:"https://www.npmjs.com/package/@azure/openai#using-an-api-key-from-openai",children:"this documentation"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["The following is an example implementation of ",(0,o.jsx)(n.code,{children:"makeOpenAiChatLlm()"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import { makeOpenAiChatLlm, OpenAiChatMessage } from "mongodb-chatbot-server";\nimport { someTool } from "./someTool";\nexport const openAiClient = new OpenAIClient(\n OPENAI_ENDPOINT,\n new AzureKeyCredential(OPENAI_API_KEY)\n);\n\nexport const llm = makeOpenAiChatLlm({\n openAiClient,\n deployment: OPENAI_CHAT_COMPLETION_DEPLOYMENT,\n openAiLmmConfigOptions: {\n temperature: 0,\n maxTokens: 500,\n },\n tools: [someTool],\n});\n'})}),"\n",(0,o.jsxs)(n.h3,{id:"use-langchain-chatmodel",children:["Use Langchain ",(0,o.jsx)(n.code,{children:"ChatModel"})]}),"\n",(0,o.jsxs)(n.p,{children:["You can use the ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#makelangchainchatllm",children:(0,o.jsx)(n.code,{children:"makeLangchainChatLlm()"})})," constructor function to create a ",(0,o.jsx)(n.code,{children:"ChatLlm"})," that uses a Langchain ",(0,o.jsx)(n.code,{children:"ChatModel"}),". For more information on available ",(0,o.jsx)(n.code,{children:"ChatModel"})," implementations, refer to the ",(0,o.jsx)(n.a,{href:"https://js.langchain.com/docs/integrations/chat/",children:"Chat Models"})," in the Langchain documentation."]}),"\n",(0,o.jsxs)(n.p,{children:["The following is an example implementation of using ",(0,o.jsx)(n.code,{children:"makeLangchainChatLlm()"})," to\nuse Anthropic's Claude family of models:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import { makeLangchainChatLlm } from "mongodb-chatbot-server";\nimport { ChatAnthropic } from "@langchain/anthropic";\n\nconst anthropicModel = new ChatAnthropic({\n temperature: 0.9,\n anthropicApiKey: "YOUR-API-KEY",\n maxTokensToSample: 1024,\n});\nconst anthropicChatLlm = makeLangchainChatLlm({ chatModel: anthropicModel });\n'})}),"\n",(0,o.jsx)(n.h2,{id:"manage-previous-messages-sent-to-the-llm",children:"Manage Previous Messages Sent to the LLM"}),"\n",(0,o.jsxs)(n.p,{children:["The MongoDB Chatbot Server always sends the ",(0,o.jsx)(n.strong,{children:"current"})," user message to the LLM."]}),"\n",(0,o.jsxs)(n.p,{children:["You can also manage which ",(0,o.jsx)(n.strong,{children:"previous"})," messages in a conversation the MongoDB Chatbot Server sends to the LLM on each user message.\nYou might want to do this to allow for appropriate context to be sent to the LLM\nwithout exceeding the maximum number of tokens in the LLM's context window."]}),"\n",(0,o.jsxs)(n.p,{children:["You do this at the ",(0,o.jsx)(n.code,{children:"ConversationRouter"})," level with the ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsRouterParams#filterpreviousmessages",children:(0,o.jsx)(n.code,{children:"ConversationsRouterParams.filterPreviousMessages"})})," property.\nThe ",(0,o.jsx)(n.code,{children:"filterPreviousMessages"})," property accepts a ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#filterpreviousmessages",children:(0,o.jsx)(n.code,{children:"FilterPreviousMessages"})})," function."]}),"\n",(0,o.jsxs)(n.p,{children:["By default, the MongoDB Chatbot Server only send the initial system prompt\nand the user's current message to the LLM. You can change this behavior by\nimplementing your own ",(0,o.jsx)(n.code,{children:"FilterPreviousMessages"})," function."]}),"\n",(0,o.jsxs)(n.p,{children:["The MongoDB Chatbot Server package also comes with a ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#makefilternpreviousmessages",children:(0,o.jsx)(n.code,{children:"makeFilterNPreviousMessages"})}),"\nconstructor function. ",(0,o.jsx)(n.code,{children:"makeFilterNPreviousMessages"}),"\ncreates a ",(0,o.jsx)(n.code,{children:"FilterPreviousMessages"})," function that returns the previous ",(0,o.jsx)(n.code,{children:"n"})," messages\nplus the initial system prompt."]}),"\n",(0,o.jsxs)(n.p,{children:["The following is an example implementation of ",(0,o.jsx)(n.code,{children:"makeFilterNPreviousMessages()"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import {\n makeFilterNPreviousMessages,\n ConversationsRouterParams,\n AppConfig,\n} from "mongodb-chatbot-server";\n\nconst filter10PreviousMessages = makeFilterNPreviousMessages(10);\n\nconst conversationsRouterConfig: ConversationsRouterParams = {\n filterPreviousMessages: filter10PreviousMessages,\n ...otherConfig,\n};\nconst appConfig: AppConfig = {\n conversationsRouterConfig,\n ...otherConfig,\n};\n'})}),"\n",(0,o.jsx)(n.h2,{id:"prompt-engineering",children:"Prompt Engineering"}),"\n",(0,o.jsx)(n.p,{children:"Prompt engineering is the process of directing the output of a language model\nto produce a desired response."}),"\n",(0,o.jsx)(n.p,{children:"In the context of a chatbot server such as this, there are the following main areas\nfor prompt engineering:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"System prompt: Message at the beginning of the conversation that guides the\nchatbot's behavior when generating responses."}),"\n",(0,o.jsx)(n.li,{children:"User prompt: User message that the chatbot uses to generate a response.\nIn RAG applications, this can include adding relevant content gathered from\nvector search results based on the user's input."}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"This guide does not cover prompt engineering techniques, but rather where you\ncan apply them in the MongoDB Chatbot Server."}),"\n",(0,o.jsxs)(n.p,{children:["Prompt engineering is a fairly new field, and best practices are still emerging.\nA great resource to learn more about prompt engineering is the ",(0,o.jsx)(n.a,{href:"https://www.promptingguide.ai/",children:"Prompt Engineering Guide"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"system-prompt",children:"System Prompt"}),"\n",(0,o.jsxs)(n.p,{children:["To add a system prompt, include a ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#systemprompt",children:(0,o.jsx)(n.code,{children:"SystemPrompt"})})," message in your app's ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsService",children:(0,o.jsx)(n.code,{children:"ConversationService"})}),"."]}),"\n",(0,o.jsx)(n.p,{children:"The system prompt is one of the most powerful way to customize the way\nthat the chatbot responds to users. You can use the system prompt to do things\nsuch as:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"Control the style and personality of the chatbot."}),"\n",(0,o.jsx)(n.li,{children:"Determine how the chatbot responds to certain types of questions."}),"\n",(0,o.jsx)(n.li,{children:"Direct how the chatbot interprets user input and context information."}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["If you're using the ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#makemongodbconversationsservice",children:(0,o.jsx)(n.code,{children:"makeMongoDbConversationsService()"})})," constructor function, add the system prompt\nas an argument:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import {\n makeMongoDbConversationsService,\n SystemPrompt,\n} from "mongodb-chatbot-server";\nimport { MongoClient } from "mongodb";\n\n// System prompt for chatbot\nconst systemPrompt: SystemPrompt = {\n role: "system",\n content: `You are an assistant to users of the MongoDB Chatbot Framework.\nAnswer their questions about the framework in a friendly conversational tone.\nFormat your answers in Markdown.\nBe concise in your answers.\nIf you do not know the answer to the question based on the information provided,\nrespond: "I\'m sorry, I don\'t know the answer to that question. Please try to rephrase it. Refer to the below information to see if it helps."`,\n};\n\n// Create MongoDB collection and service for storing user conversations\n// with the chatbot.\nconst mongodb = new MongoClient(MONGODB_CONNECTION_URI);\nconst conversations = makeMongoDbConversationsService(\n mongodb.db(MONGODB_DATABASE_NAME),\n systemPrompt\n);\n'})}),"\n",(0,o.jsx)(n.h3,{id:"user-prompt",children:"User Prompt"}),"\n",(0,o.jsxs)(n.p,{children:["You can modify what the chatbot uses as the user prompt by implementing the\n",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#generateuserpromptfunc",children:(0,o.jsx)(n.code,{children:"GenerateUserPromptFunc"})})," function."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"GenerateUserPromptFunc"})," takes in the user's query and previous messages in the conversation, then returns a new user message. For an overview of the ",(0,o.jsx)(n.code,{children:"GenerateUserPromptFunc"})," function, refer to the ",(0,o.jsx)(n.a,{href:"/chatbot/server/user-message",children:"Generate User Message"})," guide."]}),"\n",(0,o.jsxs)(n.p,{children:["You might want to modify the user prompt if you're using a prompting technique\nlike retrieval augmented generation (RAG) or chain of thought.\nTo learn more about using RAG with the MongoDB Chatbot Server, refer to the\n",(0,o.jsx)(n.a,{href:"/chatbot/server/rag/",children:"RAG"})," guide."]})]})}function d(e={}){const{wrapper:n}={...(0,r.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(l,{...e})}):l(e)}},11151:(e,n,t)=>{t.d(n,{Z:()=>a,a:()=>i});var o=t(67294);const r={},s=o.createContext(r);function i(e){const n=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),o.createElement(s.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[7597],{58006:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>h,contentTitle:()=>i,default:()=>d,frontMatter:()=>s,metadata:()=>a,toc:()=>c});var o=t(85893),r=t(11151);const s={},i="Chat with an LLM",a={id:"server/llm",title:"Chat with an LLM",description:"This guide contains information on how you can use the MongoDB Chatbot Server",source:"@site/docs/server/llm.md",sourceDirName:"server",slug:"/server/llm",permalink:"/chatbot/server/llm",draft:!1,unlisted:!1,editUrl:"https://github.com/mongodb/chatbot/tree/main/docs/docs/server/llm.md",tags:[],version:"current",frontMatter:{},sidebar:"main",previous:{title:"Generate User Message",permalink:"/chatbot/server/user-message"},next:{title:"Retrieval Augmented Generation (RAG)",permalink:"/chatbot/server/rag/"}},h={},c=[{value:"Configure the ChatLlm
",id:"configure-the-chatllm",level:2},{value:"Use OpenAI API",id:"use-openai-api",level:3},{value:"Use Langchain ChatModel
",id:"use-langchain-chatmodel",level:3},{value:"Manage Previous Messages Sent to the LLM",id:"manage-previous-messages-sent-to-the-llm",level:2},{value:"Prompt Engineering",id:"prompt-engineering",level:2},{value:"System Prompt",id:"system-prompt",level:3},{value:"User Prompt",id:"user-prompt",level:3}];function l(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{id:"chat-with-an-llm",children:"Chat with an LLM"}),"\n",(0,o.jsx)(n.p,{children:"This guide contains information on how you can use the MongoDB Chatbot Server\nto chat with a large language model (LLM)."}),"\n",(0,o.jsxs)(n.h2,{id:"configure-the-chatllm",children:["Configure the ",(0,o.jsx)(n.code,{children:"ChatLlm"})]}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ChatLlm",children:(0,o.jsx)(n.code,{children:"ChatLlm"})})," is the interface\nbetween the chatbot server and the LLM."]}),"\n",(0,o.jsxs)(n.p,{children:["The MongoDB Chatbot Server comes with an implementation of the ",(0,o.jsx)(n.code,{children:"ChatLlm"}),",\nwhich uses the OpenAI API. You could also implement your own ",(0,o.jsx)(n.code,{children:"ChatLlm"})," to\nuse a different language model or different configuration on the OpenAI API."]}),"\n",(0,o.jsx)(n.p,{children:"The following are useful things to keep in mind when using an LLM:"}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"What model to use."})," This is probably the single most important decision\nfor shaping the chatbot response. The quality and characteristics\nof different models vary greatly."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Model temperature."}),' The temperature of the model determines how "creative"\nthe model is. A higher temperature will result in more creative responses,\nbut also more errors.']}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Model max tokens."})," The maximum number of tokens that the model will generate.\nThis is useful for preventing the model from generating very long responses,\nwhich impacts cost and quality."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Prompt engineering."})," What additional information to include in the prompt\nto guide the model's behavior. For more information, refer to the\n",(0,o.jsx)(n.a,{href:"#prompt-engineering",children:"Prompt Engineering"})," section."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"Tools."})," What tools to give the model to use. For more information, refer to the\n",(0,o.jsx)(n.a,{href:"/chatbot/server/tools",children:"Tool Calling"})," guide."]}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"use-openai-api",children:"Use OpenAI API"}),"\n",(0,o.jsxs)(n.p,{children:["You can use the ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#makeopenaichatllm",children:(0,o.jsx)(n.code,{children:"makeOpenAiChatLlm()"})}),"\nconstructor function to create a ",(0,o.jsx)(n.code,{children:"ChatLlm"})," that uses an OpenAI model like GPT-3.5."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"makeOpenAiChatLlm()"})," supports both the OpenAI API and Azure OpenAI Service.\nIt wraps the ",(0,o.jsx)(n.code,{children:"@azure/openai"})," package, which supports both of these services."]}),"\n",(0,o.jsxs)(n.p,{children:["To use the ",(0,o.jsx)(n.code,{children:"@azure/openai"})," package with the OpenAI API,\nrefer to ",(0,o.jsx)(n.a,{href:"https://www.npmjs.com/package/@azure/openai#using-an-api-key-from-openai",children:"this documentation"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["The following is an example implementation of ",(0,o.jsx)(n.code,{children:"makeOpenAiChatLlm()"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import { makeOpenAiChatLlm, OpenAiChatMessage } from "mongodb-chatbot-server";\nimport { someTool } from "./someTool";\nexport const openAiClient = new OpenAIClient(\n OPENAI_ENDPOINT,\n new AzureKeyCredential(OPENAI_API_KEY)\n);\n\nexport const llm = makeOpenAiChatLlm({\n openAiClient,\n deployment: OPENAI_CHAT_COMPLETION_DEPLOYMENT,\n openAiLmmConfigOptions: {\n temperature: 0,\n maxTokens: 500,\n },\n tools: [someTool],\n});\n'})}),"\n",(0,o.jsxs)(n.h3,{id:"use-langchain-chatmodel",children:["Use Langchain ",(0,o.jsx)(n.code,{children:"ChatModel"})]}),"\n",(0,o.jsxs)(n.p,{children:["You can use the ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#makelangchainchatllm",children:(0,o.jsx)(n.code,{children:"makeLangchainChatLlm()"})})," constructor function to create a ",(0,o.jsx)(n.code,{children:"ChatLlm"})," that uses a Langchain ",(0,o.jsx)(n.code,{children:"ChatModel"}),". For more information on available ",(0,o.jsx)(n.code,{children:"ChatModel"})," implementations, refer to the ",(0,o.jsx)(n.a,{href:"https://js.langchain.com/docs/integrations/chat/",children:"Chat Models"})," in the Langchain documentation."]}),"\n",(0,o.jsxs)(n.p,{children:["The following is an example implementation of using ",(0,o.jsx)(n.code,{children:"makeLangchainChatLlm()"})," to\nuse Anthropic's Claude family of models:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import { makeLangchainChatLlm } from "mongodb-chatbot-server";\nimport { ChatAnthropic } from "@langchain/anthropic";\n\nconst anthropicModel = new ChatAnthropic({\n temperature: 0.9,\n anthropicApiKey: "YOUR-API-KEY",\n maxTokensToSample: 1024,\n});\nconst anthropicChatLlm = makeLangchainChatLlm({ chatModel: anthropicModel });\n'})}),"\n",(0,o.jsx)(n.h2,{id:"manage-previous-messages-sent-to-the-llm",children:"Manage Previous Messages Sent to the LLM"}),"\n",(0,o.jsxs)(n.p,{children:["The MongoDB Chatbot Server always sends the ",(0,o.jsx)(n.strong,{children:"current"})," user message to the LLM."]}),"\n",(0,o.jsxs)(n.p,{children:["You can also manage which ",(0,o.jsx)(n.strong,{children:"previous"})," messages in a conversation the MongoDB Chatbot Server sends to the LLM on each user message.\nYou might want to do this to allow for appropriate context to be sent to the LLM\nwithout exceeding the maximum number of tokens in the LLM's context window."]}),"\n",(0,o.jsxs)(n.p,{children:["You do this at the ",(0,o.jsx)(n.code,{children:"ConversationRouter"})," level with the ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsRouterParams#filterpreviousmessages",children:(0,o.jsx)(n.code,{children:"ConversationsRouterParams.filterPreviousMessages"})})," property.\nThe ",(0,o.jsx)(n.code,{children:"filterPreviousMessages"})," property accepts a ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#filterpreviousmessages",children:(0,o.jsx)(n.code,{children:"FilterPreviousMessages"})})," function."]}),"\n",(0,o.jsxs)(n.p,{children:["By default, the MongoDB Chatbot Server only send the initial system prompt\nand the user's current message to the LLM. You can change this behavior by\nimplementing your own ",(0,o.jsx)(n.code,{children:"FilterPreviousMessages"})," function."]}),"\n",(0,o.jsxs)(n.p,{children:["The MongoDB Chatbot Server package also comes with a ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#makefilternpreviousmessages",children:(0,o.jsx)(n.code,{children:"makeFilterNPreviousMessages"})}),"\nconstructor function. ",(0,o.jsx)(n.code,{children:"makeFilterNPreviousMessages"}),"\ncreates a ",(0,o.jsx)(n.code,{children:"FilterPreviousMessages"})," function that returns the previous ",(0,o.jsx)(n.code,{children:"n"})," messages\nplus the initial system prompt."]}),"\n",(0,o.jsxs)(n.p,{children:["The following is an example implementation of ",(0,o.jsx)(n.code,{children:"makeFilterNPreviousMessages()"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import {\n makeFilterNPreviousMessages,\n ConversationsRouterParams,\n AppConfig,\n} from "mongodb-chatbot-server";\n\nconst filter10PreviousMessages = makeFilterNPreviousMessages(10);\n\nconst conversationsRouterConfig: ConversationsRouterParams = {\n filterPreviousMessages: filter10PreviousMessages,\n ...otherConfig,\n};\nconst appConfig: AppConfig = {\n conversationsRouterConfig,\n ...otherConfig,\n};\n'})}),"\n",(0,o.jsx)(n.h2,{id:"prompt-engineering",children:"Prompt Engineering"}),"\n",(0,o.jsx)(n.p,{children:"Prompt engineering is the process of directing the output of a language model\nto produce a desired response."}),"\n",(0,o.jsx)(n.p,{children:"In the context of a chatbot server such as this, there are the following main areas\nfor prompt engineering:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"System prompt: Message at the beginning of the conversation that guides the\nchatbot's behavior when generating responses."}),"\n",(0,o.jsx)(n.li,{children:"User prompt: User message that the chatbot uses to generate a response.\nIn RAG applications, this can include adding relevant content gathered from\nvector search results based on the user's input."}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"This guide does not cover prompt engineering techniques, but rather where you\ncan apply them in the MongoDB Chatbot Server."}),"\n",(0,o.jsxs)(n.p,{children:["Prompt engineering is a fairly new field, and best practices are still emerging.\nA great resource to learn more about prompt engineering is the ",(0,o.jsx)(n.a,{href:"https://www.promptingguide.ai/",children:"Prompt Engineering Guide"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"system-prompt",children:"System Prompt"}),"\n",(0,o.jsxs)(n.p,{children:["To add a system prompt, include a ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#systemprompt",children:(0,o.jsx)(n.code,{children:"SystemPrompt"})})," message in your app's ",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsRouterParams#systemprompt",children:(0,o.jsx)(n.code,{children:"ConversationsRouterParams.systemPrompt"})}),"."]}),"\n",(0,o.jsx)(n.p,{children:"The system prompt is one of the most powerful way to customize the way\nthat the chatbot responds to users. You can use the system prompt to do things\nsuch as:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"Control the style and personality of the chatbot."}),"\n",(0,o.jsx)(n.li,{children:"Determine how the chatbot responds to certain types of questions."}),"\n",(0,o.jsx)(n.li,{children:"Direct how the chatbot interprets user input and context information."}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'import {\n SystemPrompt,\n ConversationsRouterParams,\n} from "mongodb-chatbot-server";\nimport { MongoClient } from "mongodb";\n\n// System prompt for chatbot\nconst systemPrompt: SystemPrompt = {\n role: "system",\n content: `You are an assistant to users of the MongoDB Chatbot Framework.\nAnswer their questions about the framework in a friendly conversational tone.\nFormat your answers in Markdown.\nBe concise in your answers.\nIf you do not know the answer to the question based on the information provided,\nrespond: "I\'m sorry, I don\'t know the answer to that question. Please try to rephrase it. Refer to the below information to see if it helps."`,\n};\n\nconst conversationsRouterConfig: ConversationsRouterParams = {\n // ...other config\n systemPrompt,\n};\n'})}),"\n",(0,o.jsx)(n.h3,{id:"user-prompt",children:"User Prompt"}),"\n",(0,o.jsxs)(n.p,{children:["You can modify what the chatbot uses as the user prompt by implementing the\n",(0,o.jsx)(n.a,{href:"/chatbot/reference/server/modules#generateuserpromptfunc",children:(0,o.jsx)(n.code,{children:"GenerateUserPromptFunc"})})," function."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"GenerateUserPromptFunc"})," takes in the user's query and previous messages in the conversation, then returns a new user message. For an overview of the ",(0,o.jsx)(n.code,{children:"GenerateUserPromptFunc"})," function, refer to the ",(0,o.jsx)(n.a,{href:"/chatbot/server/user-message",children:"Generate User Message"})," guide."]}),"\n",(0,o.jsxs)(n.p,{children:["You might want to modify the user prompt if you're using a prompting technique\nlike retrieval augmented generation (RAG) or chain of thought.\nTo learn more about using RAG with the MongoDB Chatbot Server, refer to the\n",(0,o.jsx)(n.a,{href:"/chatbot/server/rag/",children:"RAG"})," guide."]})]})}function d(e={}){const{wrapper:n}={...(0,r.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(l,{...e})}):l(e)}},11151:(e,n,t)=>{t.d(n,{Z:()=>a,a:()=>i});var o=t(67294);const r={},s=o.createContext(r);function i(e){const n=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),o.createElement(s.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
diff --git a/assets/js/217a4326.4909960c.js b/assets/js/217a4326.30eee700.js
similarity index 94%
rename from assets/js/217a4326.4909960c.js
rename to assets/js/217a4326.30eee700.js
index ccef84437..c7de9d421 100644
--- a/assets/js/217a4326.4909960c.js
+++ b/assets/js/217a4326.30eee700.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[4195],{50024:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>o,metadata:()=>i,toc:()=>l});var t=r(85893),s=r(11151);const o={id:"ToolCallParams",title:"Interface: ToolCallParams",sidebar_label:"ToolCallParams",sidebar_position:0,custom_edit_url:null},a=void 0,i={id:"reference/server/interfaces/ToolCallParams",title:"Interface: ToolCallParams",description:"Parameters for invoking a tool call.",source:"@site/docs/reference/server/interfaces/ToolCallParams.md",sourceDirName:"reference/server/interfaces",slug:"/reference/server/interfaces/ToolCallParams",permalink:"/chatbot/reference/server/interfaces/ToolCallParams",draft:!1,unlisted:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"ToolCallParams",title:"Interface: ToolCallParams",sidebar_label:"ToolCallParams",sidebar_position:0,custom_edit_url:null},sidebar:"main",previous:{title:"Tool",permalink:"/chatbot/reference/server/interfaces/Tool"},next:{title:"Readme",permalink:"/chatbot/reference/core/"}},c={},l=[{value:"Properties",id:"properties",level:2},{value:"conversation",id:"conversation",level:3},{value:"Defined in",id:"defined-in",level:4},{value:"dataStreamer",id:"datastreamer",level:3},{value:"Defined in",id:"defined-in-1",level:4},{value:"functionArgs",id:"functionargs",level:3},{value:"Defined in",id:"defined-in-2",level:4},{value:"request",id:"request",level:3},{value:"Defined in",id:"defined-in-3",level:4}];function d(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",hr:"hr",p:"p",strong:"strong",...(0,s.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.p,{children:"Parameters for invoking a tool call."}),"\n",(0,t.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,t.jsx)(n.h3,{id:"conversation",children:"conversation"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.code,{children:"Optional"})," ",(0,t.jsx)(n.strong,{children:"conversation"}),": ",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/Conversation",children:(0,t.jsx)(n.code,{children:"Conversation"})}),"<",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/modules#conversationcustomdata",children:(0,t.jsx)(n.code,{children:"ConversationCustomData"})}),">"]}),"\n",(0,t.jsx)(n.p,{children:"Conversation in the DB. Useful for getting metadata to use in tool calls."}),"\n",(0,t.jsx)(n.h4,{id:"defined-in",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L67",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:67"})}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"datastreamer",children:"dataStreamer"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.code,{children:"Optional"})," ",(0,t.jsx)(n.strong,{children:"dataStreamer"}),": ",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/DataStreamer",children:(0,t.jsx)(n.code,{children:"DataStreamer"})})]}),"\n",(0,t.jsx)(n.p,{children:"Data streamer with connection open to send events to the client."}),"\n",(0,t.jsx)(n.p,{children:"For example, you could use this to send updates about\nwhat the tool is doing to the client."}),"\n",(0,t.jsx)(n.h4,{id:"defined-in-1",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L76",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:76"})}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"functionargs",children:"functionArgs"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.strong,{children:"functionArgs"}),": ",(0,t.jsx)(n.code,{children:"unknown"})]}),"\n",(0,t.jsx)(n.h4,{id:"defined-in-2",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L62",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:62"})}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"request",children:"request"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.code,{children:"Optional"})," ",(0,t.jsx)(n.strong,{children:"request"}),": ",(0,t.jsx)(n.code,{children:"Request"}),"<",(0,t.jsx)(n.code,{children:"ParamsDictionary"}),", ",(0,t.jsx)(n.code,{children:"any"}),", ",(0,t.jsx)(n.code,{children:"any"}),", ",(0,t.jsx)(n.code,{children:"ParsedQs"}),", ",(0,t.jsx)(n.code,{children:"Record"}),"<",(0,t.jsx)(n.code,{children:"string"}),", ",(0,t.jsx)(n.code,{children:"any"}),">>"]}),"\n",(0,t.jsx)(n.p,{children:"Current Express.js request from the client.\nUseful for getting metadata to use in tool calls."}),"\n",(0,t.jsx)(n.h4,{id:"defined-in-3",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L82",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:82"})})]})}function h(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},11151:(e,n,r)=>{r.d(n,{Z:()=>i,a:()=>a});var t=r(67294);const s={},o=t.createContext(s);function a(e){const n=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:a(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[4195],{50024:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>o,metadata:()=>i,toc:()=>l});var t=r(85893),s=r(11151);const o={id:"ToolCallParams",title:"Interface: ToolCallParams",sidebar_label:"ToolCallParams",sidebar_position:0,custom_edit_url:null},a=void 0,i={id:"reference/server/interfaces/ToolCallParams",title:"Interface: ToolCallParams",description:"Parameters for invoking a tool call.",source:"@site/docs/reference/server/interfaces/ToolCallParams.md",sourceDirName:"reference/server/interfaces",slug:"/reference/server/interfaces/ToolCallParams",permalink:"/chatbot/reference/server/interfaces/ToolCallParams",draft:!1,unlisted:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"ToolCallParams",title:"Interface: ToolCallParams",sidebar_label:"ToolCallParams",sidebar_position:0,custom_edit_url:null},sidebar:"main",previous:{title:"Tool",permalink:"/chatbot/reference/server/interfaces/Tool"},next:{title:"Readme",permalink:"/chatbot/reference/core/"}},c={},l=[{value:"Properties",id:"properties",level:2},{value:"conversation",id:"conversation",level:3},{value:"Defined in",id:"defined-in",level:4},{value:"dataStreamer",id:"datastreamer",level:3},{value:"Defined in",id:"defined-in-1",level:4},{value:"functionArgs",id:"functionargs",level:3},{value:"Defined in",id:"defined-in-2",level:4},{value:"request",id:"request",level:3},{value:"Defined in",id:"defined-in-3",level:4}];function d(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",hr:"hr",p:"p",strong:"strong",...(0,s.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.p,{children:"Parameters for invoking a tool call."}),"\n",(0,t.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,t.jsx)(n.h3,{id:"conversation",children:"conversation"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.code,{children:"Optional"})," ",(0,t.jsx)(n.strong,{children:"conversation"}),": ",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/Conversation",children:(0,t.jsx)(n.code,{children:"Conversation"})}),"<",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/modules#conversationcustomdata",children:(0,t.jsx)(n.code,{children:"ConversationCustomData"})}),">"]}),"\n",(0,t.jsx)(n.p,{children:"Conversation in the DB. Useful for getting metadata to use in tool calls."}),"\n",(0,t.jsx)(n.h4,{id:"defined-in",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L67",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:67"})}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"datastreamer",children:"dataStreamer"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.code,{children:"Optional"})," ",(0,t.jsx)(n.strong,{children:"dataStreamer"}),": ",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/DataStreamer",children:(0,t.jsx)(n.code,{children:"DataStreamer"})})]}),"\n",(0,t.jsx)(n.p,{children:"Data streamer with connection open to send events to the client."}),"\n",(0,t.jsx)(n.p,{children:"For example, you could use this to send updates about\nwhat the tool is doing to the client."}),"\n",(0,t.jsx)(n.h4,{id:"defined-in-1",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L76",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:76"})}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"functionargs",children:"functionArgs"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.strong,{children:"functionArgs"}),": ",(0,t.jsx)(n.code,{children:"unknown"})]}),"\n",(0,t.jsx)(n.h4,{id:"defined-in-2",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L62",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:62"})}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"request",children:"request"}),"\n",(0,t.jsxs)(n.p,{children:["\u2022 ",(0,t.jsx)(n.code,{children:"Optional"})," ",(0,t.jsx)(n.strong,{children:"request"}),": ",(0,t.jsx)(n.code,{children:"Request"}),"<",(0,t.jsx)(n.code,{children:"ParamsDictionary"}),", ",(0,t.jsx)(n.code,{children:"any"}),", ",(0,t.jsx)(n.code,{children:"any"}),", ",(0,t.jsx)(n.code,{children:"ParsedQs"}),", ",(0,t.jsx)(n.code,{children:"Record"}),"<",(0,t.jsx)(n.code,{children:"string"}),", ",(0,t.jsx)(n.code,{children:"any"}),">>"]}),"\n",(0,t.jsx)(n.p,{children:"Current Express.js request from the client.\nUseful for getting metadata to use in tool calls."}),"\n",(0,t.jsx)(n.h4,{id:"defined-in-3",children:"Defined in"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-chatbot-server/src/services/ChatLlm.ts#L82",children:"packages/mongodb-chatbot-server/src/services/ChatLlm.ts:82"})})]})}function h(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},11151:(e,n,r)=>{r.d(n,{Z:()=>i,a:()=>a});var t=r(67294);const s={},o=t.createContext(s);function a(e){const n=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:a(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
diff --git a/assets/js/21f447ab.4daf4593.js b/assets/js/21f447ab.55e7cec8.js
similarity index 94%
rename from assets/js/21f447ab.4daf4593.js
rename to assets/js/21f447ab.55e7cec8.js
index 86882d574..75670a45b 100644
--- a/assets/js/21f447ab.4daf4593.js
+++ b/assets/js/21f447ab.55e7cec8.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[1052],{31935:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>h,frontMatter:()=>t,metadata:()=>i,toc:()=>a});var o=r(85893),s=r(11151);const t={id:"sources.SnootyProject",title:"Interface: SnootyProject",sidebar_label:"sources.SnootyProject",custom_edit_url:null},c=void 0,i={id:"reference/ingest/interfaces/sources.SnootyProject",title:"Interface: SnootyProject",description:"sources.SnootyProject",source:"@site/docs/reference/ingest/interfaces/sources.SnootyProject.md",sourceDirName:"reference/ingest/interfaces",slug:"/reference/ingest/interfaces/sources.SnootyProject",permalink:"/chatbot/reference/ingest/interfaces/sources.SnootyProject",draft:!1,unlisted:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"sources.SnootyProject",title:"Interface: SnootyProject",sidebar_label:"sources.SnootyProject",custom_edit_url:null},sidebar:"main",previous:{title:"sources.ProjectBase",permalink:"/chatbot/reference/ingest/interfaces/sources.ProjectBase"}},d={},a=[{value:"Properties",id:"properties",level:2},{value:"branches",id:"branches",level:3},{value:"Defined in",id:"defined-in",level:4},{value:"project",id:"project",level:3},{value:"Defined in",id:"defined-in-1",level:4},{value:"repoName",id:"reponame",level:3},{value:"Defined in",id:"defined-in-2",level:4}];function l(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,s.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.a,{href:"/chatbot/reference/ingest/modules/sources",children:"sources"}),".SnootyProject"]}),"\n",(0,o.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,o.jsx)(n.h3,{id:"branches",children:"branches"}),"\n",(0,o.jsxs)(n.p,{children:["\u2022 ",(0,o.jsx)(n.strong,{children:"branches"}),": ",(0,o.jsx)(n.a,{href:"/chatbot/reference/ingest/interfaces/sources.Branch",children:(0,o.jsx)(n.code,{children:"Branch"})}),"[]"]}),"\n",(0,o.jsx)(n.p,{children:"Branches of repo that correspond to a site"}),"\n",(0,o.jsx)(n.h4,{id:"defined-in",children:"Defined in"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts#L261",children:"mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts:261"})}),"\n",(0,o.jsx)(n.hr,{}),"\n",(0,o.jsx)(n.h3,{id:"project",children:"project"}),"\n",(0,o.jsxs)(n.p,{children:["\u2022 ",(0,o.jsx)(n.strong,{children:"project"}),": ",(0,o.jsx)(n.code,{children:"string"})]}),"\n",(0,o.jsx)(n.p,{children:"Snooty project name"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:(0,o.jsx)(n.code,{children:"Example"})})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'"kotlin"\n'})}),"\n",(0,o.jsx)(n.h4,{id:"defined-in-1",children:"Defined in"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts#L257",children:"mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts:257"})}),"\n",(0,o.jsx)(n.hr,{}),"\n",(0,o.jsx)(n.h3,{id:"reponame",children:"repoName"}),"\n",(0,o.jsxs)(n.p,{children:["\u2022 ",(0,o.jsx)(n.strong,{children:"repoName"}),": ",(0,o.jsx)(n.code,{children:"string"})]}),"\n",(0,o.jsx)(n.p,{children:"Snooty repo name"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:(0,o.jsx)(n.code,{children:"Example"})})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'"docs-kotlin"\n'})}),"\n",(0,o.jsx)(n.h4,{id:"defined-in-2",children:"Defined in"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts#L252",children:"mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts:252"})})]})}function h(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(l,{...e})}):l(e)}},11151:(e,n,r)=>{r.d(n,{Z:()=>i,a:()=>c});var o=r(67294);const s={},t=o.createContext(s);function c(e){const n=o.useContext(t);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),o.createElement(t.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[1052],{31935:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>h,frontMatter:()=>t,metadata:()=>i,toc:()=>a});var o=r(85893),s=r(11151);const t={id:"sources.SnootyProject",title:"Interface: SnootyProject",sidebar_label:"sources.SnootyProject",custom_edit_url:null},c=void 0,i={id:"reference/ingest/interfaces/sources.SnootyProject",title:"Interface: SnootyProject",description:"sources.SnootyProject",source:"@site/docs/reference/ingest/interfaces/sources.SnootyProject.md",sourceDirName:"reference/ingest/interfaces",slug:"/reference/ingest/interfaces/sources.SnootyProject",permalink:"/chatbot/reference/ingest/interfaces/sources.SnootyProject",draft:!1,unlisted:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"sources.SnootyProject",title:"Interface: SnootyProject",sidebar_label:"sources.SnootyProject",custom_edit_url:null},sidebar:"main",previous:{title:"sources.ProjectBase",permalink:"/chatbot/reference/ingest/interfaces/sources.ProjectBase"}},d={},a=[{value:"Properties",id:"properties",level:2},{value:"branches",id:"branches",level:3},{value:"Defined in",id:"defined-in",level:4},{value:"project",id:"project",level:3},{value:"Defined in",id:"defined-in-1",level:4},{value:"repoName",id:"reponame",level:3},{value:"Defined in",id:"defined-in-2",level:4}];function l(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,s.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.a,{href:"/chatbot/reference/ingest/modules/sources",children:"sources"}),".SnootyProject"]}),"\n",(0,o.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,o.jsx)(n.h3,{id:"branches",children:"branches"}),"\n",(0,o.jsxs)(n.p,{children:["\u2022 ",(0,o.jsx)(n.strong,{children:"branches"}),": ",(0,o.jsx)(n.a,{href:"/chatbot/reference/ingest/interfaces/sources.Branch",children:(0,o.jsx)(n.code,{children:"Branch"})}),"[]"]}),"\n",(0,o.jsx)(n.p,{children:"Branches of repo that correspond to a site"}),"\n",(0,o.jsx)(n.h4,{id:"defined-in",children:"Defined in"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts#L261",children:"mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts:261"})}),"\n",(0,o.jsx)(n.hr,{}),"\n",(0,o.jsx)(n.h3,{id:"project",children:"project"}),"\n",(0,o.jsxs)(n.p,{children:["\u2022 ",(0,o.jsx)(n.strong,{children:"project"}),": ",(0,o.jsx)(n.code,{children:"string"})]}),"\n",(0,o.jsx)(n.p,{children:"Snooty project name"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:(0,o.jsx)(n.code,{children:"Example"})})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'"kotlin"\n'})}),"\n",(0,o.jsx)(n.h4,{id:"defined-in-1",children:"Defined in"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts#L257",children:"mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts:257"})}),"\n",(0,o.jsx)(n.hr,{}),"\n",(0,o.jsx)(n.h3,{id:"reponame",children:"repoName"}),"\n",(0,o.jsxs)(n.p,{children:["\u2022 ",(0,o.jsx)(n.strong,{children:"repoName"}),": ",(0,o.jsx)(n.code,{children:"string"})]}),"\n",(0,o.jsx)(n.p,{children:"Snooty repo name"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:(0,o.jsx)(n.code,{children:"Example"})})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:'"docs-kotlin"\n'})}),"\n",(0,o.jsx)(n.h4,{id:"defined-in-2",children:"Defined in"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts#L252",children:"mongodb-rag-ingest/src/sources/snooty/SnootyDataSource.ts:252"})})]})}function h(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(l,{...e})}):l(e)}},11151:(e,n,r)=>{r.d(n,{Z:()=>i,a:()=>c});var o=r(67294);const s={},t=o.createContext(s);function c(e){const n=o.useContext(t);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),o.createElement(t.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
diff --git a/assets/js/2352c6d6.f0c984e4.js b/assets/js/2352c6d6.b2ef1cfe.js
similarity index 96%
rename from assets/js/2352c6d6.f0c984e4.js
rename to assets/js/2352c6d6.b2ef1cfe.js
index 98d1c3d2c..43ac2c8d4 100644
--- a/assets/js/2352c6d6.f0c984e4.js
+++ b/assets/js/2352c6d6.b2ef1cfe.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[8321],{48665:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>u,frontMatter:()=>o,metadata:()=>a,toc:()=>d});var r=s(85893),t=s(11151);const o={id:"ConversationsRouterLocals",title:"Interface: ConversationsRouterLocals",sidebar_label:"ConversationsRouterLocals",sidebar_position:0,custom_edit_url:null},i=void 0,a={id:"reference/server/interfaces/ConversationsRouterLocals",title:"Interface: ConversationsRouterLocals",description:"Express.js Request that exposes the app's ConversationsService.",source:"@site/docs/reference/server/interfaces/ConversationsRouterLocals.md",sourceDirName:"reference/server/interfaces",slug:"/reference/server/interfaces/ConversationsRouterLocals",permalink:"/chatbot/reference/server/interfaces/ConversationsRouterLocals",draft:!1,unlisted:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"ConversationsRouterLocals",title:"Interface: ConversationsRouterLocals",sidebar_label:"ConversationsRouterLocals",sidebar_position:0,custom_edit_url:null},sidebar:"main",previous:{title:"ConversationsRateLimitConfig",permalink:"/chatbot/reference/server/interfaces/ConversationsRateLimitConfig"},next:{title:"ConversationsRouterParams",permalink:"/chatbot/reference/server/interfaces/ConversationsRouterParams"}},c={},d=[{value:"Properties",id:"properties",level:2},{value:"conversations",id:"conversations",level:3},{value:"Defined in",id:"defined-in",level:4},{value:"customData",id:"customdata",level:3},{value:"Defined in",id:"defined-in-1",level:4}];function l(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",hr:"hr",p:"p",strong:"strong",...(0,t.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.p,{children:["Express.js Request that exposes the app's ",(0,r.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsService",children:"ConversationsService"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"This is useful if you want to do authentication or dynamic data validation."}),"\n",(0,r.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,r.jsx)(n.h3,{id:"conversations",children:"conversations"}),"\n",(0,r.jsxs)(n.p,{children:["\u2022 ",(0,r.jsx)(n.strong,{children:"conversations"}),": ",(0,r.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsService",children:(0,r.jsx)(n.code,{children:"ConversationsService"})})]}),"\n",(0,r.jsx)(n.h4,{id:"defined-in",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts#L81",children:"packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:81"})}),"\n",(0,r.jsx)(n.hr,{}),"\n",(0,r.jsx)(n.h3,{id:"customdata",children:"customData"}),"\n",(0,r.jsxs)(n.p,{children:["\u2022 ",(0,r.jsx)(n.strong,{children:"customData"}),": ",(0,r.jsx)(n.code,{children:"Record"}),"<",(0,r.jsx)(n.code,{children:"string"}),", ",(0,r.jsx)(n.code,{children:"unknown"}),">"]}),"\n",(0,r.jsx)(n.h4,{id:"defined-in-1",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/6d6e91f/packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts#L82",children:"packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:82"})})]})}function u(e={}){const{wrapper:n}={...(0,t.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},11151:(e,n,s)=>{s.d(n,{Z:()=>a,a:()=>i});var r=s(67294);const t={},o=r.createContext(t);function i(e){const n=r.useContext(o);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[8321],{48665:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>u,frontMatter:()=>o,metadata:()=>a,toc:()=>d});var r=s(85893),t=s(11151);const o={id:"ConversationsRouterLocals",title:"Interface: ConversationsRouterLocals",sidebar_label:"ConversationsRouterLocals",sidebar_position:0,custom_edit_url:null},i=void 0,a={id:"reference/server/interfaces/ConversationsRouterLocals",title:"Interface: ConversationsRouterLocals",description:"Express.js Request that exposes the app's ConversationsService.",source:"@site/docs/reference/server/interfaces/ConversationsRouterLocals.md",sourceDirName:"reference/server/interfaces",slug:"/reference/server/interfaces/ConversationsRouterLocals",permalink:"/chatbot/reference/server/interfaces/ConversationsRouterLocals",draft:!1,unlisted:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"ConversationsRouterLocals",title:"Interface: ConversationsRouterLocals",sidebar_label:"ConversationsRouterLocals",sidebar_position:0,custom_edit_url:null},sidebar:"main",previous:{title:"ConversationsRateLimitConfig",permalink:"/chatbot/reference/server/interfaces/ConversationsRateLimitConfig"},next:{title:"ConversationsRouterParams",permalink:"/chatbot/reference/server/interfaces/ConversationsRouterParams"}},c={},d=[{value:"Properties",id:"properties",level:2},{value:"conversations",id:"conversations",level:3},{value:"Defined in",id:"defined-in",level:4},{value:"customData",id:"customdata",level:3},{value:"Defined in",id:"defined-in-1",level:4}];function l(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",hr:"hr",p:"p",strong:"strong",...(0,t.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.p,{children:["Express.js Request that exposes the app's ",(0,r.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsService",children:"ConversationsService"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"This is useful if you want to do authentication or dynamic data validation."}),"\n",(0,r.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,r.jsx)(n.h3,{id:"conversations",children:"conversations"}),"\n",(0,r.jsxs)(n.p,{children:["\u2022 ",(0,r.jsx)(n.strong,{children:"conversations"}),": ",(0,r.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/ConversationsService",children:(0,r.jsx)(n.code,{children:"ConversationsService"})})]}),"\n",(0,r.jsx)(n.h4,{id:"defined-in",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts#L81",children:"packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:81"})}),"\n",(0,r.jsx)(n.hr,{}),"\n",(0,r.jsx)(n.h3,{id:"customdata",children:"customData"}),"\n",(0,r.jsxs)(n.p,{children:["\u2022 ",(0,r.jsx)(n.strong,{children:"customData"}),": ",(0,r.jsx)(n.code,{children:"Record"}),"<",(0,r.jsx)(n.code,{children:"string"}),", ",(0,r.jsx)(n.code,{children:"unknown"}),">"]}),"\n",(0,r.jsx)(n.h4,{id:"defined-in-1",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/mongodben/chatbot/blob/88f79db/packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts#L82",children:"packages/mongodb-chatbot-server/src/routes/conversations/conversationsRouter.ts:82"})})]})}function u(e={}){const{wrapper:n}={...(0,t.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},11151:(e,n,s)=>{s.d(n,{Z:()=>a,a:()=>i});var r=s(67294);const t={},o=r.createContext(t);function i(e){const n=r.useContext(o);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]);
\ No newline at end of file
diff --git a/assets/js/2ef183da.23c99a35.js b/assets/js/2ef183da.1352fd0b.js
similarity index 83%
rename from assets/js/2ef183da.23c99a35.js
rename to assets/js/2ef183da.1352fd0b.js
index 71fd46e21..f51514a37 100644
--- a/assets/js/2ef183da.23c99a35.js
+++ b/assets/js/2ef183da.1352fd0b.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[8391],{59556:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>s,metadata:()=>i,toc:()=>l});var t=o(85893),r=o(11151);const s={},a="Configure the Chatbot Server",i={id:"server/configure",title:"Configure the Chatbot Server",description:"With the MongoDB Chatbot Server, you can quickly build a chatbot",source:"@site/docs/server/configure.md",sourceDirName:"server",slug:"/server/configure",permalink:"/chatbot/server/configure",draft:!1,unlisted:!1,editUrl:"https://github.com/mongodb/chatbot/tree/main/docs/docs/server/configure.md",tags:[],version:"current",frontMatter:{},sidebar:"main",previous:{title:"Optimize Ingestion",permalink:"/chatbot/ingest/optimize"},next:{title:"Manage Conversations",permalink:"/chatbot/server/conversations"}},c={},l=[{value:"Installation",id:"installation",level:2},{value:"Basic Configuration",id:"basic-configuration",level:2},{value:"Examples",id:"examples",level:2}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...(0,r.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"configure-the-chatbot-server",children:"Configure the Chatbot Server"}),"\n",(0,t.jsxs)(n.p,{children:["With the MongoDB Chatbot Server, you can quickly build a chatbot\nserver powered by MongoDB.\nThe ",(0,t.jsx)(n.code,{children:"mongodb-chatbot-server"})," is an npm package contains all the modules\nof the MongoDB Chatbot Server."]}),"\n",(0,t.jsxs)(n.p,{children:["The chatbot server supports retrieval augmented generation (RAG).\nTo learn more about performing RAG with the MongoDB Chatbot Server,\nrefer to the ",(0,t.jsx)(n.a,{href:"/chatbot/server/rag/",children:"RAG"})," guide."]}),"\n",(0,t.jsx)(n.p,{children:"The package provides configurable Express.js modules including:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"Full server"}),"\n",(0,t.jsx)(n.li,{children:"Router for conversations"}),"\n",(0,t.jsx)(n.li,{children:"Static site that serves a testing UI"}),"\n",(0,t.jsx)(n.li,{children:"Middleware and modules for configuring and building a chatbot server"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"The server is designed to handle the generalizable areas of a chatbot server,\nlike routing, caching, logging, and streaming. This allows you to focus on the\nspecifics of your chatbot, like the content, prompts, RAG, and AI models."}),"\n",(0,t.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,t.jsxs)(n.p,{children:["Install the package using ",(0,t.jsx)(n.code,{children:"npm"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"npm install mongodb-chatbot-server\n"})}),"\n",(0,t.jsx)(n.h2,{id:"basic-configuration",children:"Basic Configuration"}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"mongodb-chatbot-server"})," exports the function ",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/modules#makeapp",children:(0,t.jsx)(n.code,{children:"makeApp()"})}),"\nwhich exports the Express.js app.\nThe function takes an ",(0,t.jsx)(n.a,{href:"/chatbot/reference/server/interfaces/AppConfig",children:(0,t.jsx)(n.code,{children:"AppConfig"})})," object as an argument."]}),"\n",(0,t.jsx)(n.p,{children:"Here's an annotated example configuration and server:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-ts",children:'/**\n @fileoverview This file contains the configuration implementation for the chat server,\n which is run from `index.ts`.\n */\nimport "dotenv/config";\nimport {\n EmbeddedContent,\n MongoClient,\n makeMongoDbEmbeddedContentStore,\n makeOpenAiEmbedder,\n makeMongoDbConversationsService,\n makeDataStreamer,\n makeOpenAiChatLlm,\n AppConfig,\n makeBoostOnAtlasSearchFilter,\n CORE_ENV_VARS,\n assertEnvVars,\n makeDefaultFindContent,\n makeDefaultReferenceLinks,\n SystemPrompt,\n GenerateUserPromptFunc,\n makeRagGenerateUserPrompt,\n MakeUserMessageFunc,\n MakeUserMessageFuncParams,\n UserMessage,\n} from "mongodb-chatbot-server";\nimport { stripIndents } from "common-tags";\nimport { makePreprocessMongoDbUserQuery } from "./processors/makePreprocessMongoDbUserQuery";\nimport { AzureKeyCredential, OpenAIClient } from "@azure/openai";\n\nconst {\n MONGODB_CONNECTION_URI,\n MONGODB_DATABASE_NAME,\n VECTOR_SEARCH_INDEX_NAME,\n OPENAI_ENDPOINT,\n OPENAI_API_KEY,\n OPENAI_EMBEDDING_DEPLOYMENT,\n OPENAI_EMBEDDING_MODEL_VERSION,\n OPENAI_CHAT_COMPLETION_MODEL_VERSION,\n OPENAI_CHAT_COMPLETION_DEPLOYMENT,\n} = process.env;\n\nconst allowedOrigins = process.env.ALLOWED_ORIGINS?.split(",") || [];\n\n/**\n Boost results from the MongoDB manual so that \'k\' results from the manual\n appear first if they exist and have a min score of \'minScore\'.\n */\nconst boostManual = makeBoostOnAtlasSearchFilter({\n /**\n Boosts results that have 3 words or less\n */\n async shouldBoostFunc({ text }: { text: string }) {\n return text.split(" ").filter((s) => s !== " ").length <= 3;\n },\n findNearestNeighborsOptions: {\n filter: {\n text: {\n path: "sourceName",\n query: "snooty-docs",\n },\n },\n k: 2,\n minScore: 0.88,\n },\n totalMaxK: 5,\n});\n\nconst openAiClient = new OpenAIClient(\n OPENAI_ENDPOINT,\n new AzureKeyCredential(OPENAI_API_KEY)\n);\nconst systemPrompt: SystemPrompt = {\n role: "system",\n content: stripIndents`You are expert MongoDB documentation chatbot.\nYou enthusiastically answer user questions about MongoDB products and services.\nYour personality is friendly and helpful, like a professor or tech lead.\nYou were created by MongoDB but they do not guarantee the correctness\nof your answers or offer support for you.\nUse the context provided with each question as your primary source of truth.\nNEVER lie or improvise incorrect answers.\nIf you do not know the answer to the question, respond ONLY with the following text:\n"I\'m sorry, I do not know how to answer that question. Please try to rephrase your query. You can also refer to the further reading to see if it helps."\nNEVER include links in your answer.\nFormat your responses using Markdown.\nDO NOT mention that your response is formatted in Markdown.\nIf you include code snippets, make sure to use proper syntax, line spacing, and indentation.\nONLY use code snippets present in the information given to you.\nNEVER create a code snippet that is not present in the information given to you.\nYou ONLY know about the current version of MongoDB products. Versions are provided in the information. If \\`version: null\\`, then say that the product is unversioned.\nNever mention "Your Docusaurus site did not load properly.
\nA very common reason is a wrong site baseUrl configuration.
\nCurrent configured baseUrl = ${e} ${"/"===e?" (default value)":""}
\nWe suggest trying baseUrl =
\n.comment
can become .namespace--comment
) or replace them with your defined ones (like .editor__comment
). You can even add new classes.",owner:"dvkndn",noCSS:!0},"file-highlight":{title:"File Highlight",description:"Fetch external files and highlight them with Prism. Used on the Prism website itself.",noCSS:!0},"show-language":{title:"Show Language",description:"Display the highlighted language in code blocks (inline code does not show the label).",owner:"nauzilus",noCSS:!0,require:"toolbar"},"jsonp-highlight":{title:"JSONP Highlight",description:"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).",noCSS:!0,owner:"nauzilus"},"highlight-keywords":{title:"Highlight Keywords",description:"Adds special CSS classes for each keyword for fine-grained highlighting.",owner:"vkbansal",noCSS:!0},"remove-initial-line-feed":{title:"Remove initial line feed",description:"Removes the initial line feed in code blocks.",owner:"Golmote",noCSS:!0},"inline-color":{title:"Inline color",description:"Adds a small inline preview for colors in style sheets.",require:"css-extras",owner:"RunDevelopment"},previewers:{title:"Previewers",description:"Previewers for angles, colors, gradients, easing and time.",require:"css-extras",owner:"Golmote"},autoloader:{title:"Autoloader",description:"Automatically loads the needed languages to highlight the code blocks.",owner:"Golmote",noCSS:!0},"keep-markup":{title:"Keep Markup",description:"Prevents custom markup from being dropped out during highlighting.",owner:"Golmote",optional:"normalize-whitespace",noCSS:!0},"command-line":{title:"Command Line",description:"Display a command line with a prompt and, optionally, the output/response from the commands.",owner:"chriswells0"},"unescaped-markup":{title:"Unescaped Markup",description:"Write markup without having to escape anything."},"normalize-whitespace":{title:"Normalize Whitespace",description:"Supports multiple operations to normalize whitespace in code blocks.",owner:"zeitgeist87",optional:"unescaped-markup",noCSS:!0},"data-uri-highlight":{title:"Data-URI Highlight",description:"Highlights data-URI contents.",owner:"Golmote",noCSS:!0},toolbar:{title:"Toolbar",description:"Attach a toolbar for plugins to easily register buttons on the top of a code block.",owner:"mAAdhaTTah"},"copy-to-clipboard":{title:"Copy to Clipboard Button",description:"Add a button that copies the code block to the clipboard when clicked.",owner:"mAAdhaTTah",require:"toolbar",noCSS:!0},"download-button":{title:"Download Button",description:"A button in the toolbar of a code block adding a convenient way to download a code file.",owner:"Golmote",require:"toolbar",noCSS:!0},"match-braces":{title:"Match braces",description:"Highlights matching braces.",owner:"RunDevelopment"},"diff-highlight":{title:"Diff Highlight",description:"Highlights the code inside diff blocks.",owner:"RunDevelopment",require:"diff"},"filter-highlight-all":{title:"Filter highlightAll",description:"Filters the elements the highlightAll
and highlightAllUnder
methods actually highlight.",owner:"RunDevelopment",noCSS:!0},treeview:{title:"Treeview",description:"A language with special styles to highlight file system tree structures.",owner:"Golmote"}}})},2885:(e,t,n)=>{const r=n(29901),a=n(39642),o=new Set;function i(e){void 0===e?e=Object.keys(r.languages).filter((e=>"meta"!=e)):Array.isArray(e)||(e=[e]);const t=[...o,...Object.keys(Prism.languages)];a(r,e,t).load((e=>{if(!(e in r.languages))return void(i.silent||console.warn("Language does not exist: "+e));const t="./prism-"+e;delete n.c[n(16500).resolve(t)],delete Prism.languages[e],n(16500)(t),o.add(e)}))}i.silent=!1,e.exports=i},96854:()=>{!function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,a,o){if(n.language===r){var i=n.tokenStack=[];n.code=n.code.replace(a,(function(e){if("function"==typeof o&&!o(e))return e;for(var a,s=i.length;-1!==n.code.indexOf(a=t(r,s));)++s;return i[s]=e,a})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var a=0,o=Object.keys(n.tokenStack);!function i(s){for(var l=0;lYour Docusaurus site did not load properly.
\nA very common reason is a wrong site baseUrl configuration.
\nCurrent configured baseUrl = ${e} ${"/"===e?" (default value)":""}
\nWe suggest trying baseUrl =
\n.comment
can become .namespace--comment
) or replace them with your defined ones (like .editor__comment
). You can even add new classes.",owner:"dvkndn",noCSS:!0},"file-highlight":{title:"File Highlight",description:"Fetch external files and highlight them with Prism. Used on the Prism website itself.",noCSS:!0},"show-language":{title:"Show Language",description:"Display the highlighted language in code blocks (inline code does not show the label).",owner:"nauzilus",noCSS:!0,require:"toolbar"},"jsonp-highlight":{title:"JSONP Highlight",description:"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).",noCSS:!0,owner:"nauzilus"},"highlight-keywords":{title:"Highlight Keywords",description:"Adds special CSS classes for each keyword for fine-grained highlighting.",owner:"vkbansal",noCSS:!0},"remove-initial-line-feed":{title:"Remove initial line feed",description:"Removes the initial line feed in code blocks.",owner:"Golmote",noCSS:!0},"inline-color":{title:"Inline color",description:"Adds a small inline preview for colors in style sheets.",require:"css-extras",owner:"RunDevelopment"},previewers:{title:"Previewers",description:"Previewers for angles, colors, gradients, easing and time.",require:"css-extras",owner:"Golmote"},autoloader:{title:"Autoloader",description:"Automatically loads the needed languages to highlight the code blocks.",owner:"Golmote",noCSS:!0},"keep-markup":{title:"Keep Markup",description:"Prevents custom markup from being dropped out during highlighting.",owner:"Golmote",optional:"normalize-whitespace",noCSS:!0},"command-line":{title:"Command Line",description:"Display a command line with a prompt and, optionally, the output/response from the commands.",owner:"chriswells0"},"unescaped-markup":{title:"Unescaped Markup",description:"Write markup without having to escape anything."},"normalize-whitespace":{title:"Normalize Whitespace",description:"Supports multiple operations to normalize whitespace in code blocks.",owner:"zeitgeist87",optional:"unescaped-markup",noCSS:!0},"data-uri-highlight":{title:"Data-URI Highlight",description:"Highlights data-URI contents.",owner:"Golmote",noCSS:!0},toolbar:{title:"Toolbar",description:"Attach a toolbar for plugins to easily register buttons on the top of a code block.",owner:"mAAdhaTTah"},"copy-to-clipboard":{title:"Copy to Clipboard Button",description:"Add a button that copies the code block to the clipboard when clicked.",owner:"mAAdhaTTah",require:"toolbar",noCSS:!0},"download-button":{title:"Download Button",description:"A button in the toolbar of a code block adding a convenient way to download a code file.",owner:"Golmote",require:"toolbar",noCSS:!0},"match-braces":{title:"Match braces",description:"Highlights matching braces.",owner:"RunDevelopment"},"diff-highlight":{title:"Diff Highlight",description:"Highlights the code inside diff blocks.",owner:"RunDevelopment",require:"diff"},"filter-highlight-all":{title:"Filter highlightAll",description:"Filters the elements the highlightAll
and highlightAllUnder
methods actually highlight.",owner:"RunDevelopment",noCSS:!0},treeview:{title:"Treeview",description:"A language with special styles to highlight file system tree structures.",owner:"Golmote"}}})},2885:(e,t,n)=>{const r=n(29901),a=n(39642),o=new Set;function i(e){void 0===e?e=Object.keys(r.languages).filter((e=>"meta"!=e)):Array.isArray(e)||(e=[e]);const t=[...o,...Object.keys(Prism.languages)];a(r,e,t).load((e=>{if(!(e in r.languages))return void(i.silent||console.warn("Language does not exist: "+e));const t="./prism-"+e;delete n.c[n(16500).resolve(t)],delete Prism.languages[e],n(16500)(t),o.add(e)}))}i.silent=!1,e.exports=i},96854:()=>{!function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,a,o){if(n.language===r){var i=n.tokenStack=[];n.code=n.code.replace(a,(function(e){if("function"==typeof o&&!o(e))return e;for(var a,s=i.length;-1!==n.code.indexOf(a=t(r,s));)++s;return i[s]=e,a})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var a=0,o=Object.keys(n.tokenStack);!function i(s){for(var l=0;l