Commit Graph

11 Commits

Author SHA1 Message Date
Dominik Seemann 8af800a122 fix(graph): pass small_model to graphiti so non-openai backends don't 404
Graphiti's OpenAIClient routes "simpler" extraction prompts to
ModelSize.small, falling back to a hard-coded `gpt-4.1-nano` when no
small_model is configured. Against Qwen/Dashscope (and other OpenAI-SDK
endpoints that don't host that model) this surfaces as a 404 mid-graph
build, even when LLM_MODEL_NAME points at a working model.

Add LLM_SMALL_MODEL_NAME (defaults to LLM_MODEL_NAME) and pass it through
the Graphiti LLMConfig so the small slot is always populated with a
model the configured endpoint actually serves.

Closes #37
2026-05-11 13:12:21 +02:00
Dominik Seemann fb0ac4b5fe fix(graph): replace passthrough reranker with ollama-backed cross-encoder
Graphiti's default cross-encoder hard-codes the OpenAI gpt-4.1-nano model
and depends on OpenAI-specific logprobs/logit_bias, so the adapter has
been injecting a no-op _PassthroughReranker just to keep search code
paths working. Search results consumed by SearchResult, InsightForge,
Panorama, and Interview were therefore returned in Graphiti's RRF order
with no real reranking signal.

Add an Ollama-backed CrossEncoderClient that scores passages through a
local chat model via the OpenAI-compatible /v1 surface and wire it into
_get_graphiti() behind a RERANKER_PROVIDER switch (default: ollama).
Construction is side-effect-free and the rank() method never raises:
per-passage parse failures degrade to a deterministic low score, and a
whole-call failure falls back to passthrough order with a single WARNING
log so Flask keeps serving when Ollama is unreachable. Setting
RERANKER_PROVIDER=none preserves the legacy passthrough for CI and slim
containers that cannot pull the model.

Closes #39
2026-05-11 10:39:50 +00:00
Dominik Seemann ebeff4940d fix(graph): default embeddings to local ollama and gate empty graph builds
Two coupled changes that together restore non-empty post-migration graph
builds and remove the silent "succeeded but empty" outcome.

Root cause: Config defaulted EMBEDDING_MODEL to OpenAI text-embedding-3-small
(1536 dim), but Graphiti's Neo4j vector index is 1024 dim. With the
documented Dashscope LLM default, EMBEDDING_API_KEY/EMBEDDING_BASE_URL
fell back to LLM_*, producing either a 4xx (since #29 propagates as
Task.FAILED) or a write that landed metadata but no entities.

Changes:
- Flip Config defaults to local Ollama (mxbai-embed-large, 1024 dim,
  http://localhost:11434/v1). Override semantics unchanged: explicit
  EMBEDDING_* env vars continue to win, so existing OpenAI/Gemini setups
  are not affected.
- Gate _build_graph_worker on a non-zero entity-node count before
  complete_task. Mirrors the existing _recover_stuck_projects rule;
  surfaces any residual silent failure as Task.FAILED with the new
  progress.emptyGraphFailure locale key, instead of marking the project
  GRAPH_COMPLETED on an empty graph.
- Update README, CLAUDE.md, and docker-compose.yml comments to reflect
  Ollama as the active default and OpenAI/Gemini as commented fallbacks.
- The matching .env.example diff is recorded in
  .kiro/specs/graph-build-empty-fix/HANDOFF.md for manual operator apply
  (file is hook-protected from the assistant).

Spec: .kiro/specs/graph-build-empty-fix/

Closes #37
2026-05-11 09:43:28 +00:00
Dominik Seemann e1019d91cb docs(i18n): translate chinese docstrings/comments in backend root, api init, simulation_ipc, simulation_manager, zep_entity_reader 2026-05-07 14:49:20 +00:00
Dominik Seemann 2badf568e7 feat(graphiti): finalize neo4j migration with provider switch
Adds a Neo4j service to docker-compose so `docker compose up -d` works
on a clean checkout, and unhardcodes Graphiti's LLM/embedder so the
documented default provider (Qwen via Dashscope) actually works.

- docker-compose: neo4j:5-community service with cypher-shell
  healthcheck, named volumes, and `depends_on: service_healthy` on the
  app container; in-Docker NEO4J_URI override leaves the host-mode
  default untouched.
- Config: new GRAPHITI_LLM_PROVIDER (openai|gemini, default openai) plus
  optional EMBEDDING_API_KEY / EMBEDDING_BASE_URL that fall back to the
  chat LLM credentials.
- graphiti_adapter: provider switch inside the singleton factory with
  lazy per-provider imports; Gemini path is preserved exactly. The
  no-op `_GeminiReranker` becomes a provider-agnostic
  `_PassthroughReranker`, still injected explicitly so Graphiti does
  not fall back to its OpenAI-only default reranker.
- Drop the ignored `reranker=` kwarg from `_GraphNamespace.search` and
  the misleading callers in `zep_tools.py` and
  `oasis_profile_generator.py`.
- Refresh `.env.example` to mirror the README env section.

Spec, requirements, and design under
`.kiro/specs/graphiti-neo4j-finalize/`.

Closes #1
2026-05-07 08:43:36 +00:00
Abhishek Yadav 28827067c0 feat: migrate knowledge graph from Zep Cloud to Graphiti + local Neo4j
Replaces the paid, rate-limited Zep Cloud service with Graphiti (graphiti-core
0.11.6) backed by a local Neo4j instance — free, unlimited, and self-hosted.

Key changes:
- Add GraphitiAdapter: drop-in Zep-compatible wrapper around Graphiti with a
  persistent event-loop thread to avoid asyncio/Neo4j driver conflicts
- Switch LLM client to native GeminiClient + GeminiEmbedder (text-embedding-004
  fails on Gemini compat endpoint; use google-genai SDK directly)
- Add _GeminiReranker passthrough replacing OpenAIRerankerClient (which
  hardcodes gpt-4.1-nano and uses logprobs unsupported by Gemini)
- Fix Cypher queries: use s.uuid/t.uuid for edge source/target instead of
  r.source_node_uuid (null property in Graphiti's schema)
- Add ontology-based entity type classifier (_classify_entity_type) so nodes
  get colored by type in the D3 graph visualization instead of all being Entity
- Apply classifier in ZepEntityReader so filter_defined_entities finds entities
  (previously 0 personas loaded because all labels were ['Entity'])
- Add startup recovery: auto-mark graph_building projects as graph_completed
  on backend restart if Neo4j already has their data
- Add resume capability to graph build: skip already-processed episodes after
  a restart (断点续传)
- Add non-blocking graph data cache with background refresh in graph.py
- Add EMBEDDING_MODEL config (default: gemini-embedding-001 for Gemini users)
- Add CLAUDE.md with project architecture and dev commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 01:30:28 +05:30
666ghj 40f7035947 fix(config): enable overriding of environment variables when loading .env file 2026-01-23 16:20:24 +08:00
666ghj 5ece3f670b Implement Report Agent for automated report generation and interaction
- Introduced the Report Agent module to facilitate the automatic generation of simulation analysis reports using LangChain and Zep, following the ReACT model.
- Added functionality for report outline planning, segmented content generation, and user interaction through a dialogue interface.
- Implemented new API endpoints for report generation, status checking, and retrieval, enhancing the overall reporting capabilities.
- Updated README.md to include detailed instructions on the new report generation features and API usage.
- Enhanced the project structure to accommodate the new report management functionalities, including report storage and retrieval mechanisms.
2025-12-09 15:10:55 +08:00
666ghj 5b4f02f421 Enhance simulation configuration and management features
- Added support for a `max_rounds` parameter in simulation API, allowing users to limit the number of simulation rounds, improving control over simulation duration.
- Updated README.md to reflect the new `max_rounds` parameter and its usage in simulation requests.
- Enhanced error handling for `max_rounds` input validation to ensure it is a positive integer.
- Modified simulation runner and related scripts to incorporate `max_rounds` functionality, ensuring consistent application across Twitter and Reddit simulations.
- Improved logging to indicate when the number of rounds is truncated due to the `max_rounds` setting, enhancing traceability during simulation execution.
2025-12-05 15:50:54 +08:00
666ghj 5f159f6d88 Enhance backend functionality with OASIS simulation features
- Updated README.md to include new simulation scripts and configuration details for OASIS, including API retry mechanisms and environment variable settings.
- Added simulation management and configuration generation services to streamline the simulation process across Twitter and Reddit platforms.
- Introduced new API routes for simulation-related operations, including entity retrieval and simulation status management.
- Implemented a robust retry mechanism for external API calls to improve system stability.
- Enhanced task management model to include detailed progress tracking.
- Added logging capabilities for action tracking during simulations.
- Included new scripts for running parallel simulations and testing profile formats.
2025-12-01 15:03:44 +08:00
666ghj 08f417f3b7 Introduce Project ID for context management, finalizing the stateful API pipeline from file submission to graph construction. 2025-11-28 17:21:08 +08:00