From 2d33f8924f4eb9a2db0c6c7f2d9a19dd1300d4f0 Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Mon, 6 Jan 2025 10:42:08 -0800 Subject: [PATCH] Fix vector store driver docs (#1508) --- .../drivers/src/vector_store_drivers_3.py | 6 ++++-- .../official-tools/src/vector_store_tool_1.py | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/griptape-framework/drivers/src/vector_store_drivers_3.py b/docs/griptape-framework/drivers/src/vector_store_drivers_3.py index d84164cb4..60af6f197 100644 --- a/docs/griptape-framework/drivers/src/vector_store_drivers_3.py +++ b/docs/griptape-framework/drivers/src/vector_store_drivers_3.py @@ -4,6 +4,8 @@ from griptape.drivers import OpenAiEmbeddingDriver, PineconeVectorStoreDriver from griptape.loaders import WebLoader +NAMESPACE = "griptape" + # Initialize an Embedding Driver embedding_driver = OpenAiEmbeddingDriver(api_key=os.environ["OPENAI_API_KEY"]) @@ -19,9 +21,9 @@ chunks = TextChunker(max_tokens=100).chunk(artifact) # Upsert Artifacts into the Vector Store Driver -vector_store_driver.upsert_text_artifacts({"griptape": chunks}) +vector_store_driver.upsert_text_artifacts({NAMESPACE: chunks}) -results = vector_store_driver.query(query="What is griptape?") +results = vector_store_driver.query(query="What is griptape?", namespace=NAMESPACE) values = [r.to_artifact().value for r in results] diff --git a/docs/griptape-tools/official-tools/src/vector_store_tool_1.py b/docs/griptape-tools/official-tools/src/vector_store_tool_1.py index bdb60d98b..d71268261 100644 --- a/docs/griptape-tools/official-tools/src/vector_store_tool_1.py +++ b/docs/griptape-tools/official-tools/src/vector_store_tool_1.py @@ -2,7 +2,9 @@ from griptape.drivers import LocalVectorStoreDriver, OpenAiEmbeddingDriver from griptape.loaders import WebLoader from griptape.structures import Agent -from griptape.tools import PromptSummaryTool, VectorStoreTool +from griptape.tools import VectorStoreTool + +NAMESPACE = "griptape" vector_store_driver = LocalVectorStoreDriver( embedding_driver=OpenAiEmbeddingDriver(), @@ -11,14 +13,13 @@ artifacts = WebLoader().load("https://www.griptape.ai") chunks = TextChunker().chunk(artifacts) -vector_store_driver.upsert_text_artifacts({"griptape": chunks}) +vector_store_driver.upsert_text_artifacts({NAMESPACE: chunks}) vector_db = VectorStoreTool( description="This DB has information about the Griptape Python framework", vector_store_driver=vector_store_driver, - query_params={"namespace": "griptape"}, - off_prompt=True, + query_params={"namespace": NAMESPACE}, ) -agent = Agent(tools=[vector_db, PromptSummaryTool()]) +agent = Agent(tools=[vector_db]) agent.run("what is Griptape?")