[FEAT][WeaviateClient]

pull/334/head
Kye 1 year ago
parent 387084cef9
commit 2bc46b8193

@ -28,7 +28,7 @@ pip install swarms
## Initialization ## Initialization
To use the Weaviate API Client, you need to initialize an instance of the `WeaviateClient` class. Here are the parameters you can pass to the constructor: To use the Weaviate API Client, you need to initialize an instance of the `WeaviateDB` class. Here are the parameters you can pass to the constructor:
| Parameter | Type | Description | | Parameter | Type | Description |
|----------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------| |----------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------|
@ -43,12 +43,12 @@ To use the Weaviate API Client, you need to initialize an instance of the `Weavi
| `additional_config` | Optional[weaviate.AdditionalConfig] | Additional configuration for the client. (Optional) | | `additional_config` | Optional[weaviate.AdditionalConfig] | Additional configuration for the client. (Optional) |
| `connection_params` | Dict[str, Any] | Dictionary containing connection parameters. This parameter is used internally and can be ignored in most cases. | | `connection_params` | Dict[str, Any] | Dictionary containing connection parameters. This parameter is used internally and can be ignored in most cases. |
Here's an example of how to initialize a WeaviateClient: Here's an example of how to initialize a WeaviateDB:
```python ```python
from swarms.memory import WeaviateClient from swarms.memory import WeaviateDB
weaviate_client = WeaviateClient( weaviate_client = WeaviateDB(
http_host="YOUR_HTTP_HOST", http_host="YOUR_HTTP_HOST",
http_port="YOUR_HTTP_PORT", http_port="YOUR_HTTP_PORT",
http_secure=True, http_secure=True,

@ -1,6 +1,6 @@
from swarms.memory import WeaviateClient from swarms.memory import WeaviateDB
weaviate_client = WeaviateClient( weaviate_client = WeaviateDB(
http_host="YOUR_HTTP_HOST", http_host="YOUR_HTTP_HOST",
http_port="YOUR_HTTP_PORT", http_port="YOUR_HTTP_PORT",
http_secure=True, http_secure=True,

@ -1,6 +1,6 @@
from swarms.memory.base_vectordb import VectorDatabase from swarms.memory.base_vectordb import VectorDatabase
from swarms.memory.short_term_memory import ShortTermMemory from swarms.memory.short_term_memory import ShortTermMemory
from swarms.memory.sqlite import SQLiteDB from swarms.memory.sqlite import SQLiteDB
from swarms.memory.weaviate_db import WeaviateClient from swarms.memory.weaviate_db import WeaviateDB
__all__ = ["VectorDatabase", "ShortTermMemory", "SQLiteDB", "WeaviateClient"] __all__ = ["VectorDatabase", "ShortTermMemory", "SQLiteDB", "WeaviateDB"]

@ -11,7 +11,7 @@ try:
except ImportError as error: except ImportError as error:
print("pip install weaviate-client") print("pip install weaviate-client")
class WeaviateClient(VectorDatabase): class WeaviateDB(VectorDatabase):
""" """
Weaviate API Client Weaviate API Client
@ -36,7 +36,7 @@ class WeaviateClient(VectorDatabase):
delete: Delete an object from a specified collection. delete: Delete an object from a specified collection.
Examples: Examples:
>>> from swarms.memory import WeaviateClient >>> from swarms.memory import WeaviateDB
""" """
def __init__( def __init__(
@ -77,7 +77,7 @@ class WeaviateClient(VectorDatabase):
) )
# If additional headers are provided, add them to the connection params. # If additional headers are provided, add them to the connection params.
self.client = weaviate.WeaviateClient( self.client = weaviate.WeaviateDB(
connection_params=connection_params, connection_params=connection_params,
auth_client_secret=auth_client_secret, auth_client_secret=auth_client_secret,
additional_headers=additional_headers, additional_headers=additional_headers,

@ -1,12 +1,12 @@
import pytest import pytest
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from swarms.memory.weaviate import WeaviateClient from swarms.memory.weaviate_db import WeaviateDB
# Define fixture for a WeaviateClient instance with mocked methods # Define fixture for a WeaviateDB instance with mocked methods
@pytest.fixture @pytest.fixture
def weaviate_client_mock(): def weaviate_client_mock():
client = WeaviateClient( client = WeaviateDB(
http_host="mock_host", http_host="mock_host",
http_port="mock_port", http_port="mock_port",
http_secure=False, http_secure=False,
@ -31,7 +31,7 @@ def weaviate_client_mock():
return client return client
# Define tests for the WeaviateClient class # Define tests for the WeaviateDB class
def test_create_collection(weaviate_client_mock): def test_create_collection(weaviate_client_mock):
# Test creating a collection # Test creating a collection
weaviate_client_mock.create_collection( weaviate_client_mock.create_collection(

Loading…
Cancel
Save