diff --git a/README.md b/README.md
index 400f264..b340263 100644
--- a/README.md
+++ b/README.md
@@ -133,6 +133,10 @@ When set, this will calculate the [Factual Consistency Score (FCS)](https://docs
Define the [summarizer and prompt](https://docs.vectara.com/docs/learn/grounded-generation/select-a-summarizer) to use to generate the chat response.
+##### `customPrompt` (optional)
+
+Define the [custom prompt](https://docs.vectara.com/docs/prompts/vectara-prompt-engine) to use to generate the chat response.
+
##### `numberOfSearchResults` (optional)
Define the number of search results to be used to generate summary. Default is set to 15.
diff --git a/docs/package-lock.json b/docs/package-lock.json
index 061ea86..2888e77 100644
--- a/docs/package-lock.json
+++ b/docs/package-lock.json
@@ -14,7 +14,7 @@
},
"..": {
"name": "@vectara/react-chatbot",
- "version": "3.0.1",
+ "version": "3.1.0",
"license": "Apache-2.0",
"dependencies": {
"@types/react": "^17.0.0",
@@ -24,7 +24,6 @@
"lodash": "^4.17.21",
"prismjs": "^1.29.0",
"react-focus-on": "^3.9.1",
- "react-markdown": "^8.0.6",
"uuid-by-string": "^4.0.0"
},
"devDependencies": {
@@ -108,7 +107,6 @@
"react-focus-on": "^3.9.1",
"react-icons": "^5.0.1",
"react-jsx-parser": "^1.29.0",
- "react-markdown": "^8.0.6",
"react-router-dom": "^6.8.2",
"rimraf": "^5.0.5",
"shadow-dom-testing-library": "^1.11.2",
diff --git a/docs/src/components/ConfigurationDrawer.tsx b/docs/src/components/ConfigurationDrawer.tsx
index 7139df1..9144af7 100644
--- a/docs/src/components/ConfigurationDrawer.tsx
+++ b/docs/src/components/ConfigurationDrawer.tsx
@@ -45,6 +45,8 @@ type Props = {
onUpdateEnableFactualConsistencyScore: (enableFactualConsistencyScore: boolean) => void;
summaryPromptName: string;
onUpdateSummaryPromptName: (summaryPromptName: string) => void;
+ customPrompt: string;
+ onUpdateCustomPrompt: (customPrompt: string) => void;
rerankerId: RerankerId;
onUpdateRerankerId: (rerankerId: RerankerId) => void;
lambda: number;
@@ -80,6 +82,8 @@ export const ConfigurationDrawer = ({
onUpdateEnableFactualConsistencyScore,
summaryPromptName,
onUpdateSummaryPromptName,
+ customPrompt,
+ onUpdateCustomPrompt,
rerankerId,
onUpdateRerankerId,
lambda,
@@ -234,6 +238,12 @@ export const ConfigurationDrawer = ({
+
+ onUpdateCustomPrompt(e.target.value)} fullWidth />
+
+
+
+
onUpdateRerankerId(rerankerId as RerankerId)} />
diff --git a/docs/src/index.tsx b/docs/src/index.tsx
index 007dca4..41cf3e5 100644
--- a/docs/src/index.tsx
+++ b/docs/src/index.tsx
@@ -51,7 +51,8 @@ const generateCodeSnippet = (
exampleQuestions?: string,
rerankerId?: RerankerId,
lambda?: number,
- isStreamingEnabled?: boolean
+ isStreamingEnabled?: boolean,
+ customPrompt?: string,
) => {
const props = [
`customerId="${customerId === "" ? "" : customerId}"`,
@@ -87,6 +88,7 @@ const generateCodeSnippet = (
props.push(`enableStreaming={${isStreamingEnabled}}`);
props.push(`numberOfSearchResultsForSummary={${numberOfSearchResults}}`);
+ props.push(`customPrompt="${customPrompt}"`)
props.push(`language="${language}"`);
props.push(`rerankerId=${rerankerId}`);
props.push(`lambda=${lambda}`);
@@ -127,6 +129,7 @@ const App = () => {
const [exampleQuestions, setExampleQuestions] = useState("What is Vectara?, How does RAG work?");
const [enableFactualConsistencyScore, setEnableFactualConsistencyScore] = useState(false);
const [summaryPromptName, setSummaryPromptName] = useState(DEFAULT_SUMMARIZER);
+ const [customPrompt, setCustomPrompt] = useState("");
const [rerankerId, setRerankerId] = useState(DEFAULT_RERANKER_ID);
const [lambda, setLambda] = useState(DEFAULT_LAMBDA_VALUE);
@@ -232,6 +235,7 @@ const App = () => {
language={language}
enableFactualConsistencyScore={enableFactualConsistencyScore}
summaryPromptName={summaryPromptName}
+ customPrompt={customPrompt}
rerankerId={rerankerId}
lambda={lambda}
enableStreaming={isStreamingEnabled}
@@ -410,6 +414,8 @@ export const App = () => {
onUpdateEnableFactualConsistencyScore={setEnableFactualConsistencyScore}
summaryPromptName={summaryPromptName}
onUpdateSummaryPromptName={setSummaryPromptName}
+ customPrompt={customPrompt}
+ onUpdateCustomPrompt={setCustomPrompt}
rerankerId={rerankerId}
onUpdateRerankerId={setRerankerId}
lambda={lambda}
diff --git a/package-lock.json b/package-lock.json
index 47be292..509d50c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@vectara/react-chatbot",
- "version": "3.0.1",
+ "version": "3.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@vectara/react-chatbot",
- "version": "3.0.1",
+ "version": "3.1.0",
"license": "Apache-2.0",
"dependencies": {
"@types/react": "^17.0.0",
diff --git a/package.json b/package.json
index 24a31a6..d0157c0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@vectara/react-chatbot",
- "version": "3.1.0",
+ "version": "3.2.0",
"description": "A Vectara-powered Chatbot component",
"main": "lib/index.js",
"module": "lib/index.js",
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index 6c12e67..08150b4 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -64,6 +64,9 @@ export interface Props {
// Defines the name of the summary prompt. Defaults to "vectara-summary-ext-v1.2.0".
summaryPromptName?: string;
+ // Define custom prompt
+ customPrompt?: string;
+
// Define the reranker Id to be used , Defaults to "272725718"
rerankerId?: RerankerId;
@@ -102,6 +105,7 @@ export const ChatView = ({
language = "eng",
enableFactualConsistencyScore,
summaryPromptName,
+ customPrompt,
rerankerId,
lambda,
enableStreaming = true,
@@ -119,6 +123,7 @@ export const ChatView = ({
language,
enableFactualConsistencyScore,
summaryPromptName,
+ customPrompt,
rerankerId,
lambda,
enableStreaming,
diff --git a/src/index.tsx b/src/index.tsx
index 533bd8c..dbef92a 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -92,6 +92,7 @@ class ReactChatbotWebComponent extends HTMLElement {
const language = (this.getAttribute("language") as SummaryLanguage) ?? undefined;
const enableFactualConsistencyScore = this.getAttribute("enableFactualConsistencyScore") === "true";
const summaryPromptName = this.getAttribute("summaryPromptName") ?? undefined;
+ const customPrompt = this.getAttribute("customPrompt") ?? undefined;
const rerankerId =
this.getAttribute("rerankerId") !== null ? parseInt(this.getAttribute("rerankerId")!, 10) : undefined;
const lambda = this.getAttribute("lambda") !== null ? parseFloat(this.getAttribute("lambda")!) : undefined;
@@ -118,6 +119,7 @@ class ReactChatbotWebComponent extends HTMLElement {
language={language}
enableFactualConsistencyScore={enableFactualConsistencyScore}
summaryPromptName={summaryPromptName}
+ customPrompt={customPrompt}
rerankerId={rerankerId as RerankerId}
lambda={lambda}
agenticConfiguration={agenticConfiguration}
diff --git a/src/useChat.ts b/src/useChat.ts
index 4d13a1a..4bb10ba 100644
--- a/src/useChat.ts
+++ b/src/useChat.ts
@@ -42,6 +42,7 @@ type UseChatConfig = {
language?: SummaryLanguage;
enableFactualConsistencyScore?: boolean;
summaryPromptName?: string;
+ customPrompt?: string
rerankerId?: number;
lambda?: number;
enableStreaming?: boolean;
@@ -60,6 +61,7 @@ export const useChat = ({
language = "eng",
enableFactualConsistencyScore,
summaryPromptName = DEFAULT_SUMMARIZER,
+ customPrompt = undefined,
rerankerId = DEFAULT_RERANKER_ID,
lambda = DEFAULT_LAMBDA_VALUE,
enableStreaming = true,
@@ -296,7 +298,8 @@ export const useChat = ({
generationPresetName: summaryPromptName,
maxUsedSearchResults: numberOfSearchResults,
enableFactualConsistencyScore: enableFactualConsistencyScore,
- responseLanguage: language
+ responseLanguage: language,
+ promptTemplate: customPrompt
}
};