-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8648aeb
commit 4d71d3a
Showing
316 changed files
with
5,118 additions
and
5,089 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,3 @@ | ||
```python | ||
import hashlib | ||
import os | ||
import json | ||
from urllib.request import urlopen | ||
from griptape.drivers import PineconeVectorStoreDriver, OpenAiEmbeddingDriver | ||
|
||
def load_data(driver: PineconeVectorStoreDriver) -> None: | ||
response = urlopen( | ||
"https://raw.githubusercontent.com/wedeploy-examples/" | ||
"supermarket-web-example/master/products.json" | ||
) | ||
|
||
for product in json.loads(response.read()): | ||
driver.upsert_text( | ||
product["description"], | ||
vector_id=hashlib.md5(product["title"].encode()).hexdigest(), | ||
meta={ | ||
"title": product["title"], | ||
"description": product["description"], | ||
"type": product["type"], | ||
"price": product["price"], | ||
"rating": product["rating"], | ||
}, | ||
namespace="supermarket-products", | ||
) | ||
|
||
vector_driver = PineconeVectorStoreDriver( | ||
api_key=os.environ["PINECONE_API_KEY"], | ||
environment=os.environ["PINECONE_ENVIRONMENT"], | ||
index_name=os.environ["PINECONE_INDEX_NAME"], | ||
embedding_driver=OpenAiEmbeddingDriver() | ||
) | ||
|
||
load_data(vector_driver) | ||
|
||
result = vector_driver.query( | ||
"fruit", | ||
count=3, | ||
filter={"price": {"$lte": 15}, "rating": {"$gte": 4}}, | ||
namespace="supermarket-products", | ||
) | ||
print(result) | ||
--8<-- "docs/examples/src/load_and_query_pinecone_1.py" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,3 @@ | ||
```python title="PYTEST_IGNORE" | ||
import os | ||
from griptape import utils | ||
from griptape.drivers import MarqoVectorStoreDriver | ||
from griptape.loaders import WebLoader | ||
from griptape.structures import Agent | ||
from griptape.tools import VectorStoreClient | ||
from griptape.drivers import OpenAiEmbeddingDriver | ||
|
||
# Define the namespace | ||
namespace = "griptape-ai" | ||
|
||
# # Initialize the vector store driver | ||
vector_store = MarqoVectorStoreDriver( | ||
api_key=os.environ["MARQO_API_KEY"], | ||
url=os.environ["MARQO_URL"], | ||
index=os.environ["MARQO_INDEX_NAME"], | ||
embedding_driver=OpenAiEmbeddingDriver() | ||
) | ||
|
||
# Initialize the knowledge base tool | ||
vector_store_tool = VectorStoreClient( | ||
description="Contains information about the Griptape Framework from www.griptape.ai", | ||
namespace=namespace, | ||
vector_store_driver=vector_store | ||
) | ||
|
||
# Load artifacts from the web | ||
artifacts = WebLoader().load("https://www.griptape.ai") | ||
|
||
# Upsert the artifacts into the vector store | ||
vector_store.upsert_text_artifacts( | ||
{ | ||
namespace: artifacts, | ||
} | ||
) | ||
|
||
# Initialize the agent | ||
agent = Agent(tools=[vector_store_tool]) | ||
|
||
# Start the chat | ||
utils.Chat(agent).start() | ||
```python | ||
--8<-- "docs/examples/src/load_query_and_chat_marqo_1.py" | ||
``` |
Oops, something went wrong.