-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper-interpreter.py
More file actions
30 lines (24 loc) · 892 Bytes
/
Copy pathwrapper-interpreter.py
File metadata and controls
30 lines (24 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from asyncio import timeout, TimeoutError, run
import sys
import json
sys.path.insert(0, "MetaGPT-DataExplainer/metagpt")
from metagpt.logs import logger
from metagpt.roles.de.data_explainer import DataExplainer
from metagpt.roles.di.data_interpreter import DataInterpreter
from metagpt.utils.recovery_util import save_history
async def _explain(request, save_dir):
di = DataInterpreter()
try:
async with timeout(7200):
rsp = await di.run(request)
except TimeoutError as e:
rsp = "========TIMEOUT======="
print("========TIMEOUT=======")
except Exception as e:
rsp = "========ERROR======="
print("========ERROR=======")
logger.info(rsp)
save_history(role=di, save_dir=save_dir)
with open("current-comp.json") as in_file:
in_json = json.load(in_file)
run(_explain(in_json['request'], in_json['output_dir']))