We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c205933 commit 43b7128Copy full SHA for 43b7128
1 file changed
codeinterpreterapi/session.py
@@ -109,7 +109,10 @@ async def arun_handler(self, code: str):
109
return f"Image {filename} got send to the user."
110
111
elif output.type == "error":
112
- # TODO: check if package install is required
+ if "ModuleNotFoundError" in output.content:
113
+ if package := re.search(r"ModuleNotFoundError: No module named '(.*)'", output.content):
114
+ await self.codebox.ainstall(package.group(1))
115
+ return f"{package.group(1)} was missing but got installed now. Please try again."
116
# TODO: preanalyze error to optimize next code generation
117
print("Error:", output.content)
118
0 commit comments