Skip to content

Commit 321d479

Browse files
authored
Update notebooks for 2.0 (#1785)
* Update API overview * Fix global search example * Fix local search example * Fix global dynamic example * Fix drift example * Update multi-index example * Semver
1 parent 0d363e6 commit 321d479

File tree

205 files changed

+225
-5820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+225
-5820
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "patch",
3+
"description": "Update llm args for consistency."
4+
}

docs/examples_notebooks/api_overview.ipynb

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,14 @@
2525
"metadata": {},
2626
"outputs": [],
2727
"source": [
28-
"import graphrag.api as api\n",
29-
"from graphrag.index.typing import PipelineRunResult"
30-
]
31-
},
32-
{
33-
"cell_type": "markdown",
34-
"metadata": {},
35-
"source": [
36-
"## Prerequisite\n",
37-
"As a prerequisite to all API operations, a `GraphRagConfig` object is required. It is the primary means to control the behavior of graphrag and can be instantiated from a `settings.yaml` configuration file.\n",
28+
"from pathlib import Path\n",
29+
"from pprint import pprint\n",
3830
"\n",
39-
"Please refer to the [CLI docs](https://microsoft.github.io/graphrag/cli/#init) for more detailed information on how to generate the `settings.yaml` file.\n",
31+
"import pandas as pd\n",
4032
"\n",
41-
"#### Load `settings.yaml` configuration"
33+
"import graphrag.api as api\n",
34+
"from graphrag.config.load_config import load_config\n",
35+
"from graphrag.index.typing.pipeline_run_result import PipelineRunResult"
4236
]
4337
},
4438
{
@@ -47,17 +41,17 @@
4741
"metadata": {},
4842
"outputs": [],
4943
"source": [
50-
"import yaml\n",
51-
"\n",
52-
"PROJECT_DIRECTORY = \"<project_directory>\"\n",
53-
"settings = yaml.safe_load(open(f\"{PROJECT_DIRECTORY}/settings.yaml\")) # noqa: PTH123, SIM115"
44+
"PROJECT_DIRECTORY = \"<your project directory>\""
5445
]
5546
},
5647
{
5748
"cell_type": "markdown",
5849
"metadata": {},
5950
"source": [
60-
"At this point, you can modify the imported settings to align with your application's requirements. For example, if building a UI application, the application might need to change the input and/or storage destinations dynamically in order to enable users to build and query different indexes."
51+
"## Prerequisite\n",
52+
"As a prerequisite to all API operations, a `GraphRagConfig` object is required. It is the primary means to control the behavior of graphrag and can be instantiated from a `settings.yaml` configuration file.\n",
53+
"\n",
54+
"Please refer to the [CLI docs](https://microsoft.github.io/graphrag/cli/#init) for more detailed information on how to generate the `settings.yaml` file."
6155
]
6256
},
6357
{
@@ -73,9 +67,7 @@
7367
"metadata": {},
7468
"outputs": [],
7569
"source": [
76-
"from graphrag.config.create_graphrag_config import create_graphrag_config\n",
77-
"\n",
78-
"graphrag_config = create_graphrag_config(values=settings, root_dir=PROJECT_DIRECTORY)"
70+
"graphrag_config = load_config(Path(PROJECT_DIRECTORY))"
7971
]
8072
},
8173
{
@@ -123,19 +115,17 @@
123115
"metadata": {},
124116
"outputs": [],
125117
"source": [
126-
"import pandas as pd\n",
127-
"\n",
128-
"final_entities = pd.read_parquet(f\"{PROJECT_DIRECTORY}/output/entities.parquet\")\n",
129-
"final_communities = pd.read_parquet(f\"{PROJECT_DIRECTORY}/output/communities.parquet\")\n",
130-
"final_community_reports = pd.read_parquet(\n",
118+
"entities = pd.read_parquet(f\"{PROJECT_DIRECTORY}/output/entities.parquet\")\n",
119+
"communities = pd.read_parquet(f\"{PROJECT_DIRECTORY}/output/communities.parquet\")\n",
120+
"community_reports = pd.read_parquet(\n",
131121
" f\"{PROJECT_DIRECTORY}/output/community_reports.parquet\"\n",
132122
")\n",
133123
"\n",
134124
"response, context = await api.global_search(\n",
135125
" config=graphrag_config,\n",
136-
" entities=final_entities,\n",
137-
" communities=final_communities,\n",
138-
" community_reports=final_community_reports,\n",
126+
" entities=entities,\n",
127+
" communities=communities,\n",
128+
" community_reports=community_reports,\n",
139129
" community_level=2,\n",
140130
" dynamic_community_selection=False,\n",
141131
" response_type=\"Multiple Paragraphs\",\n",
@@ -172,15 +162,13 @@
172162
"metadata": {},
173163
"outputs": [],
174164
"source": [
175-
"from pprint import pprint\n",
176-
"\n",
177165
"pprint(context) # noqa: T203"
178166
]
179167
}
180168
],
181169
"metadata": {
182170
"kernelspec": {
183-
"display_name": "graphrag-venv",
171+
"display_name": ".venv",
184172
"language": "python",
185173
"name": "python3"
186174
},
@@ -194,7 +182,7 @@
194182
"name": "python",
195183
"nbconvert_exporter": "python",
196184
"pygments_lexer": "ipython3",
197-
"version": "3.10.15"
185+
"version": "3.11.9"
198186
}
199187
},
200188
"nbformat": 4,

0 commit comments

Comments
 (0)