Skip to content

Commit

Permalink
docs: Update PineconeStore creation to include namespace parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin-chaurasiya committed Jul 22, 2024
1 parent d3c913f commit 41b4cac
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
12 changes: 11 additions & 1 deletion docs/core_docs/docs/how_to/qa_per_user.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,19 @@
"\n",
"const pineconeIndex = pinecone.Index(Deno.env.get(\"PINECONE_INDEX\"));\n",
"\n",
"/**\n",
" * Pinecone allows you to partition the records in an index into namespaces. \n",
" * Queries and other operations are then limited to one namespace, \n",
" * so different requests can search different subsets of your index.\n",
" * Read more about namespaces here: https://docs.pinecone.io/guides/indexes/use-namespaces\n",
" * \n",
" * NOTE: If you have namespace enabled in your Pinecone index, you must provide the namespace when creating the PineconeStore.\n",
" */\n",
"const namespace = \"pinecone\";\n",
"\n",
"const vectorStore = await PineconeStore.fromExistingIndex(\n",
" new OpenAIEmbeddings(),\n",
" { pineconeIndex },\n",
" { pineconeIndex, namespace },\n",
");\n",
"\n",
"await vectorStore.addDocuments(\n",
Expand Down
12 changes: 11 additions & 1 deletion examples/src/indexes/vector_stores/pinecone/mmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ const pinecone = new Pinecone();

const pineconeIndex = pinecone.Index(process.env.PINECONE_INDEX!);

/**
* Pinecone allows you to partition the records in an index into namespaces.
* Queries and other operations are then limited to one namespace,
* so different requests can search different subsets of your index.
* Read more about namespaces here: https://docs.pinecone.io/guides/indexes/use-namespaces
*
* NOTE: If you have namespace enabled in your Pinecone index, you must provide the namespace when creating the PineconeStore.
*/
const namespace = "pinecone";

const vectorStore = await PineconeStore.fromExistingIndex(
new OpenAIEmbeddings(),
{ pineconeIndex }
{ pineconeIndex, namespace }
);

/* Search the vector DB independently with meta filters */
Expand Down
12 changes: 11 additions & 1 deletion examples/src/indexes/vector_stores/pinecone/query_docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ const pinecone = new Pinecone();

const pineconeIndex = pinecone.Index(process.env.PINECONE_INDEX!);

/**
* Pinecone allows you to partition the records in an index into namespaces.
* Queries and other operations are then limited to one namespace,
* so different requests can search different subsets of your index.
* Read more about namespaces here: https://docs.pinecone.io/guides/indexes/use-namespaces
*
* NOTE: If you have namespace enabled in your Pinecone index, you must provide the namespace when creating the PineconeStore.
*/
const namespace = "pinecone";

const vectorStore = await PineconeStore.fromExistingIndex(
new OpenAIEmbeddings(),
{ pineconeIndex }
{ pineconeIndex, namespace }
);

/* Search the vector DB independently with metadata filters */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ const pinecone = new Pinecone();

const pineconeIndex = pinecone.Index(process.env.PINECONE_INDEX!);

/**
* Pinecone allows you to partition the records in an index into namespaces.
* Queries and other operations are then limited to one namespace,
* so different requests can search different subsets of your index.
* Read more about namespaces here: https://docs.pinecone.io/guides/indexes/use-namespaces
*
* NOTE: If you have namespace enabled in your Pinecone index, you must provide the namespace when creating the PineconeStore.
*/
const namespace = "pinecone";

const pineconeVectorstore = await PineconeStore.fromExistingIndex(
new OpenAIEmbeddings(),
{ pineconeIndex }
{ pineconeIndex , namespace }
);

const pineconeMmrRetriever = pineconeVectorstore.asRetriever({
Expand Down

0 comments on commit 41b4cac

Please sign in to comment.