Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev && \
if [ -n "$GRAPHITI_VERSION" ]; then \
if [ "$INSTALL_FALKORDB" = "true" ]; then \
uv pip install --system --upgrade "graphiti-core[falkordb]==$GRAPHITI_VERSION"; \
uv pip install --upgrade "graphiti-core[falkordb]==$GRAPHITI_VERSION"; \
else \
uv pip install --system --upgrade "graphiti-core==$GRAPHITI_VERSION"; \
uv pip install --upgrade "graphiti-core==$GRAPHITI_VERSION"; \
fi; \
else \
if [ "$INSTALL_FALKORDB" = "true" ]; then \
uv pip install --system --upgrade "graphiti-core[falkordb]"; \
uv pip install --upgrade "graphiti-core[falkordb]"; \
else \
uv pip install --system --upgrade graphiti-core; \
uv pip install --upgrade graphiti-core; \
fi; \
fi

Expand All @@ -74,5 +74,5 @@ USER app
ENV PORT=8000
EXPOSE $PORT

# Use uv run for execution
CMD ["uv", "run", "uvicorn", "graph_service.main:app", "--host", "0.0.0.0", "--port", "8000"]
# Use uv run with --no-sync to avoid re-syncing on startup
CMD ["uv", "run", "--no-sync", "uvicorn", "graph_service.main:app", "--host", "0.0.0.0", "--port", "8000"]
10 changes: 7 additions & 3 deletions server/graph_service/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ class Settings(BaseSettings):
openai_base_url: str | None = Field(None)
model_name: str | None = Field(None)
embedding_model_name: str | None = Field(None)
neo4j_uri: str
neo4j_user: str
neo4j_password: str
neo4j_uri: str | None = Field(None)
neo4j_user: str | None = Field(None)
neo4j_password: str | None = Field(None)
falkordb_host: str | None = Field(None)
falkordb_port: int | None = Field(None)
falkordb_database: str | None = Field(None)
db_backend: str = Field('neo4j')

model_config = SettingsConfigDict(env_file='.env', extra='ignore')

Expand Down
51 changes: 39 additions & 12 deletions server/graph_service/zep_graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@


class ZepGraphiti(Graphiti):
def __init__(self, uri: str, user: str, password: str, llm_client: LLMClient | None = None):
super().__init__(uri, user, password, llm_client)
def __init__(
self,
uri: str | None = None,
user: str | None = None,
password: str | None = None,
llm_client: LLMClient | None = None,
**kwargs,
):
super().__init__(uri, user, password, llm_client, **kwargs) # type: ignore

async def save_entity_node(self, name: str, uuid: str, group_id: str, summary: str = ''):
new_node = EntityNode(
Expand Down Expand Up @@ -72,11 +79,21 @@ async def delete_episodic_node(self, uuid: str):


async def get_graphiti(settings: ZepEnvDep):
client = ZepGraphiti(
uri=settings.neo4j_uri,
user=settings.neo4j_user,
password=settings.neo4j_password,
)
if settings.db_backend == 'falkordb':
from graphiti_core.driver.falkordb_driver import FalkorDriver

driver = FalkorDriver( # type: ignore
host=settings.falkordb_host or 'localhost', # type: ignore
port=settings.falkordb_port or 6379, # type: ignore
database=settings.falkordb_database or 'default_db', # type: ignore
)
client = ZepGraphiti(graph_driver=driver) # type: ignore
else:
client = ZepGraphiti(
uri=settings.neo4j_uri,
user=settings.neo4j_user,
password=settings.neo4j_password,
)
if settings.openai_base_url is not None:
client.llm_client.config.base_url = settings.openai_base_url
if settings.openai_api_key is not None:
Expand All @@ -91,11 +108,21 @@ async def get_graphiti(settings: ZepEnvDep):


async def initialize_graphiti(settings: ZepEnvDep):
client = ZepGraphiti(
uri=settings.neo4j_uri,
user=settings.neo4j_user,
password=settings.neo4j_password,
)
if settings.db_backend == 'falkordb':
from graphiti_core.driver.falkordb_driver import FalkorDriver

driver = FalkorDriver( # type: ignore
host=settings.falkordb_host or 'localhost', # type: ignore
port=settings.falkordb_port or 6379, # type: ignore
database=settings.falkordb_database or 'default_db', # type: ignore
)
client = ZepGraphiti(graph_driver=driver) # type: ignore
else:
client = ZepGraphiti(
uri=settings.neo4j_uri,
user=settings.neo4j_user,
password=settings.neo4j_password,
)
await client.build_indices_and_constraints()


Expand Down
Loading