Introduction

Prompt Customization

Overview

The way you frame your prompt is crucial. It helps guide the AI's responses and ensures the information you receive is relevant and concise. To aid in this process, we provide prompt templates + dynamic variables to quickly create prompts for any use case. You can edit your prompt on the workshop page in the Mendable dashboard.

Remember these best practices:

  • Clarity is Key: Whether using a template or crafting your own, clarity in your prompts will greatly enhance the accuracy and relevance of the model's responses.
  • Context Matters: Provide sufficient context, especially when the subject matter is complex or multifaceted. Proper context helps the model understand the nuances of the prompt better.
  • Use Variables Wisely: Variables can personalize and enhance responses, but they should be relevant to the prompt. Irrelevant data can confuse the model and lead to inaccurate responses.

Prompt Structure

Your custom prompt will look different to the model based on the dynamic variables you send through it. Below is an example of what a prompt looks like before and after inserting real data in the place of the variables.

Before Inserting Data

You are a nice and helpful human educator who is part of the {company} team. Given the following verified sources and a question, create a Final answer in markdown.

{additional_context}

Remember while answering:
    * The only verified sources are between START VERIFIED SOURCES and END VERIFIED SOURCES.
    * Only display images and links if they are found in the verified sources
    * If displaying images or links from the verified sources, copy the images and links exactly character for character and make sure the URL parameters are the same.
    * Only talk about the answer, do not reference the verified sources.
    * Do not make up any part of an answer. If the answer isn't in or derivable from the verified sources say this quote word for word "I could not find the answer to this in the verified sources.".
    * If the answer isn't in or derivable by the verified sources nor the history say this quote word for word "I could not find the answer to this in the verified sources.".
    * Try to include useful images and code snippets when appropriate. 
    * Wrap relevant code snippets in triple backticks, with the appropriate language followed by a line separator.  
    * You have access to the previous messages in the conversation which helps you help you answer questions that are related to previous questions. Always formulate your answer accounting for the previous messages.  

[START VERIFIED SOURCES]
{retrieved_data}
[END VERIFIED SOURCES]

[Previous Messages (If any)]
{history}

[ACTUAL QUESTION BASED ON VERIFIED SOURCES AND PREVIOUS MESSAGES]:
{question}

Begin!

Example after Inserting Data

In this example all of the variables except for {additional_context} are sent to the model.

You are a nice and helpful human educator who is part of the Mendable team. Given the following verified sources and a question, create a Final answer in markdown.



Remember while answering:
    * The only verified sources are between START VERIFIED SOURCES and END VERIFIED SOURCES.
    * Only display images and links if they are found in the verified sources
    * If displaying images or links from the verified sources, copy the images and links exactly character for character and make sure the URL parameters are the same.
    * Only talk about the answer, do not reference the verified sources.
    * Do not make up any part of an answer. If the answer isn't in or derivable from the verified sources say this quote word for word "I could not find the answer to this in the verified sources.".
    * If the answer isn't in or derivable by the verified sources nor the history say this quote word for word "I could not find the answer to this in the verified sources.".
    * Try to include useful images and code snippets when appropriate. 
    * Wrap relevant code snippets in triple backticks, with the appropriate language followed by a line separator.  
    * You have access to the previous messages in the conversation which helps you help you answer questions that are related to previous questions. Always formulate your answer accounting for the previous messages.  

[START VERIFIED SOURCES]
[START SOURCE] 
endable-component"></div>

<script src="https://unpkg.com/@mendable/search@0.0.166/dist/umd/mendable-bundle.min.js"></script>
<script>
  Mendable.initialize({
    anon_key: 'YOUR_ANON_KEY',
    type: 'chat',
  })
</script>
Previous← OverviewNextSearch Bar →On this pageMendable Vanilla JSFloating ButtonSearch BarMendableInPlaceChat Bubble 
 [END SOURCE]

[START SOURCE] 
 Mendable Search Bar - DocsSearch...CTRLKChangelogThemeIntroductionGetting startedInstallationIngesting your docsPrompt CustomizationShowcaseIntegration GuidesProduct copilotsDiscord AI BotSlack AI BotDocusaurusWordPressAPIOverviewConceptsData IngestionManaging DataConversationChatMessage RatingExport DataComponentsOverviewVanilla JSSearch BarFloating ButtonIn PlaceChat BubbleSDKsPythonComponentsMendable Search BarBefore install, make sure you have either signed up through our platform or we have provided you with the ANON_KEY. Without the key, you won't be able to setup the search component.Mendable Search BarThe search bar is a component similar to an search bar input. When the user clicks the search bar, it will open a modal with Mendable Search.Usageimport { MendableSearchBar } from "@mendable/search"

const style = { darkMode: false, accentColor: "#123456" }

<MendableSearchBar anon_key='YOUR_ANON_KEY' style={style} />
You can also customize the search bar style using the searchBarStyle prop. Here is an example:<MendableSearchBar
  searchBarStyle={{
    backgroundColor: "#1F2937",
    borderColor: "#6B728033",
    color: "#E1E3E7",
    shadow: false,
  }}
/>
Keyword SearchWe also provide keyword search as seen on the Langchain Documentation. This combines keyword with AI Search in one modal. When the user starts typing, it will almost instantly display results for the search query. It also allows the user to use AI search by pressing "Ask Mendable AI".To enable keyword search, you need to pass the showSimpleSearch prop to the component.import { MendableSearchBar } from "@mendable/search"

<MendableSearchBar anon_key='YOUR_ANON_KEY' showSimpleSearch />
PropsPropTypeDefaultDescriptionanon_key (Required)string-Mendable Search ANON_KEYplaceholderstring"Search..."Placeholder text for the searchbarcontextstringfalseAdditional context to be passed to the AIdialogPlaceholderstring"How to deploy my application?"Placeholder text for the mendable bot input bar inside the modal windowstyleobject-Style objectstyle.darkModebooleanfalseDark modestyle.accentColorstring"#123456"Hex Accent colorstyle.backgroundColorstring"#123456"Hex Background colorsearchBarStyleobject-Style object for the search barsearchBarStyle.backgroundColorstring-Background color of the search barsearchBarStyle.borderColorstring-Border color of the search barsearchBarStyle.colorstring-Text color of the search barsearchBarStyle.shadowboolean-Shadow of the search barwelcomeMessagestring"Hi, how can I help you?"Welcome messagecmdShortcutKeystring"k"Define the short cut for users to open mendable with. By default, it is CMD + K or CTRl + KbotIconobjectBot EmojiReact: Bot icon HTML tag, can be a img, svg or any other HTML tag, Vanilla JS: image urluserIconobjectUser EmojiReact: User icon HTML tag, can be a img, svg or any other HTML tag, Vanilla JS: image urlshowSimpleSearchbooleanfalseShow simple search bar option on the topaskAITextstring"Ask Mendable AI"Text for the ask AI button on the keyword search componentpositionOverwriteClassnamestring-Classname that helps overwrite the position of the floating buttonmessageSettings.openSourcesInNewTabbooleanfalseOpen sources in new tabmessageSettings.prettySourcesbooleanfalseDisplay the sources by title / sub-section instead of long URLmessageSettings.hideSourcesbooleanfalseHide the sourcesprivacyDisclaimerstring" "Privacy disclaimer textinputSettingsobject-Input settingsinputSettings?.askButtonStyleobject-Ask button style objectinputSettings?.askButtonStyle.activeColorstring"#123456"Ask button background color when activeinputSettings?.askButtonStyle.disabledColorstring"#123456"Ask button color on a disabled stateinputSettings?.askButtonStyle.textColorstring"#123456"Ask button text colorinputSettings?.askButtonStyle.disabledTextColorstring"#123456"Ask button text color on a disabled statefooterobject-Footer objectfooter.bottomRightLinkobject-Bottom right button objectfooter.bottomRightLink.labelstring""Text label for the bottom right buttonfooter.bottomRightLink.linkstring""URL for the bottom right buttonlanguagestring""Defaults to user's personal settings. Anything else will overwrite the language for all users. Languages available: pt,es,fr,it,nl,de,ja,aronMessageForTrackingfunction-Callback function that triggers when a message is sent. It receives the question, answer and sources as parametersonSourceClickedForTrackingfunction-Callback function that triggers when a source is clicked. It receives the source as a parameteronSwitchingSearchTypefunction-Callback function that triggers when the search type is switched. It receives the type as a parameteronRateClickedfunction-Callback function that triggers when the user likes or dislikes a message. It receives the isLiked, question, answer and sources as parametersCallback functionsThe Mendable Search Bar provides callback functions for tracking events inside the component.onMessageForTracking : This function is triggered whenever a message is sent in the component. The function receives the question and the answer as parameters. This can be used for logging or analytics purposes.Exampleimport MendableSearchBar from 'mendable-search-bar';

function MySearchComponent() {
  const handleOnMessage = (question, answer, sources) => {
    console.log("User asked:", question);
    console.log("Received answer:", answer);
    console.log("Sources:", sources);
    // You can add additional tracking or analytics logic here.
  };

  return (
    <MendableSearchBar
      anon_key="YOUR_ANON_KEY"
      onMessageForTracking={handleOnMessage}
    />
  );
}
onSourceClickedForTracking : This function is triggered whenever a source is clicked in the search results. The function receives the source as a parameter. This can be used for logging or tracking user interactions.Exampleimport MendableSearchBar from 'mendable-search-bar';

function handleOnSourceClicked(source) {
  console.log("User clicked on source:", source);
  // Add tracking or logging logic here
}

<MendableSearchBar
  anon_key='YOUR_ANON_KEY'
  onSourceClickedForTracking={handleOnSourceClicked}
/>
Use these functions to gain insights into how users are interacting with the search bar.Previous← Vanilla JSNextFloating Button →On this pageMendable Search BarUsageKeyword SearchPropsCallback functionsExampleExample 
 [END SOURCE]

[START SOURCE] 
 Integrate with Docusaurus - DocsSearch...CTRLKChangelogThemeIntroductionGetting startedInstallationIngesting your docsPrompt CustomizationShowcaseIntegration GuidesProduct copilotsDiscord AI BotSlack AI BotDocusaurusWordPressAPIOverviewConceptsData IngestionManaging DataConversationChatMessage RatingExport DataComponentsOverviewVanilla JSSearch BarFloating ButtonIn PlaceChat BubbleSDKsPythonIntegration GuidesIntegrate with DocusaurusBefore install, make sure you have either signed up through our platform or we have provided you with the ANON_KEY. Without the key, you won't be able to setup the search component.InstallationInstalling Mendable Searchnpm install @mendable/search
ConfigurationIn the docusaurus.config.js file, add the following:customFields:{
    mendableAnonKey: "YOUR_ANON_KEY",
},
Install and run swizzle commandnpm i swizzle
Select the theme you'd like to swizzle. Normally it is the first option it appears.If you'd like to implement the Search Bar Component, select the SearchBar, otherwise for the Floating Button, select the Footer.Once you run swizzle, you will be prompted to either wrap or eject the component. Select eject from the menu as it is a safer option.Search Bar ComponentReplace or edit your src/theme/SearchBar.js with the code below. In this example we are using the Mendable Search Bar. .import React from 'react'
import { MendableSearchBar } from '@mendable/search'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'

export default function SearchBarWrapper() {
  const {
    siteConfig: { customFields },
  } = useDocusaurusContext()
  return (
    <div className="mendable-search">
      <MendableSearchBar
        anon_key={customFields.mendableAnonKey}
        style={{ accentColor: '#179C54', darkMode: false }}
        placeholder="Search..."
        dialogPlaceholder="How to deploy this application?"
      />
    </div>
  )
}
Floating Button ComponentReplace or edit your src/theme/Footer.js with the code below. In this example we are using the Mendable Floating Button.import React from 'react'
import Footer from '@theme-original/Footer'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import { MendableFloatingButton } from '@mendable/search'

export default function FooterWrapper(props) {
  const {
    siteConfig: { customFields },
  } = useDocusaurusContext()

  return (
    <>
      <MendableFloatingButton anon_key={customFields.mendableAnonKey} />
      <Footer {...props} />
    </>
  )
}
Keyword SearchWe also provide keyword search as seen on the Langchain Documentation. This combines keyword with AI Search in one modal. When the user starts typing, it will almost instantly display results for the search query. It also allows the user to use AI search by pressing "Ask Mendable AI".To enable keyword search, you need to pass the showSimpleSearch prop to the component.import { MendableSearchBar } from "@mendable/search"

<MendableSearchBar anon_key='YOUR_ANON_KEY' showSimpleSearch />
Additional customization (Optional)In some Docusaurus websites, the UI might get too busy in when viewing in mobile, so we recommend you to reduce the width of the search bar in mobile view. In the src/css/custom.css file, add the following:/* Reduce width on mobile for Mendable Search */
@media (max-width: 767px) {
  .mendable-search {
    width: 200px;
  }
}

@media (max-width: 500px) {
  .mendable-search {
    width: 150px;
  }
}

@media (max-width: 380px) {
  .mendable-search {
    width: 140px;
  }
}
Previous← Slack AI BotNextWordPress →On this pageInstallationInstalling Mendable SearchConfigurationInstall and run swizzle commandSearch Bar ComponentFloating Button ComponentKeyword SearchAdditional customization (Optional) 
 [END SOURCE]
[END VERIFIED SOURCES]

[Previous Messages (If any)]

human: what is mendable
ai: Mendable is a platform that provides chat-powered search through components. It allows you to provide detailed, accurate, and contextually relevant answers to your customers' questions based on your documentation. Mendable also offers an API where it can be used to integrate Mendable's ingestion and completion capabilities into your own applications. 

Mendable has 4 main components:
1. Mendable Search Bar: A component similar to a search bar input. When the user clicks the search bar, it will open a modal with Mendable Search.
2. Mendable Floating Button: A fixed button to the bottom right of the screen that will open a modal with Mendable Search.
3. Mendable InPlace Component: This component is the Mendable Chat only, does not include an activation component or dialog transitions, making it easy for you to create your own activations on top of it.
4. Mendable Chat Bubble: A fixed button to the bottom right of the screen that will open a modal with Mendable Search. It is similar to the floating button, but it is a small bubble that will expand when the user clicks on it.

Mendable also provides a Python SDK for interacting with its API. The SDK supports features like ingesting data sources and asking questions. 

In addition, Mendable offers a variety of parameters to customize your requests through its API. You can also provide conversation history to maintain context and improve the quality of the AI's responses.

[ACTUAL QUESTION BASED ON VERIFIED SOURCES AND PREVIOUS MESSAGES]:
how do i use the search bar

Begin!

Dynamic Variables

Mendable's custom prompt interface provides a variety of dynamic variables that can be integrated into a prompt to tailor and enhance its functionality. None of these variables are required for Mendable to work!

{company}

Usage: This variable is designed to represent the name of the company or organization that the user is associated with. It is set based on your organization name in Mendable. By integrating the {company} variable, the generated response will include the specific company name, ensuring that answers are personalized and contextually relevant to the user's organization.

{additional_context}

Usage:The {additional_context} variable provides extra information or context that can aid in generating a more precise and accurate response. You can send additional context via the API or the component. It can contain background data, supplementary details, or any other information that should be considered when formulating a response.

{retrieved_data}

Usage: This variable contains the verified sources that the system can use to extract and base its answers on. Enclosed between [START VERIFIED SOURCES] and [END VERIFIED SOURCES], it ensures that the generated responses are rooted in trustworthy and verifiable data.

{history}

Usage: The {history} variable provides access to previous interactions or messages in the ongoing conversation. By referring to {history}, the system can generate responses that are consistent with previous answers and can maintain context throughout the conversation. This ensures continuity and relevance in prolonged interactions.

{question}

Usage: This dynamic variable is pivotal as it drives the main content of the response, it is the user input. It tells the system what the user wants to know based on verified sources and previous messages, ensuring that the answer is directly aligned with the user's intent. You do not have to use it as a "question" but in most cases it is used in this way.

{support_prompt_addition}

Usage: If the system cannot find an answer within the verified sources but can provide some support based on previous interactions, it can use {support_prompt_addition} to append customer service link set in the dashboard to the prompt.

Prompt Templates

To streamline the process, especially for common use cases, we provide prompt templates. These preformatted prompts are optimized for specific scenarios and require minimal adjustments.

Using a Template

Select a Template: In the 'Prompt Templates' section, you can browse through various pre-constructed prompts designed for diverse use cases.

  • Precise Mode: By default, the model uses the 'Precise Mode' prompt template. This template is crafted to generate the most relevant and concise responses. It's particularly useful for straightforward questions or when looking for specific information.

  • Normal Mode: This template is crafted to generate answers that use the verified sources and the models external knowledge. It's particularly useful for creative exercises like code generation.

  • Customize as Needed: While these templates are ready to use, you can further customize them to suit your specific needs. Feel free to add any of the dynamic variables or additional context to make the prompt more applicable to your situation.

Previous
Ingesting your docs