textgraph-kg 3.3.2__tar.gz → 3.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.gitignore +4 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/CHANGELOG.md +38 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/PKG-INFO +1 -1
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/pyproject.toml +1 -1
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_chat_decisions.py +18 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_console.py +22 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l8_retrieval.py +16 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/__init__.py +1 -1
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/cli.py +5 -1
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/console/chat.py +33 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/console/renderer.py +36 -2
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/console/server.py +14 -1
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/engine.py +42 -3
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/routing.py +3 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/graph_json.py +40 -1
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/uv.lock +1 -1
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.gitattributes +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/benchmark.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/determinism.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/lint-and-typecheck.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/pages.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/pre-commit.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/publish-pypi.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/release.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.github/workflows/test.yml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/.pre-commit-config.yaml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/ARCHITECTURE.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/BENCHMARKS.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/LICENSE +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/PLAN.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/README.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/SECURITY.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/TextGraph Architecture Gap Analysis.docx +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/TextGraph_Engineering_Blueprint.pdf +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/benchmarks/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/benchmarks/defaults.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/benchmarks/quality.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/benchmarks/reasoning.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/benchmarks/retrieval.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/benchmarks/run.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/benchmarks/security.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/COMPARISON_SEMANTICA.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/RUNNING.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/SKILL.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/how-it-works.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/plans/chat-console.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/plans/neo4j-backend.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/retrieval-routing.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/docs/site/index.html +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/requirements-dev.txt +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/requirements-full.txt +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/requirements.txt +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/schema/graph.schema.json +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/schema/manifest.schema.json +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/schema/schema.yaml +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/schema/validate.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/determinism/test_byte_identical.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/README.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/adr/adr-0007-case-linking.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/adr/adr-0008-retention.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/chat/case-4471.chat +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/conflict/filing-a.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/conflict/filing-b.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/contradiction/filing.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/decision_chain/adr-0001-retention.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/decision_chain/adr-0002-citations.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/decision_chain/adr-0003-tooling.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/docs/aml-overview.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/docs/shell-company.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/docs/wire-transfers.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/secure/public.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/secure/secret.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/temporal/correction.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpus_docs/adr-0001.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpus_docs/mixed-encoding.log +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpus_docs/notes.txt +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/er/aliases.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_agent_session.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_artifacts.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_duckdb_store.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_edge_provenance.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_er_pipeline.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_ie_pipeline.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_incremental.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_incremental_stress.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_provenance_integrity.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_quality_benchmark.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_report_corpora.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/integration/test_security_redteam.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_canonical_doc.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_canonical_json.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_chat.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_cli.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_config.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_conflicts.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_content_address.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_decision_chain.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_decisions.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_defaults.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_dense.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_doctor.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_export_rdf.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_gliner_backend.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_got.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_gql.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_ingest.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_integrations.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l0_ingest.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l1_structure.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l2_linguistic.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l3_encoder_ie.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l4_llm.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l5_resolution.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l6_claims.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l7_analytics.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_l7_layout.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_llm_augment.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_mcp_tools.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_offsets.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_richdocs.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_routing.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_security.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/unit/test_vision.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/console/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/console/api.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/console/ingest.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/console/page.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/canonical_doc.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/canonical_json.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/config.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/content_address.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/incremental.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/layout.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/core/offsets.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/doctor.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/got/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/got/reason.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/got/thought.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/gql/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/gql/ast.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/gql/engine.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/gql/errors.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/gql/parser.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/gql/tokenizer.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/integrations/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/integrations/adapters.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/base.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/dispatch.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/logs.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/markdown.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/plaintext.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/richdocs.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/structured.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l0_ingest/transcript.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l1_structure/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l1_structure/decisions.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l1_structure/emit.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l1_structure/structure.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l2_linguistic/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l2_linguistic/negation.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l2_linguistic/sentences.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l3_encoder_ie/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l3_encoder_ie/canonicalize.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l3_encoder_ie/emit_ie.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l3_encoder_ie/extract.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l3_encoder_ie/gliner_backend.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l3_encoder_ie/model.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l3_encoder_ie/rules.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l4_llm_optional/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l4_llm_optional/cache.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l4_llm_optional/client.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l4_llm_optional/extract.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l4_llm_optional/synthesize.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/audit.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/blocking.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/clustering.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/emit_er.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/metrics.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/model.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/resolve.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/scoring.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/similarity.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l5_entity_resolution/splink_backend.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l6_graph_model/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l6_graph_model/claims.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l6_graph_model/conflicts.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l6_graph_model/temporal.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l7_analytics/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l7_analytics/algorithms.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l7_analytics/analyze.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l7_analytics/communities.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l7_analytics/enrich.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l7_analytics/layout.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/bm25.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/dense.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/emit_chunks.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/grounding.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/model.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/narrate.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/rerank.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/vision/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/vision/embed.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/vision/maxsim.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l8_retrieval/vision/retriever.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/analytics_lite.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/artifacts.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/graph_html.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/ontology.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/prov.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/rdf.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/l9_artifacts/report.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/mcp/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/mcp/server.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/mcp/tools.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/pipeline.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/security/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/security/abac.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/security/context.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/security/policy.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/security/rebac.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/store/__init__.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/store/base.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/store/duckdb_store.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/store/memory.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph/watch.py +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/textgraph-engineering-research.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/ui/graph_html/README.md +0 -0
- {textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/ui/pipeline_console/README.md +0 -0
|
@@ -6,6 +6,44 @@ to Semantic Versioning.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [3.5.0] - 2026-08-08
|
|
10
|
+
|
|
11
|
+
**Console intelligence + explorability.** The web console gets the "explore + ask" loop and
|
|
12
|
+
cleaner retrieval — one terminal command to launch, everything else in the browser.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- **Click-to-expand neighbours** — clicking a node lights up its neighbourhood (connected
|
|
16
|
+
nodes + edges), so you can walk the graph instead of staring at dots.
|
|
17
|
+
- **Relation labels on edges** — predicates are drawn on highlighted edges (and on every edge
|
|
18
|
+
when zoomed in), so the graph reads as *who → how → whom*, not anonymous lines.
|
|
19
|
+
- **Grouped view** — a **Group** toggle outlines each community with its label (Semantica-style
|
|
20
|
+
cluster grouping) for large graphs.
|
|
21
|
+
- **LLM answers in the Ask dock** — a **Narrate (LLM)** tool composes a grounded, cited answer
|
|
22
|
+
over the retrieved evidence, in the browser (opt-in; needs an LLM endpoint in the env;
|
|
23
|
+
`GENERATED`-quarantined; degrades to a clear message when no endpoint is set).
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
- **Cleaner search** — repeated file-header templates (identical `====` banners across many
|
|
27
|
+
docs) are detected and down-ranked, and result snippets skip the banner/label lines so you
|
|
28
|
+
see real content, not separators. Query-time only; `graph.json` is unaffected.
|
|
29
|
+
|
|
30
|
+
## [3.4.0] - 2026-08-08
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- **The console can serve a pre-built `graph.json`.** `textgraph console textgraph-out`
|
|
34
|
+
(or `…/graph.json`, or a `.duckdb`) now serves the **already-built** graph instead of
|
|
35
|
+
silently rebuilding with the deterministic default. This means an **LLM-enriched build**
|
|
36
|
+
(`build --llm-extract`) shows *all* its `GENERATED` relations in the UI — previously the
|
|
37
|
+
console rebuilt without the LLM, so a legal/technical corpus (0 deterministic relations)
|
|
38
|
+
looked like disconnected dots. New `load_graph_json()` reconstructs `(nodes, edges)` from
|
|
39
|
+
a written `graph.json` (tags + byte-span citations preserved).
|
|
40
|
+
|
|
41
|
+
Typical flow — one build with intelligence, then explore it in the browser:
|
|
42
|
+
```
|
|
43
|
+
textgraph build ./docs --llm-extract -o out
|
|
44
|
+
textgraph console out
|
|
45
|
+
```
|
|
46
|
+
|
|
9
47
|
## [3.3.2] - 2026-08-08
|
|
10
48
|
|
|
11
49
|
**Prove & guard the investigator defaults.** PDF ingestion and entity resolution have run
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: textgraph-kg
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.5.0
|
|
4
4
|
Summary: Turn any textual corpus into a queryable, byte-cited knowledge graph. Deterministic & local-first by default, with opt-in LLM extraction, grounded answer synthesis, and semantic (embedding) search.
|
|
5
5
|
Project-URL: Homepage, https://krishddd.github.io/Wiki_textgraph/
|
|
6
6
|
Project-URL: Repository, https://github.com/krishddd/Wiki_textgraph
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "textgraph-kg"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.5.0"
|
|
4
4
|
description = "Turn any textual corpus into a queryable, byte-cited knowledge graph. Deterministic & local-first by default, with opt-in LLM extraction, grounded answer synthesis, and semantic (embedding) search."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
+
import pytest
|
|
5
6
|
from textgraph.console.chat import answer, classify
|
|
6
7
|
from textgraph.l8_retrieval import QueryEngine
|
|
7
8
|
from textgraph.pipeline import build
|
|
@@ -84,3 +85,20 @@ def test_answers_are_deterministic() -> None:
|
|
|
84
85
|
a = answer(eng, "are there conflicts").to_dict()
|
|
85
86
|
b = answer(eng, "are there conflicts").to_dict()
|
|
86
87
|
assert a == b
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_narrate_tool_is_registered_and_selectable() -> None:
|
|
91
|
+
from textgraph.l8_retrieval.routing import TOOLS
|
|
92
|
+
|
|
93
|
+
assert "narrate" in TOOLS
|
|
94
|
+
assert classify("anything", forced="narrate") == "narrate"
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_narrate_without_llm_endpoint_is_graceful(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
98
|
+
# No LLM env configured -> a clear message, never a fabricated answer.
|
|
99
|
+
for var in ("TEXTGRAPH_LLM_API_KEY", "API_KEY", "OPENAI_API_KEY"):
|
|
100
|
+
monkeypatch.delenv(var, raising=False)
|
|
101
|
+
ans = answer(_engine(CONFLICT), "summarise the conflicts", tool="narrate")
|
|
102
|
+
assert ans.tool == "narrate"
|
|
103
|
+
assert "endpoint" in ans.text.lower()
|
|
104
|
+
assert not ans.abstained
|
|
@@ -138,3 +138,25 @@ def test_export_graph_bytes_is_valid_graph_json() -> None:
|
|
|
138
138
|
assert len(doc["edges"]) == len(r.edges)
|
|
139
139
|
# Deterministic: same graph -> byte-identical export.
|
|
140
140
|
assert export_graph_bytes(QueryEngine(r.nodes, r.edges)) == body
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def test_console_serves_a_prebuilt_graph_json(tmp_path: Path) -> None:
|
|
144
|
+
# `textgraph console textgraph-out/graph.json` (or the output dir) serves the ALREADY
|
|
145
|
+
# built graph -- so an LLM-enriched build shows all its relations, no silent rebuild.
|
|
146
|
+
from textgraph.console.server import build_engine
|
|
147
|
+
from textgraph.l9_artifacts.graph_json import load_graph_json
|
|
148
|
+
from textgraph.pipeline import build_graph_bytes
|
|
149
|
+
|
|
150
|
+
out = tmp_path / "graph.json"
|
|
151
|
+
out.write_bytes(build_graph_bytes(DOCS))
|
|
152
|
+
r = build(DOCS)
|
|
153
|
+
|
|
154
|
+
nodes, edges = load_graph_json(out)
|
|
155
|
+
assert len(nodes) == len(r.nodes) and len(edges) == len(r.edges)
|
|
156
|
+
# tags + spans survive the round-trip (provenance intact).
|
|
157
|
+
assert {str(e.tag) for e in edges} == {str(e.tag) for e in r.edges}
|
|
158
|
+
assert any(e.source_spans for e in edges)
|
|
159
|
+
|
|
160
|
+
# build_engine accepts the graph.json file AND its containing directory.
|
|
161
|
+
assert build_engine(out).search("Acme", k=3).to_dict()["hits"]
|
|
162
|
+
assert build_engine(tmp_path).search("Acme", k=3).to_dict()["hits"]
|
|
@@ -139,3 +139,19 @@ def test_communities_and_stats() -> None:
|
|
|
139
139
|
|
|
140
140
|
def test_estimate_tokens_is_monotonic() -> None:
|
|
141
141
|
assert estimate_tokens("a" * 40) > estimate_tokens("a" * 4)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_clean_snippet_strips_banner_headers() -> None:
|
|
145
|
+
from textgraph.l8_retrieval.engine import _clean_snippet
|
|
146
|
+
|
|
147
|
+
text = (
|
|
148
|
+
"================================================================\n"
|
|
149
|
+
"EU AI ACT - LEGAL TEXT DOCUMENT\n"
|
|
150
|
+
"================================================================\n"
|
|
151
|
+
"\nTitle: Recital (1)\n\n"
|
|
152
|
+
"The purpose of this Regulation is to improve the internal market.\n"
|
|
153
|
+
)
|
|
154
|
+
snip = _clean_snippet(text)
|
|
155
|
+
assert not snip.startswith("=")
|
|
156
|
+
assert "EU AI ACT - LEGAL TEXT DOCUMENT" not in snip # all-caps banner line skipped
|
|
157
|
+
assert "purpose of this Regulation" in snip
|
|
@@ -908,7 +908,11 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
908
908
|
p_secure.set_defaults(func=_cmd_secure)
|
|
909
909
|
|
|
910
910
|
p_console = sub.add_parser("console", help="serve the local web console over the graph")
|
|
911
|
-
p_console.add_argument(
|
|
911
|
+
p_console.add_argument(
|
|
912
|
+
"path",
|
|
913
|
+
help="corpus dir, a built graph.json / output dir (serves the pre-built, e.g. "
|
|
914
|
+
"LLM-enriched, graph as-is), or a .duckdb snapshot",
|
|
915
|
+
)
|
|
912
916
|
p_console.add_argument("--host", default="127.0.0.1", help="bind host (default 127.0.0.1)")
|
|
913
917
|
p_console.add_argument("--port", type=int, default=8765, help="bind port (default 8765)")
|
|
914
918
|
p_console.add_argument(
|
|
@@ -153,6 +153,8 @@ def _dispatch(
|
|
|
153
153
|
return _timeline(engine, e) if e else _reason(engine, q, mode)
|
|
154
154
|
if chosen == "contradictions":
|
|
155
155
|
return _contradictions(engine)
|
|
156
|
+
if chosen == "narrate":
|
|
157
|
+
return _narrate(engine, q)
|
|
156
158
|
if chosen == "conflicts":
|
|
157
159
|
return _conflicts(engine)
|
|
158
160
|
if chosen == "trace":
|
|
@@ -375,6 +377,37 @@ def _contradictions(engine: QueryEngine) -> ChatAnswer:
|
|
|
375
377
|
)
|
|
376
378
|
|
|
377
379
|
|
|
380
|
+
def _narrate(engine: QueryEngine, q: str) -> ChatAnswer:
|
|
381
|
+
"""Opt-in LLM answer: compose a grounded, cited reply over the retrieved evidence.
|
|
382
|
+
|
|
383
|
+
GENERATED-quarantined; needs an LLM endpoint in the environment (MODEL_BASE_URL /
|
|
384
|
+
MODEL_NAME / API_KEY). No endpoint -> a clear message, never a fabricated answer.
|
|
385
|
+
"""
|
|
386
|
+
from textgraph.core.config import Config
|
|
387
|
+
from textgraph.l4_llm_optional import resolve_client
|
|
388
|
+
from textgraph.l8_retrieval.narrate import narrate as _compose
|
|
389
|
+
|
|
390
|
+
res = engine.search(q, k=6)
|
|
391
|
+
passages = [(h.snippet, list(h.citations)) for h in res.hits if h.snippet]
|
|
392
|
+
client = resolve_client(Config())
|
|
393
|
+
if client is None:
|
|
394
|
+
return ChatAnswer(
|
|
395
|
+
text="LLM narration needs an endpoint: set MODEL_BASE_URL / MODEL_NAME / API_KEY "
|
|
396
|
+
"in the environment before launching the console.",
|
|
397
|
+
tool="narrate",
|
|
398
|
+
)
|
|
399
|
+
ans = _compose(client, q, passages)
|
|
400
|
+
if ans is None:
|
|
401
|
+
return ChatAnswer(text="No retrieved evidence to ground an answer.", tool="narrate")
|
|
402
|
+
return ChatAnswer(
|
|
403
|
+
text=ans.text,
|
|
404
|
+
tool="narrate",
|
|
405
|
+
evidence=list(ans.citations),
|
|
406
|
+
highlight_nodes=[h.node_id for h in res.hits if h.kind == "entity"],
|
|
407
|
+
detail=[{"note": "GENERATED — composed by the LLM from the cited evidence above."}],
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
|
|
378
411
|
def _conflicts(engine: QueryEngine) -> ChatAnswer:
|
|
379
412
|
res = engine.conflicts()
|
|
380
413
|
if not res.conflicts:
|
|
@@ -200,6 +200,7 @@ SKELETON_HTML = """
|
|
|
200
200
|
<input id="q" placeholder="Search entities & passages… (Enter)">
|
|
201
201
|
</div>
|
|
202
202
|
<div class="spacer"></div>
|
|
203
|
+
<button class="btn" id="groupbtn" title="outline communities (grouped view)">Group</button>
|
|
203
204
|
<button class="btn" id="pathbtn" title="click two nodes to trace a path">Path</button>
|
|
204
205
|
<button class="btn" id="fit" title="fit graph to screen">Fit</button>
|
|
205
206
|
<button class="btn icon-btn" id="theme" title="toggle light / dark">◑</button>
|
|
@@ -225,6 +226,7 @@ SKELETON_HTML = """
|
|
|
225
226
|
<button id="save" title="download a graph.json snapshot of the current graph">💾</button>
|
|
226
227
|
<select id="asktool" title="which tool to use">
|
|
227
228
|
<option value="auto">Auto</option>
|
|
229
|
+
<option value="narrate">Narrate (LLM)</option>
|
|
228
230
|
<option value="reason">Reason</option>
|
|
229
231
|
<option value="search">Search</option>
|
|
230
232
|
<option value="path">Path</option>
|
|
@@ -266,7 +268,7 @@ const PALETTE = ['#4f6bff','#f59e42','#e0555b','#2bb7a3','#7bc043','#f2c14e','#c
|
|
|
266
268
|
'#ef8fb4','#9b7b5b','#8a94a6','#3aa0ff','#ff7a59','#59c1ff','#b08cff'];
|
|
267
269
|
const TAGS = ['STRUCTURAL','EXTRACTED','INFERRED','GENERATED'];
|
|
268
270
|
const S = { g:null, scale:1, tx:0, ty:0, hidden:new Set(), tags:new Set(TAGS),
|
|
269
|
-
q:'', match:null, sel:null, pathMode:false, pick:[], pathEdges:new Set(), date:null };
|
|
271
|
+
q:'', match:null, sel:null, pathMode:false, pick:[], pathEdges:new Set(), date:null, grouped:false };
|
|
270
272
|
const c = document.getElementById('c'), ctx = c.getContext('2d');
|
|
271
273
|
const tip = document.getElementById('tip'), note = document.getElementById('note');
|
|
272
274
|
const color = cid => PALETTE[((cid%PALETTE.length)+PALETTE.length)%PALETTE.length];
|
|
@@ -291,11 +293,26 @@ function edgeActive(e){ if(S.date===null) return true;
|
|
|
291
293
|
if(e.t_invalid && S.date >= e.t_invalid) return false;
|
|
292
294
|
return true; }
|
|
293
295
|
|
|
296
|
+
function drawGroups(labelColor){
|
|
297
|
+
const g={}; // community -> {xs,ys,label}
|
|
298
|
+
for(const n of S.g.nodes){ if(!visible(n)||n.community<0||n.community==null) continue;
|
|
299
|
+
(g[n.community]=g[n.community]||{xs:[],ys:[],label:n.community_label||('#'+n.community)});
|
|
300
|
+
g[n.community].xs.push(SX(n)); g[n.community].ys.push(SY(n)); }
|
|
301
|
+
for(const k in g){ const m=g[k]; if(m.xs.length<2) continue;
|
|
302
|
+
const cx=m.xs.reduce((a,b)=>a+b,0)/m.xs.length, cy=m.ys.reduce((a,b)=>a+b,0)/m.ys.length;
|
|
303
|
+
let rr=0; for(let i=0;i<m.xs.length;i++){ rr=Math.max(rr,Math.hypot(m.xs[i]-cx,m.ys[i]-cy)); }
|
|
304
|
+
rr+=22; ctx.beginPath(); ctx.arc(cx,cy,rr,0,7);
|
|
305
|
+
ctx.fillStyle='rgba('+(cssv('--edge-rgb')||'120,130,150')+',0.06)'; ctx.fill();
|
|
306
|
+
ctx.strokeStyle='rgba('+(cssv('--edge-rgb')||'120,130,150')+',0.25)'; ctx.lineWidth=1; ctx.stroke();
|
|
307
|
+
ctx.fillStyle=labelColor; ctx.font='600 11px ui-sans-serif,system-ui';
|
|
308
|
+
ctx.fillText(m.label.slice(0,28), cx-rr+6, cy-rr+14); }
|
|
309
|
+
}
|
|
294
310
|
function draw(){
|
|
295
311
|
const r = c.getBoundingClientRect(); ctx.clearRect(0,0,r.width,r.height);
|
|
296
312
|
const byId = S.byId; const ergb = cssv('--edge-rgb')||'120,130,150';
|
|
297
313
|
const labelColor = cssv('--canvas-label')||'#334'; const accent = cssv('--acc')||'#4f6bff';
|
|
298
314
|
const selColor = cssv('--fg')||'#111';
|
|
315
|
+
if(S.grouped) drawGroups(labelColor);
|
|
299
316
|
for(const e of S.g.edges){
|
|
300
317
|
if(!S.tags.has(e.tag)) continue;
|
|
301
318
|
const a=byId[e.source], b=byId[e.target]; if(!a||!b||!visible(a)||!visible(b)) continue;
|
|
@@ -305,6 +322,12 @@ function draw(){
|
|
|
305
322
|
ctx.beginPath(); ctx.moveTo(SX(a),SY(a)); ctx.lineTo(SX(b),SY(b));
|
|
306
323
|
ctx.strokeStyle = inPath?accent:('rgba('+ergb+','+alpha+')');
|
|
307
324
|
ctx.lineWidth = inPath?2.5:1; ctx.stroke();
|
|
325
|
+
// Label relation predicates on highlighted edges, or on every edge when zoomed in.
|
|
326
|
+
if(e.predicate && (inPath || S.scale>1.6) && !(dim(a)||dim(b))){
|
|
327
|
+
const mx=(SX(a)+SX(b))/2, my=(SY(a)+SY(b))/2;
|
|
328
|
+
ctx.fillStyle=inPath?accent:labelColor; ctx.font='10px ui-sans-serif,system-ui';
|
|
329
|
+
ctx.fillText(e.predicate.replace(/_/g,' ').slice(0,22), mx+3, my-3);
|
|
330
|
+
}
|
|
308
331
|
}
|
|
309
332
|
for(const n of S.g.nodes){
|
|
310
333
|
if(!visible(n)) continue;
|
|
@@ -345,9 +368,18 @@ c.addEventListener('wheel',e=>{ e.preventDefault(); const r=c.getBoundingClientR
|
|
|
345
368
|
const mx=e.clientX-r.left,my=e.clientY-r.top, f=e.deltaY<0?1.1:1/1.1;
|
|
346
369
|
S.tx=mx-(mx-S.tx)*f; S.ty=my-(my-S.ty)*f; S.scale*=f; draw(); },{passive:false});
|
|
347
370
|
|
|
371
|
+
function neighborsOf(id){ const set=new Set([id]); const edges=new Set();
|
|
372
|
+
for(const e of S.g.edges){ if(!S.tags.has(e.tag)) continue;
|
|
373
|
+
if(e.source===id){ set.add(e.target); edges.add(e.source+'>'+e.target); }
|
|
374
|
+
else if(e.target===id){ set.add(e.source); edges.add(e.source+'>'+e.target); } }
|
|
375
|
+
return {set,edges}; }
|
|
348
376
|
function onPick(n){
|
|
349
377
|
if(S.pathMode){ S.pick.push(n.id); if(S.pick.length===2){ runPath(); } draw(); return; }
|
|
350
|
-
S.sel=n;
|
|
378
|
+
S.sel=n;
|
|
379
|
+
const nb=neighborsOf(n.id); // click-to-expand: light up the node's neighbourhood
|
|
380
|
+
S.match = nb.set.size>1 ? nb.set : null;
|
|
381
|
+
S.pathEdges = nb.edges;
|
|
382
|
+
draw(); inspect(n);
|
|
351
383
|
}
|
|
352
384
|
|
|
353
385
|
function citeStr(cs){ return (cs||[]).map(x=>`[${x.doc_id.slice(0,18)}…:${x.start}-${x.end}]`).join(' '); }
|
|
@@ -468,6 +500,8 @@ document.getElementById('all').onchange=e=>{ S.hidden.clear();
|
|
|
468
500
|
if(!e.target.checked) S.g.communities.forEach(c=>S.hidden.add(c.community_id));
|
|
469
501
|
document.querySelectorAll('#comms input').forEach(cb=>cb.checked=e.target.checked); draw(); };
|
|
470
502
|
document.getElementById('fit').onclick=fit;
|
|
503
|
+
document.getElementById('groupbtn').onclick=()=>{ S.grouped=!S.grouped;
|
|
504
|
+
document.getElementById('groupbtn').classList.toggle('on',S.grouped); draw(); };
|
|
471
505
|
document.getElementById('pathbtn').onclick=()=>setPathMode(!S.pathMode);
|
|
472
506
|
document.getElementById('q').addEventListener('keydown',e=>{ if(e.key==='Enter') search();
|
|
473
507
|
if(e.key==='Escape'){ e.target.value=''; S.match=null; draw(); } });
|
|
@@ -25,8 +25,21 @@ from textgraph.l8_retrieval.engine import QueryEngine
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def build_engine(source: str | Path) -> QueryEngine:
|
|
28
|
-
"""Build a QueryEngine from a corpus
|
|
28
|
+
"""Build a QueryEngine from a corpus dir, a ``.duckdb`` file, or a built ``graph.json``.
|
|
29
|
+
|
|
30
|
+
Passing a ``graph.json`` (or a build-output directory containing one) serves the
|
|
31
|
+
*already-built* graph without re-running the pipeline — so an LLM-enriched build
|
|
32
|
+
(``build --llm-extract``) shows all its relations in the UI, instead of the console
|
|
33
|
+
silently rebuilding with the deterministic default.
|
|
34
|
+
"""
|
|
29
35
|
path = Path(source)
|
|
36
|
+
if path.is_dir() and (path / "graph.json").is_file():
|
|
37
|
+
path = path / "graph.json" # a build-output dir -> serve its graph.json
|
|
38
|
+
if path.is_file() and path.suffix == ".json":
|
|
39
|
+
from textgraph.l9_artifacts.graph_json import load_graph_json
|
|
40
|
+
|
|
41
|
+
nodes, edges = load_graph_json(path)
|
|
42
|
+
return QueryEngine(nodes, edges)
|
|
30
43
|
if path.is_file() and path.suffix == ".duckdb":
|
|
31
44
|
from textgraph.store.duckdb_store import load_graph
|
|
32
45
|
|
|
@@ -69,6 +69,25 @@ def _citations(edge: Edge) -> list[Citation]:
|
|
|
69
69
|
return [Citation(s.doc_id, s.start, s.end, s.hash) for s in edge.source_spans]
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
def _clean_snippet(text: str, limit: int = 280) -> str:
|
|
73
|
+
"""Skip leading banner/separator/label lines so a snippet shows real content, not a
|
|
74
|
+
repeated file-header template (``====`` rules, ``KEY: value`` metadata)."""
|
|
75
|
+
lines = text.splitlines()
|
|
76
|
+
i = 0
|
|
77
|
+
for line in lines:
|
|
78
|
+
s = line.strip()
|
|
79
|
+
# A separator rule (mostly = - * # _), a boilerplate label line, or an empty line.
|
|
80
|
+
alnum = sum(ch.isalnum() for ch in s)
|
|
81
|
+
is_rule = bool(s) and alnum <= max(2, len(s) // 5)
|
|
82
|
+
is_label = s.isupper() and len(s) <= 40 # e.g. "FULL TEXT", "LEGISLATIVE CONTEXT"
|
|
83
|
+
if not s or is_rule or is_label:
|
|
84
|
+
i += 1
|
|
85
|
+
else:
|
|
86
|
+
break
|
|
87
|
+
body = "\n".join(lines[i:]).strip() or text.strip()
|
|
88
|
+
return " ".join(body.split())[:limit]
|
|
89
|
+
|
|
90
|
+
|
|
72
91
|
class QueryEngine:
|
|
73
92
|
"""Typed, bounded, cited retrieval over an assembled TextGraph."""
|
|
74
93
|
|
|
@@ -102,6 +121,22 @@ class QueryEngine:
|
|
|
102
121
|
[(cid, str(self._node[cid].properties.get("text", ""))) for cid in self._chunk_ids]
|
|
103
122
|
)
|
|
104
123
|
|
|
124
|
+
# Boilerplate detection: chunks whose leading text is a template repeated across many
|
|
125
|
+
# documents (e.g. an identical file-header banner) carry no signal but match everything.
|
|
126
|
+
# They are down-ranked in search so real content surfaces instead. (Query-time only.)
|
|
127
|
+
from collections import Counter
|
|
128
|
+
|
|
129
|
+
fingerprints: Counter[str] = Counter()
|
|
130
|
+
chunk_fp: dict[str, str] = {}
|
|
131
|
+
for cid in self._chunk_ids:
|
|
132
|
+
text = str(self._node[cid].properties.get("text", ""))
|
|
133
|
+
fp = " ".join(text.split())[:120].lower() # whitespace-normalised head
|
|
134
|
+
chunk_fp[cid] = fp
|
|
135
|
+
fingerprints[fp] += 1
|
|
136
|
+
self._boilerplate_chunks = frozenset(
|
|
137
|
+
cid for cid, fp in chunk_fp.items() if fingerprints[fp] > 3
|
|
138
|
+
)
|
|
139
|
+
|
|
105
140
|
# Dual-node PPR graph: entities + chunks joined by relations / SAME_AS /
|
|
106
141
|
# chunk-mention edges (weight = confidence).
|
|
107
142
|
ppr_ids = sorted(self._entity_ids | self._chunk_ids)
|
|
@@ -450,13 +485,17 @@ class QueryEngine:
|
|
|
450
485
|
|
|
451
486
|
# Reciprocal Rank Fusion across the chunk (lexical), entity (graph), and — when a
|
|
452
487
|
# dense embedder is configured — chunk (semantic) lists.
|
|
488
|
+
def _w(cid: str) -> float:
|
|
489
|
+
# Down-weight repeated-template (boilerplate) chunks so they don't dominate.
|
|
490
|
+
return 0.2 if cid in self._boilerplate_chunks else 1.0
|
|
491
|
+
|
|
453
492
|
rrf: dict[str, float] = {}
|
|
454
493
|
for cid, rank in chunk_rank.items():
|
|
455
|
-
rrf[cid] = rrf.get(cid, 0.0) +
|
|
494
|
+
rrf[cid] = rrf.get(cid, 0.0) + _w(cid) / (_RRF_K + rank)
|
|
456
495
|
for nid, rank in entity_rank.items():
|
|
457
496
|
rrf[nid] = rrf.get(nid, 0.0) + 1.0 / (_RRF_K + rank)
|
|
458
497
|
for cid, rank in dense_rank.items():
|
|
459
|
-
rrf[cid] = rrf.get(cid, 0.0) +
|
|
498
|
+
rrf[cid] = rrf.get(cid, 0.0) + _w(cid) / (_RRF_K + rank)
|
|
460
499
|
|
|
461
500
|
routed = self.resolve(query)
|
|
462
501
|
routing = "local" if routed and routed in entity_rank else "global"
|
|
@@ -467,7 +506,7 @@ class QueryEngine:
|
|
|
467
506
|
candidates: list[SearchHit] = []
|
|
468
507
|
for node_id, score in fused:
|
|
469
508
|
if node_id in self._chunk_ids:
|
|
470
|
-
snippet = str(self._node[node_id].properties.get("text", ""))
|
|
509
|
+
snippet = _clean_snippet(str(self._node[node_id].properties.get("text", "")))
|
|
471
510
|
cit = self._chunk_citation.get(node_id)
|
|
472
511
|
candidates.append(
|
|
473
512
|
SearchHit(
|
|
@@ -22,6 +22,7 @@ from dataclasses import dataclass
|
|
|
22
22
|
TOOLS = (
|
|
23
23
|
"auto",
|
|
24
24
|
"reason",
|
|
25
|
+
"narrate",
|
|
25
26
|
"search",
|
|
26
27
|
"path",
|
|
27
28
|
"why",
|
|
@@ -52,6 +53,7 @@ STRATEGY: dict[str, str] = {
|
|
|
52
53
|
"stats": "graph-analytics", # aggregate counts
|
|
53
54
|
"search": "hybrid-lexical-graph", # BM25 + Personalized PageRank + RRF
|
|
54
55
|
"reason": "hybrid-multi-tool", # Graph-of-Thoughts over several of the above
|
|
56
|
+
"narrate": "hybrid-multi-tool", # opt-in LLM answer grounded on retrieved evidence
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
# Ordered cue → tool rules. First match wins; documented so the decision is auditable.
|
|
@@ -140,6 +142,7 @@ def route(question: str, forced: str = "auto") -> RoutePlan:
|
|
|
140
142
|
"decisions": "searches decisions by their statement",
|
|
141
143
|
"communities": "asks about clusters/topics",
|
|
142
144
|
"stats": "asks for aggregate counts",
|
|
145
|
+
"narrate": "opt-in LLM answer grounded on the retrieved evidence",
|
|
143
146
|
"reason": "open question — Graph-of-Thoughts over hybrid retrieval",
|
|
144
147
|
}.get(tool, "hybrid retrieval")
|
|
145
148
|
return RoutePlan(tool=tool, strategy=strategy, reason=reason)
|
|
@@ -6,17 +6,56 @@ keys are canonical-sorted at write time. Conforms to schema/graph.schema.json.
|
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
|
+
import json
|
|
9
10
|
from collections import Counter
|
|
11
|
+
from pathlib import Path
|
|
10
12
|
from typing import Any
|
|
11
13
|
|
|
12
14
|
from textgraph import __version__
|
|
13
15
|
from textgraph.core.canonical_json import canonical_dump_bytes
|
|
16
|
+
from textgraph.core.content_address import hash_text
|
|
14
17
|
from textgraph.core.layout import IngestResult
|
|
15
|
-
from textgraph.store.base import Edge, Node
|
|
18
|
+
from textgraph.store.base import ConfidenceTag, Edge, Node, SourceSpan
|
|
16
19
|
|
|
17
20
|
SCHEMA_VERSION = "1.0"
|
|
18
21
|
|
|
19
22
|
|
|
23
|
+
def load_graph_json(path: str | Path) -> tuple[list[Node], list[Edge]]:
|
|
24
|
+
"""Reconstruct ``(nodes, edges)`` from a written ``graph.json`` artifact.
|
|
25
|
+
|
|
26
|
+
Lets a viewer/engine be built from an *existing* build — including an LLM-enriched one
|
|
27
|
+
(``build --llm-extract``) — without re-running the pipeline. ``graph.json`` doesn't store
|
|
28
|
+
edge ids (they're derived), so a stable content-addressed id is re-synthesised here.
|
|
29
|
+
"""
|
|
30
|
+
doc = json.loads(Path(path).read_text(encoding="utf-8"))
|
|
31
|
+
nodes = [
|
|
32
|
+
Node(node_id=n["node_id"], labels=tuple(n["labels"]), properties=dict(n["properties"]))
|
|
33
|
+
for n in doc["nodes"]
|
|
34
|
+
]
|
|
35
|
+
edges: list[Edge] = []
|
|
36
|
+
for e in doc["edges"]:
|
|
37
|
+
spans = tuple(
|
|
38
|
+
SourceSpan(doc_id=s["doc_id"], start=s["start"], end=s["end"], hash=s["hash"])
|
|
39
|
+
for s in e.get("source_spans", [])
|
|
40
|
+
)
|
|
41
|
+
span_key = "|".join(f"{s.doc_id}|{s.start}|{s.end}" for s in spans)
|
|
42
|
+
edge_id = "edge:" + hash_text(f"{e['subject']}|{e['predicate']}|{e['object']}|{span_key}")
|
|
43
|
+
edges.append(
|
|
44
|
+
Edge(
|
|
45
|
+
edge_id=edge_id,
|
|
46
|
+
subject=e["subject"],
|
|
47
|
+
predicate=e["predicate"],
|
|
48
|
+
object=e["object"],
|
|
49
|
+
tag=ConfidenceTag(e["tag"]),
|
|
50
|
+
confidence=float(e["confidence"]),
|
|
51
|
+
evidence_count=int(e.get("evidence_count", 0)),
|
|
52
|
+
source_spans=spans,
|
|
53
|
+
properties=dict(e.get("properties", {})),
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
return nodes, edges
|
|
57
|
+
|
|
58
|
+
|
|
20
59
|
def _node_dict(n: Node) -> dict[str, Any]:
|
|
21
60
|
return {
|
|
22
61
|
"node_id": n.node_id,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{textgraph_kg-3.3.2 → textgraph_kg-3.5.0}/tests/fixtures/corpora/adr/adr-0007-case-linking.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|