generated from The-Swarm-Corporation/Multi-Agent-Template-App
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from radekdymacz/singlestore
- Loading branch information
Showing
9 changed files
with
933 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
# Pinecone Configuration | ||
PINECONE_API_KEYS="your_pinecone_api_key" | ||
BASE_SWARMS_MEMORY_URL="http:" | ||
|
||
# Base URL Configuration | ||
BASE_SWARMS_MEMORY_URL="http:" | ||
|
||
# SingleStore Configuration | ||
# Host can be localhost for local development or your SingleStore deployment URL | ||
SINGLESTORE_HOST="your_singlestore_host" # e.g., "localhost" or "svc-123-xyz.aws.singlestore.com" | ||
|
||
# Default port is 3306, but might be different for your deployment | ||
SINGLESTORE_PORT="3306" | ||
|
||
# Your SingleStore user credentials | ||
SINGLESTORE_USER="your_singlestore_username" # e.g., "admin" | ||
SINGLESTORE_PASSWORD="your_singlestore_password" | ||
|
||
# Database name where vector tables will be created | ||
SINGLESTORE_DATABASE="your_database_name" # e.g., "vector_store" |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
from dotenv import load_dotenv | ||
from swarms_memory.vector_dbs.singlestore_wrapper import SingleStoreDB | ||
|
||
# Load environment variables | ||
load_dotenv() | ||
|
||
def main(): | ||
# Initialize SingleStore with environment variables | ||
db = SingleStoreDB( | ||
host=os.getenv("SINGLESTORE_HOST"), | ||
port=int(os.getenv("SINGLESTORE_PORT", "3306")), | ||
user=os.getenv("SINGLESTORE_USER"), | ||
password=os.getenv("SINGLESTORE_PASSWORD"), | ||
database=os.getenv("SINGLESTORE_DATABASE"), | ||
table_name="example_vectors", | ||
dimension=768, # Default dimension for all-MiniLM-L6-v2 | ||
namespace="example" | ||
) | ||
|
||
# Example documents | ||
documents = [ | ||
"SingleStore is a distributed SQL database that combines the horizontal scalability of NoSQL systems with the ACID guarantees of traditional RDBMSs.", | ||
"Vector similarity search in SingleStore uses DOT_PRODUCT distance type for efficient nearest neighbor queries.", | ||
"SingleStore supports both row and column store formats, making it suitable for both transactional and analytical workloads." | ||
] | ||
|
||
# Add documents to the database | ||
doc_ids = [] | ||
for doc in documents: | ||
doc_id = db.add( | ||
document=doc, | ||
metadata={"source": "example", "type": "documentation"} | ||
) | ||
doc_ids.append(doc_id) | ||
print(f"Added document with ID: {doc_id}") | ||
|
||
# Query similar documents | ||
query = "How does SingleStore handle vector similarity search?" | ||
results = db.query( | ||
query=query, | ||
top_k=2, | ||
metadata_filter={"source": "example"} | ||
) | ||
|
||
print("\nQuery:", query) | ||
print("\nResults:") | ||
for result in results: | ||
print(f"\nDocument: {result['document']}") | ||
print(f"Similarity: {result['similarity']:.4f}") | ||
print(f"Metadata: {result['metadata']}") | ||
|
||
# Clean up - delete documents | ||
print("\nCleaning up...") | ||
for doc_id in doc_ids: | ||
db.delete(doc_id) | ||
print(f"Deleted document with ID: {doc_id}") | ||
|
||
if __name__ == "__main__": | ||
main() |
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ pinecone = "*" | |
faiss-cpu = "*" | ||
pydantic = "*" | ||
sqlalchemy = "*" | ||
singlestoredb = "*" | ||
|
||
|
||
|
||
|
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ pinecone | |
faiss-cpu | ||
torch | ||
pydantic | ||
sqlalchemy | ||
sqlalchemy | ||
singlestoredb |
Oops, something went wrong.