remove host and port and use cluster url instead

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
Francisco Javier Arceo 2025-07-30 20:38:39 -04:00
parent 87780534b0
commit edf4514ba2
3 changed files with 8 additions and 17 deletions

View file

@ -37,19 +37,15 @@ See [Weaviate's documentation](https://weaviate.io/developers/weaviate) for more
| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `host` | `str \| None` | No | localhost | |
| `port` | `int \| None` | No | 8080 | |
| `weaviate_api_key` | `str \| None` | No | | The API key for the Weaviate instance |
| `weaviate_cluster_url` | `str \| None` | No | | The URL of the Weaviate cluster |
| `weaviate_cluster_url` | `str \| None` | No | localhost:8080 | The URL of the Weaviate cluster |
| `kvstore` | `utils.kvstore.config.RedisKVStoreConfig \| utils.kvstore.config.SqliteKVStoreConfig \| utils.kvstore.config.PostgresKVStoreConfig \| utils.kvstore.config.MongoDBKVStoreConfig, annotation=NoneType, required=False, default='sqlite', discriminator='type'` | No | | Config for KV store backend (SQLite only for now) |
## Sample Configuration
```yaml
host: ${env.WEAVIATE_HOST:=localhost}
port: ${env.WEAVIATE_PORT:=8080}
weaviate_api_key: null
weaviate_cluster_url: null
weaviate_cluster_url: ${env.WEAVIATE_CLUSTER_URL:=localhost:8080}
kvstore:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/dummy}/weaviate_registry.db

View file

@ -17,25 +17,19 @@ from llama_stack.schema_utils import json_schema_type
@json_schema_type
class WeaviateVectorIOConfig(BaseModel):
host: str | None = Field(default="localhost")
port: int | None = Field(default=8080)
weaviate_api_key: str | None = Field(description="The API key for the Weaviate instance", default=None)
weaviate_cluster_url: str | None = Field(description="The URL of the Weaviate cluster", default=None)
weaviate_cluster_url: str | None = Field(description="The URL of the Weaviate cluster", default="localhost:8080")
kvstore: KVStoreConfig | None = Field(description="Config for KV store backend (SQLite only for now)", default=None)
@classmethod
def sample_run_config(
cls,
__distro_dir__: str,
host: str = "${env.WEAVIATE_HOST:=localhost}",
port: int = "${env.WEAVIATE_PORT:=8080}",
**kwargs: Any,
) -> dict[str, Any]:
return {
"host": "${env.WEAVIATE_HOST:=localhost}",
"port": "${env.WEAVIATE_PORT:=8080}",
"weaviate_api_key": None,
"weaviate_cluster_url": None,
"weaviate_cluster_url": "${env.WEAVIATE_CLUSTER_URL:=localhost:8080}",
"kvstore": SqliteKVStoreConfig.sample_run_config(
__distro_dir__=__distro_dir__,
db_name="weaviate_registry.db",

View file

@ -166,11 +166,12 @@ class WeaviateVectorIOAdapter(
self.metadata_collection_name = "openai_vector_stores_metadata"
def _get_client(self) -> weaviate.Client:
if self.config.weaviate_cluster_url is None:
if self.config.weaviate_cluster_url == "localhost:8080":
host, port = self.config.weaviate_cluster_url.split(":")
key = "local_test"
client = weaviate.connect_to_local(
host=self.config.host,
port=self.config.port,
host=host,
port=port,
)
else:
key = f"{self.config.weaviate_cluster_url}::{self.config.weaviate_api_key}"