Post-run operations, including: 1. Dumping the run configuration. 2. Dumping the LLM call history.
(self)
| 288 | return polished_article |
| 289 | |
| 290 | def post_run(self): |
| 291 | """ |
| 292 | Post-run operations, including: |
| 293 | 1. Dumping the run configuration. |
| 294 | 2. Dumping the LLM call history. |
| 295 | """ |
| 296 | config_log = self.lm_configs.log() |
| 297 | FileIOHelper.dump_json( |
| 298 | config_log, os.path.join(self.article_output_dir, "run_config.json") |
| 299 | ) |
| 300 | |
| 301 | llm_call_history = self.lm_configs.collect_and_reset_lm_history() |
| 302 | with open( |
| 303 | os.path.join(self.article_output_dir, "llm_call_history.jsonl"), "w" |
| 304 | ) as f: |
| 305 | for call in llm_call_history: |
| 306 | if "kwargs" in call: |
| 307 | call.pop( |
| 308 | "kwargs" |
| 309 | ) # All kwargs are dumped together to run_config.json. |
| 310 | f.write(json.dumps(call) + "\n") |
| 311 | |
| 312 | def _load_information_table_from_local_fs(self, information_table_local_path): |
| 313 | assert os.path.exists(information_table_local_path), makeStringRed( |