Fixed pre commit

This commit is contained in:
Enrico Zimuel 2025-11-20 14:34:04 +01:00
parent 7034637cac
commit df23e0c32f
No known key found for this signature in database
GPG key ID: 6CB203F6934A69F1
8 changed files with 28 additions and 14 deletions

View file

@ -89,15 +89,15 @@ See [Elasticsearch's documentation](https://www.elastic.co/docs/solutions/search
| Field | Type | Required | Default | Description | | Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------| |-------|------|----------|---------|-------------|
| `api_key` | `str \| None` | No | | The API key for the Elasticsearch instance | | `elasticsearch_api_key` | `str \| None` | No | | The API key for the Elasticsearch instance |
| `hosts` | `str \| None` | No | localhost:9200 | The URL of the Elasticsearch instance | | `elasticsearch_url` | `str \| None` | No | localhost:9200 | The URL of the Elasticsearch instance |
| `persistence` | `llama_stack.core.storage.datatypes.KVStoreReference \| None` | No | | Config for KV store backend (SQLite only for now) | | `persistence` | `KVStoreReference \| None` | No | | Config for KV store backend (SQLite only for now) |
## Sample Configuration ## Sample Configuration
```yaml ```yaml
hosts: ${env.ELASTICSEARCH_API_KEY:=None} elasticsearch_url: ${env.ELASTICSEARCH_URL:=localhost:9200}
api_key: ${env.ELASTICSEARCH_URL:=localhost:9200} elasticsearch_api_key: ${env.ELASTICSEARCH_API_KEY:=}
persistence: persistence:
namespace: vector_io::elasticsearch namespace: vector_io::elasticsearch
backend: kv_default backend: kv_default

View file

@ -146,6 +146,14 @@ providers:
persistence: persistence:
namespace: vector_io::weaviate namespace: vector_io::weaviate
backend: kv_default backend: kv_default
- provider_id: ${env.ELASTICSEARCH_URL:+elasticsearch}
provider_type: remote::elasticsearch
config:
elasticsearch_url: ${env.ELASTICSEARCH_URL:=localhost:9200}
elasticsearch_api_key: ${env.ELASTICSEARCH_API_KEY:=}
persistence:
namespace: vector_io::elasticsearch
backend: kv_default
files: files:
- provider_id: meta-reference-files - provider_id: meta-reference-files
provider_type: inline::localfs provider_type: inline::localfs

View file

@ -146,6 +146,14 @@ providers:
persistence: persistence:
namespace: vector_io::weaviate namespace: vector_io::weaviate
backend: kv_default backend: kv_default
- provider_id: ${env.ELASTICSEARCH_URL:+elasticsearch}
provider_type: remote::elasticsearch
config:
elasticsearch_url: ${env.ELASTICSEARCH_URL:=localhost:9200}
elasticsearch_api_key: ${env.ELASTICSEARCH_API_KEY:=}
persistence:
namespace: vector_io::elasticsearch
backend: kv_default
files: files:
- provider_id: meta-reference-files - provider_id: meta-reference-files
provider_type: inline::localfs provider_type: inline::localfs

View file

@ -149,8 +149,8 @@ providers:
- provider_id: ${env.ELASTICSEARCH_URL:+elasticsearch} - provider_id: ${env.ELASTICSEARCH_URL:+elasticsearch}
provider_type: remote::elasticsearch provider_type: remote::elasticsearch
config: config:
elasticsearch_api_key: ${env.ELASTICSEARCH_API_KEY:=}
elasticsearch_url: ${env.ELASTICSEARCH_URL:=localhost:9200} elasticsearch_url: ${env.ELASTICSEARCH_URL:=localhost:9200}
elasticsearch_api_key: ${env.ELASTICSEARCH_API_KEY:=}
persistence: persistence:
namespace: vector_io::elasticsearch namespace: vector_io::elasticsearch
backend: kv_default backend: kv_default

View file

@ -149,8 +149,8 @@ providers:
- provider_id: ${env.ELASTICSEARCH_URL:+elasticsearch} - provider_id: ${env.ELASTICSEARCH_URL:+elasticsearch}
provider_type: remote::elasticsearch provider_type: remote::elasticsearch
config: config:
elasticsearch_api_key: ${env.ELASTICSEARCH_API_KEY:=}
elasticsearch_url: ${env.ELASTICSEARCH_URL:=localhost:9200} elasticsearch_url: ${env.ELASTICSEARCH_URL:=localhost:9200}
elasticsearch_api_key: ${env.ELASTICSEARCH_API_KEY:=}
persistence: persistence:
namespace: vector_io::elasticsearch namespace: vector_io::elasticsearch
backend: kv_default backend: kv_default

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
from llama_stack.providers.datatypes import Api, ProviderSpec from llama_stack_api import Api, ProviderSpec
from .config import ElasticsearchVectorIOConfig from .config import ElasticsearchVectorIOConfig

View file

@ -9,7 +9,7 @@ from typing import Any
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from llama_stack.core.storage.datatypes import KVStoreReference from llama_stack.core.storage.datatypes import KVStoreReference
from llama_stack.schema_utils import json_schema_type from llama_stack_api import json_schema_type
@json_schema_type @json_schema_type

View file

@ -229,6 +229,7 @@ class ElasticsearchIndex(EmbeddingIndex):
log.error(f"Error deleting Elasticsearch index {self.collection_name}: {e}") log.error(f"Error deleting Elasticsearch index {self.collection_name}: {e}")
raise raise
class ElasticsearchVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProtocolPrivate): class ElasticsearchVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProtocolPrivate):
def __init__( def __init__(
self, self,
@ -244,10 +245,7 @@ class ElasticsearchVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStore
self.vector_store_table = None self.vector_store_table = None
async def initialize(self) -> None: async def initialize(self) -> None:
self.client = AsyncElasticsearch( self.client = AsyncElasticsearch(hosts=self.config.elasticsearch_url, api_key=self.config.elasticsearch_api_key)
hosts=self.config.elasticsearch_url,
api_key=self.config.elasticsearch_api_key
)
self.kvstore = await kvstore_impl(self.config.persistence) self.kvstore = await kvstore_impl(self.config.persistence)
start_key = VECTOR_DBS_PREFIX start_key = VECTOR_DBS_PREFIX