Skip to content

Commit

Permalink
updated documentation (langchain-ai#2785)
Browse files Browse the repository at this point in the history
added X-Source to header
ofermend authored Oct 4, 2023
1 parent 2c94d0c commit 347c839
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ const store = await VectaraStore.fromTexts(

You'll need to:

- Create a [free Vectara account](https://console.vectara.com/signup).
- Create a [free Vectara account](https://vectara.com/integrations/langchain).
- Create a [corpus](https://docs.vectara.com/docs/console-ui/creating-a-corpus) to store your data
- Create an [API key](https://docs.vectara.com/docs/common-use-cases/app-authn-authz/api-keys) with QueryService and IndexService access so you can access this corpus

7 changes: 7 additions & 0 deletions langchain/src/vectorstores/vectara.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ export interface VectaraLibArgs {
corpusId: number | number[];
apiKey: string;
verbose?: boolean;
source?: string;
}

/**
@@ -23,6 +24,7 @@ interface VectaraCallHeader {
"x-api-key": string;
"Content-Type": string;
"customer-id": string;
"X-Source": string;
};
}

@@ -94,6 +96,8 @@ export class VectaraStore extends VectorStore {

private verbose: boolean;

private source: string;

private vectaraApiTimeoutSeconds = 60;

_vectorstoreType(): string {
@@ -110,6 +114,7 @@ export class VectaraStore extends VectorStore {
throw new Error("Vectara api key is not provided.");
}
this.apiKey = apiKey;
this.source = args.source ?? "langchainjs";

const corpusId =
args.corpusId ??
@@ -153,6 +158,7 @@ export class VectaraStore extends VectorStore {
"x-api-key": this.apiKey,
"Content-Type": "application/json",
"customer-id": this.customerId.toString(),
"X-Source": this.source,
},
};
}
@@ -275,6 +281,7 @@ export class VectaraStore extends VectorStore {
method: "POST",
headers: {
"x-api-key": this.apiKey,
"X-Source": this.source,
},
body: data,
}

0 comments on commit 347c839

Please sign in to comment.