Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vector store driver docs #1508

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?")
Loading