Commit Graph

5 Commits

Author SHA1 Message Date
viettranx 6dcac3d7e3 fix(kg): sanitize LLM JSON output before parsing (#167)
Add sanitizeJSON() to fix malformed decimal numbers (e.g. '0. 85' → '0.85')
and trailing commas before closing brackets. Fixes extraction failures with
Gemini 2.5 Flash which occasionally produces invalid JSON.
2026-03-14 16:22:48 +07:00
viettranx 558bdd6d5c fix(memory): use per-user workspace for memory path detection and KG extraction
Two related fixes:

1. Memory interceptor now resolves workspace from request context
   (per-user workspace) instead of using the static global workspace.
   This fixes memory writes with absolute paths under per-user
   workspaces (e.g. workspace/channel/userID/memory/) being bypassed
   and written to disk instead of the database, which also prevented
   KG extraction, memory indexing, and cross-session recall.

2. KG extractor: increase max_tokens 4096→8192, add retry on
   truncation (finish_reason=length), and support chunking for
   long inputs with deduplication on merge.
2026-03-13 13:22:02 +07:00
viettranx b4133282a6 refactor(kg): improve extraction prompt with few-shot example and controlled vocabulary
Add domain context, coreference rules, controlled relation types (15 predefined),
few-shot example, and dynamic entity count (3-15). Increase max input from 6000
to 12000 chars, reduce max output tokens from 8192 to 4096.
2026-03-12 18:54:14 +07:00
viettranx bdb60de7ae chore: upgrade Go 1.25 → 1.26 and apply go fix modernizations
- Update go.mod and Dockerfile to Go 1.26
- Apply `go fix ./...` stdlib modernizations across 170+ files
- Add `go fix` to post-implementation checklist in CLAUDE.md
- Fix go fix misapplied rewrite in loop_history.go
2026-03-10 00:09:15 +07:00
viettranx 63eff188ad feat(kg): add knowledge graph with LLM extraction, traversal, and graph visualization
- KnowledgeGraphStore interface + PostgreSQL implementation (recursive CTE traversal, 5s timeout)
- LLM entity extraction pipeline triggered on memory writes (background goroutine)
- knowledge_graph_search agent tool with search + traversal modes
- HTTP API: CRUD entities, traverse, extract, stats, graph endpoints
- Web UI: KG tab on memory page with table/graph toggle, entity detail, manual extraction
- Force-directed graph visualization using @xyflow/react + d3-force
- Builtin tool seed with configurable provider/model/confidence settings
2026-03-09 17:11:20 +07:00