add embedding dim env var
This commit is contained in:
parent
6b57979869
commit
08d20395d6
3 changed files with 11 additions and 8 deletions
|
|
@ -23,6 +23,8 @@ from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
|
from graphiti_core.embedder.client import EMBEDDING_DIM
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from opensearchpy import OpenSearch, helpers
|
from opensearchpy import OpenSearch, helpers
|
||||||
|
|
||||||
|
|
@ -59,8 +61,8 @@ aoss_indices = [
|
||||||
'group_id': {'type': 'text'},
|
'group_id': {'type': 'text'},
|
||||||
'created_at': {'type': 'date', 'format': "yyyy-MM-dd'T'HH:mm:ss.SSSZ"},
|
'created_at': {'type': 'date', 'format': "yyyy-MM-dd'T'HH:mm:ss.SSSZ"},
|
||||||
'name_embedding': {
|
'name_embedding': {
|
||||||
'type': 'dense_vector',
|
'type': 'knn_vector',
|
||||||
'dims': 1024,
|
'dims': EMBEDDING_DIM,
|
||||||
'index': True,
|
'index': True,
|
||||||
'similarity': 'cosine',
|
'similarity': 'cosine',
|
||||||
'method': {
|
'method': {
|
||||||
|
|
@ -116,13 +118,13 @@ aoss_indices = [
|
||||||
'expired_at': {'type': 'date', 'format': "yyyy-MM-dd'T'HH:mm:ss.SSSZ"},
|
'expired_at': {'type': 'date', 'format': "yyyy-MM-dd'T'HH:mm:ss.SSSZ"},
|
||||||
'invalid_at': {'type': 'date', 'format': "yyyy-MM-dd'T'HH:mm:ss.SSSZ"},
|
'invalid_at': {'type': 'date', 'format': "yyyy-MM-dd'T'HH:mm:ss.SSSZ"},
|
||||||
'fact_embedding': {
|
'fact_embedding': {
|
||||||
'type': 'dense_vector',
|
'type': 'knn_vector',
|
||||||
'dims': 1024,
|
'dims': EMBEDDING_DIM,
|
||||||
'index': True,
|
'index': True,
|
||||||
'similarity': 'cosine',
|
'similarity': 'cosine',
|
||||||
'method': {
|
'method': {
|
||||||
'engine': 'faiss',
|
'engine': 'faiss',
|
||||||
'space_type': 'cosinesimil',
|
'space_type': 'innerproduct',
|
||||||
'name': 'hnsw',
|
'name': 'hnsw',
|
||||||
'parameters': {'ef_construction': 128, 'm': 16},
|
'parameters': {'ef_construction': 128, 'm': 16},
|
||||||
},
|
},
|
||||||
|
|
@ -236,7 +238,7 @@ class GraphDriver(ABC):
|
||||||
|
|
||||||
def save_to_aoss(self, name: str, data: list[dict]) -> int:
|
def save_to_aoss(self, name: str, data: list[dict]) -> int:
|
||||||
client = self.aoss_client
|
client = self.aoss_client
|
||||||
if not client:
|
if not client or not helpers:
|
||||||
logger.warning('No OpenSearch client found')
|
logger.warning('No OpenSearch client found')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class FalkorDriverSession(GraphDriverSession):
|
class FalkorDriverSession(GraphDriverSession):
|
||||||
provider = GraphProvider.FALKORDB
|
provider = GraphProvider.FALKORDB
|
||||||
aoss_client: None = None
|
|
||||||
|
|
||||||
def __init__(self, graph: FalkorGraph):
|
def __init__(self, graph: FalkorGraph):
|
||||||
self.graph = graph
|
self.graph = graph
|
||||||
|
|
@ -75,6 +74,7 @@ class FalkorDriverSession(GraphDriverSession):
|
||||||
|
|
||||||
class FalkorDriver(GraphDriver):
|
class FalkorDriver(GraphDriver):
|
||||||
provider = GraphProvider.FALKORDB
|
provider = GraphProvider.FALKORDB
|
||||||
|
aoss_client: None = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,13 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
EMBEDDING_DIM = 1024
|
EMBEDDING_DIM = os.getenv('EMBEDDING_DIM', 1024)
|
||||||
|
|
||||||
|
|
||||||
class EmbedderConfig(BaseModel):
|
class EmbedderConfig(BaseModel):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue