Skip to content

Commit

Permalink
Fix vector store driver docs (#1508)
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter authored Jan 6, 2025
1 parent 20fa760 commit 2d33f89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions docs/griptape-framework/drivers/src/vector_store_drivers_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -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]

Expand Down
11 changes: 6 additions & 5 deletions docs/griptape-tools/official-tools/src/vector_store_tool_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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?")

0 comments on commit 2d33f89

Please sign in to comment.