Skip to content

Commit

Permalink
updated README and removed unused code (#54)
Browse files Browse the repository at this point in the history
* updated README and removed unused code

* fixed corpus key bug
  • Loading branch information
adeelehsan authored Jul 24, 2024
1 parent 86ef8d7 commit 43f01d6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 49 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import { ReactChatbot } from "@vectara/react-chatbot";

<ReactChatbot
customerId="CUSTOMER_ID"
corpusKeys={["CORPUS_KEY_1", "CORPUS_KEY_2", "CORPUS_KEY_N"]}
corpusKeys={"CORPUS_KEY_1,CORPUS_KEY_2,CORPUS_KEY_N"}
apiKey="API_KEY"
title="My Chatbot"
placeholder="Chat with your AI assistant"
Expand Down Expand Up @@ -163,7 +163,7 @@ import { useChat } from "@vectara/react-chatbot/lib/useChat";
const { sendMessage, activeMessage, messageHistory, isLoading, isStreamingResponse, hasError, startNewConversation } =
useChat({
customerId: "CUSTOMER_ID",
corpusIds: ["CORPUS_ID_1", "CORPUS_ID_2", "CORPUS_ID_N"],
corpusKeys: "CORPUS_ID_1,CORPUS_ID_2,CORPUS_ID_N",
apiKey: "API_KEY",
enableStreaming: true, // Enable streaming, false otherwise. Defaults to true.
language: "fra" // Response language. Defaults to "eng" for English. See our types for more information.
Expand Down Expand Up @@ -231,7 +231,7 @@ export const App = (props: Props): ReactNode => {
setChatWidget(
<ReactChatbot
customerId="CUSTOMER_ID"
corpusKeys={["CORPUS_KEY_1", "CORPUS_KEY_2", "CORPUS_KEY_N"]}
corpusKeys={"CORPUS_KEY_1,CORPUS_KEY_2,CORPUS_KEY_N"}
apiKey="API_KEY"
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/ConfigurationDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const ConfigurationDrawer = ({

<VuiSpacer size="m" />

<VuiFormGroup label="Corpus Key" labelFor="corpusId">
<VuiFormGroup label="Corpus Key" labelFor="corpusKey">
<VuiTextInput value={corpusKeys} onChange={onUpdateCorpusKeys} />
</VuiFormGroup>

Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const App = () => {
const [placeholder, setPlaceholder] = useState<string>(DEFAULT_PLACEHOLDER);
const [inputSize, setInputSize] = useState<"large" | "medium">("large");
const [isStreamingEnabled, setIsStreamingEnabled] = useState<boolean>(true);
const [numberOfSearchResults, setNumberOfSearchResults] = useState<number>(15);
const [numberOfSearchResults, setNumberOfSearchResults] = useState<number>(10);
const [language, setLanguage] = useState<SummaryLanguage>("eng");
const [emptyStateJsx, setEmptyStateJsx] = useState<string>("");
const [exampleQuestions, setExampleQuestions] = useState<string>("What is Vectara?, How does RAG work?");
Expand Down Expand Up @@ -308,7 +308,7 @@ export const App = () => {
corpusKeys: DEFAULT_CORPUS_KEY,
apiKey: DEFAULT_API_KEY,
enableStreaming: true, // Enable streaming, false otherwise. Defaults to true.
numberOfSearchResults: 15, // Number of search results to use for summary.
numberOfSearchResults: 10, // Number of search results to use for summary.
language: "fra" // Response language. Defaults to "eng" for English.
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vectara/react-chatbot",
"version": "3.0.0",
"version": "3.0.1",
"description": "A Vectara-powered Chatbot component",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down
9 changes: 3 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ReactChatbotWebComponent extends HTMLElement {

public connectedCallback() {
const customerId = this.getAttribute("customerId") ?? "";
const corpusKeys = (this.getAttribute("corpuskey") ?? "");
const corpusKeys = (this.getAttribute("corpuskeys") ?? "");
const apiKey = this.getAttribute("apiKey") ?? "";
const title = this.getAttribute("title") ?? undefined;
const placeholder = this.getAttribute("placeholder") ?? undefined;
Expand All @@ -88,6 +88,7 @@ class ReactChatbotWebComponent extends HTMLElement {
const enableStreaming =
this.getAttribute("enableStreaming") !== null ? this.getAttribute("enableStreaming") == "true" : undefined;

console.log(corpusKeys)
ReactDOM.render(
<div>
<ChatView
Expand Down Expand Up @@ -138,11 +139,7 @@ export const ReactChatbot = (props: Props) => {
const typedProps = props as Record<string, any>;
const updatedProps = Object.keys(props).reduce((acc: Record<string, string>, propName: string) => {
if (propName === "emptyStateDisplay") return acc;
if (propName === "corpusIds") {
acc[propName] = typedProps["corpusIds"].join(" ");
} else {
acc[propName] = typedProps[propName];
}
acc[propName] = typedProps[propName];

return acc;
}, {});
Expand Down
36 changes: 0 additions & 36 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,6 @@ export type SearchResultWithSnippet = SearchResult & {
};
};



export type DocMetadata = {
name: string;
value: string;
};

export type SearchResponse = {
document: SearchResponseDoc[];
response: SearchResponseResult[];
summary: SearchResponseSummary[];
};

type SearchResponseDoc = {
id: string;
metadata: DocMetadata[];
};

type SearchResponseResult = {
corpusKey: {
corpusId: string;
customerId: string;
dim: string[];
};
documentIndex: string;
resultLength: number;
resultOffset: number;
score: number;
text: string;
};

type SearchResponseSummary = {
text?: string;
status?: string;
};

export const SUMMARY_LANGUAGES = [
"auto",
"eng",
Expand Down

0 comments on commit 43f01d6

Please sign in to comment.