@@ -185,35 +185,41 @@ def _initialize_project_at(path: str, reporter: ProgressReporter) -> None:
185185
186186 dotenv = root / ".env"
187187 if not dotenv .exists ():
188- with settings_yaml .open ("w " ) as file :
189- file .write (INIT_YAML )
188+ with settings_yaml .open ("wb " ) as file :
189+ file .write (INIT_YAML . encode ( encoding = "utf-8" , errors = "strict" ) )
190190
191- with dotenv .open ("w " ) as file :
192- file .write (INIT_DOTENV )
191+ with dotenv .open ("wb " ) as file :
192+ file .write (INIT_DOTENV . encode ( encoding = "utf-8" , errors = "strict" ) )
193193
194194 prompts_dir = root / "prompts"
195195 if not prompts_dir .exists ():
196196 prompts_dir .mkdir (parents = True , exist_ok = True )
197197
198198 entity_extraction = prompts_dir / "entity_extraction.txt"
199199 if not entity_extraction .exists ():
200- with entity_extraction .open ("w" ) as file :
201- file .write (GRAPH_EXTRACTION_PROMPT )
200+ with entity_extraction .open ("wb" ) as file :
201+ file .write (
202+ GRAPH_EXTRACTION_PROMPT .encode (encoding = "utf-8" , errors = "strict" )
203+ )
202204
203205 summarize_descriptions = prompts_dir / "summarize_descriptions.txt"
204206 if not summarize_descriptions .exists ():
205- with summarize_descriptions .open ("w " ) as file :
206- file .write (SUMMARIZE_PROMPT )
207+ with summarize_descriptions .open ("wb " ) as file :
208+ file .write (SUMMARIZE_PROMPT . encode ( encoding = "utf-8" , errors = "strict" ) )
207209
208210 claim_extraction = prompts_dir / "claim_extraction.txt"
209211 if not claim_extraction .exists ():
210- with claim_extraction .open ("w" ) as file :
211- file .write (CLAIM_EXTRACTION_PROMPT )
212+ with claim_extraction .open ("wb" ) as file :
213+ file .write (
214+ CLAIM_EXTRACTION_PROMPT .encode (encoding = "utf-8" , errors = "strict" )
215+ )
212216
213217 community_report = prompts_dir / "community_report.txt"
214218 if not community_report .exists ():
215- with community_report .open ("w" ) as file :
216- file .write (COMMUNITY_REPORT_PROMPT )
219+ with community_report .open ("wb" ) as file :
220+ file .write (
221+ COMMUNITY_REPORT_PROMPT .encode (encoding = "utf-8" , errors = "strict" )
222+ )
217223
218224
219225def _create_default_config (
@@ -267,18 +273,18 @@ def _read_config_parameters(root: str, config: str | None, reporter: ProgressRep
267273
268274 if settings_yaml .exists ():
269275 reporter .success (f"Reading settings from { settings_yaml } " )
270- with settings_yaml .open ("r " ) as file :
276+ with settings_yaml .open ("rb " ) as file :
271277 import yaml
272278
273- data = yaml .safe_load (file )
279+ data = yaml .safe_load (file . read (). decode ( encoding = "utf-8" , errors = "strict" ) )
274280 return create_graphrag_config (data , root )
275281
276282 if settings_json .exists ():
277283 reporter .success (f"Reading settings from { settings_json } " )
278- with settings_json .open ("r " ) as file :
284+ with settings_json .open ("rb " ) as file :
279285 import json
280286
281- data = json .loads (file .read ())
287+ data = json .loads (file .read (). decode ( encoding = "utf-8" , errors = "strict" ) )
282288 return create_graphrag_config (data , root )
283289
284290 reporter .success ("Reading settings from environment variables" )
0 commit comments