mindgraph-sdk 0.2.1__tar.gz → 0.3.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.
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/PKG-INFO +1 -1
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/mindgraph/client.py +99 -10
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/pyproject.toml +1 -1
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/.github/workflows/publish.yml +0 -0
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/CHANGELOG.md +0 -0
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/README.md +0 -0
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/examples/README.md +0 -0
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/examples/research_continuity.py +0 -0
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/mindgraph/__init__.py +0 -0
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/tests/__init__.py +0 -0
- {mindgraph_sdk-0.2.1 → mindgraph_sdk-0.3.0}/tests/test_integration.py +0 -0
|
@@ -580,7 +580,16 @@ class MindGraph:
|
|
|
580
580
|
node_type: str | None = None,
|
|
581
581
|
layer: str | None = None,
|
|
582
582
|
limit: int | None = None,
|
|
583
|
-
|
|
583
|
+
min_score: float | None = None,
|
|
584
|
+
include_edges: bool = False,
|
|
585
|
+
include_chunks: bool = False,
|
|
586
|
+
) -> list[dict[str, Any]] | dict[str, Any]:
|
|
587
|
+
"""Full-text search over nodes.
|
|
588
|
+
|
|
589
|
+
When ``include_edges`` or ``include_chunks`` is True the response is an
|
|
590
|
+
enriched dict with ``results``, ``edges``, and ``chunks`` keys.
|
|
591
|
+
Otherwise a flat list of search results is returned.
|
|
592
|
+
"""
|
|
584
593
|
body: dict[str, Any] = {"query": query}
|
|
585
594
|
if node_type:
|
|
586
595
|
body["node_type"] = node_type
|
|
@@ -588,6 +597,12 @@ class MindGraph:
|
|
|
588
597
|
body["layer"] = layer
|
|
589
598
|
if limit:
|
|
590
599
|
body["limit"] = limit
|
|
600
|
+
if min_score is not None:
|
|
601
|
+
body["min_score"] = min_score
|
|
602
|
+
if include_edges:
|
|
603
|
+
body["include_edges"] = True
|
|
604
|
+
if include_chunks:
|
|
605
|
+
body["include_chunks"] = True
|
|
591
606
|
return self._request("POST", "/search", body)
|
|
592
607
|
|
|
593
608
|
def hybrid_search(
|
|
@@ -914,31 +929,50 @@ class MindGraph:
|
|
|
914
929
|
self,
|
|
915
930
|
query: str,
|
|
916
931
|
*,
|
|
917
|
-
|
|
918
|
-
|
|
932
|
+
node_limit: int | None = None,
|
|
933
|
+
article_limit: int | None = None,
|
|
934
|
+
chunk_limit: int | None = None,
|
|
919
935
|
node_types: list[str] | None = None,
|
|
920
936
|
layer: str | None = None,
|
|
921
|
-
include_chunks: bool | None = None,
|
|
922
937
|
include_graph: bool | None = None,
|
|
923
938
|
min_similarity: float | None = None,
|
|
924
939
|
) -> dict[str, Any]:
|
|
940
|
+
"""Retrieve context from the knowledge graph.
|
|
941
|
+
|
|
942
|
+
Returns articles (synthesized wiki summaries), graph nodes with
|
|
943
|
+
source_documents provenance, and optionally raw chunks.
|
|
944
|
+
|
|
945
|
+
Args:
|
|
946
|
+
query: Natural language search query.
|
|
947
|
+
node_limit: Max graph nodes (default 10).
|
|
948
|
+
article_limit: Max wiki articles (default 3). Set 0 to skip.
|
|
949
|
+
chunk_limit: Max raw chunks (default 0). Set >0 to include source text.
|
|
950
|
+
node_types: Filter to specific node types.
|
|
951
|
+
layer: Filter to a specific layer.
|
|
952
|
+
include_graph: Include graph nodes and edges (default True).
|
|
953
|
+
min_similarity: Minimum similarity threshold.
|
|
954
|
+
"""
|
|
925
955
|
body: dict[str, Any] = {"query": query}
|
|
926
|
-
if
|
|
927
|
-
body["
|
|
928
|
-
if
|
|
929
|
-
body["
|
|
956
|
+
if node_limit is not None:
|
|
957
|
+
body["node_limit"] = node_limit
|
|
958
|
+
if article_limit is not None:
|
|
959
|
+
body["article_limit"] = article_limit
|
|
960
|
+
if chunk_limit is not None:
|
|
961
|
+
body["chunk_limit"] = chunk_limit
|
|
930
962
|
if node_types:
|
|
931
963
|
body["node_types"] = node_types
|
|
932
964
|
if layer:
|
|
933
965
|
body["layer"] = layer
|
|
934
|
-
if include_chunks is not None:
|
|
935
|
-
body["include_chunks"] = include_chunks
|
|
936
966
|
if include_graph is not None:
|
|
937
967
|
body["include_graph"] = include_graph
|
|
938
968
|
if min_similarity is not None:
|
|
939
969
|
body["min_similarity"] = min_similarity
|
|
940
970
|
return self._request("POST", "/retrieve/context", body)
|
|
941
971
|
|
|
972
|
+
def backfill_node_sources(self) -> dict[str, Any]:
|
|
973
|
+
"""Backfill node_source provenance from existing ExtractedFrom edges."""
|
|
974
|
+
return self._request("POST", "/backfill/node-sources", {})
|
|
975
|
+
|
|
942
976
|
def list_jobs(self) -> list[dict[str, Any]]:
|
|
943
977
|
return self._request("GET", "/jobs")
|
|
944
978
|
|
|
@@ -976,3 +1010,58 @@ class MindGraph:
|
|
|
976
1010
|
def clear_graph(self) -> dict[str, Any]:
|
|
977
1011
|
return self._request("POST", "/clear")
|
|
978
1012
|
|
|
1013
|
+
# ── Wiki ──────────────────────────────────────────────────────────────
|
|
1014
|
+
|
|
1015
|
+
def list_articles(
|
|
1016
|
+
self,
|
|
1017
|
+
*,
|
|
1018
|
+
article_type: str | None = None,
|
|
1019
|
+
covers_node_type: str | None = None,
|
|
1020
|
+
search: str | None = None,
|
|
1021
|
+
limit: int | None = None,
|
|
1022
|
+
offset: int | None = None,
|
|
1023
|
+
) -> dict[str, Any]:
|
|
1024
|
+
"""List wiki articles with optional filters."""
|
|
1025
|
+
params: dict[str, str] = {}
|
|
1026
|
+
if article_type:
|
|
1027
|
+
params["article_type"] = article_type
|
|
1028
|
+
if covers_node_type:
|
|
1029
|
+
params["covers_node_type"] = covers_node_type
|
|
1030
|
+
if search:
|
|
1031
|
+
params["search"] = search
|
|
1032
|
+
if limit is not None:
|
|
1033
|
+
params["limit"] = str(limit)
|
|
1034
|
+
if offset is not None:
|
|
1035
|
+
params["offset"] = str(offset)
|
|
1036
|
+
qs = "&".join(f"{k}={v}" for k, v in params.items())
|
|
1037
|
+
return self._request("GET", f"/wiki/articles?{qs}" if qs else "/wiki/articles")
|
|
1038
|
+
|
|
1039
|
+
def get_article(self, uid: str) -> dict[str, Any]:
|
|
1040
|
+
"""Get a single wiki article by UID."""
|
|
1041
|
+
return self._request("GET", f"/wiki/article/{uid}")
|
|
1042
|
+
|
|
1043
|
+
def get_article_by_subject(self, subject_uid: str) -> dict[str, Any] | None:
|
|
1044
|
+
"""Find the article that covers or summarizes a given entity/document UID."""
|
|
1045
|
+
try:
|
|
1046
|
+
return self._request("GET", f"/wiki/article/by-subject/{subject_uid}")
|
|
1047
|
+
except MindGraphError as e:
|
|
1048
|
+
if e.status == 404:
|
|
1049
|
+
return None
|
|
1050
|
+
raise
|
|
1051
|
+
|
|
1052
|
+
def update_article(self, uid: str, content: str) -> dict[str, Any]:
|
|
1053
|
+
"""Update an article's markdown content (user editing)."""
|
|
1054
|
+
return self._request("PATCH", f"/wiki/article/{uid}", {"content": content})
|
|
1055
|
+
|
|
1056
|
+
def compile_document(self, doc_uid: str) -> dict[str, Any]:
|
|
1057
|
+
"""Trigger wiki compilation for a specific document."""
|
|
1058
|
+
return self._request("POST", f"/wiki/compile/{doc_uid}")
|
|
1059
|
+
|
|
1060
|
+
def compile_entity(self, entity_uid: str) -> dict[str, Any]:
|
|
1061
|
+
"""Trigger wiki compilation for a specific entity."""
|
|
1062
|
+
return self._request("POST", f"/wiki/compile/entity/{entity_uid}")
|
|
1063
|
+
|
|
1064
|
+
def compile_all(self) -> dict[str, Any]:
|
|
1065
|
+
"""Backfill: compile articles for all documents and eligible entities."""
|
|
1066
|
+
return self._request("POST", "/wiki/compile/all")
|
|
1067
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|