Spaces:
Runtime error
Runtime error
Shroominic
commited on
Commit
·
43b7128
1
Parent(s):
c205933
package install on error
Browse files
codeinterpreterapi/session.py
CHANGED
|
@@ -109,7 +109,10 @@ class CodeInterpreterSession():
|
|
| 109 |
return f"Image {filename} got send to the user."
|
| 110 |
|
| 111 |
elif output.type == "error":
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
| 113 |
# TODO: preanalyze error to optimize next code generation
|
| 114 |
print("Error:", output.content)
|
| 115 |
|
|
|
|
| 109 |
return f"Image {filename} got send to the user."
|
| 110 |
|
| 111 |
elif output.type == "error":
|
| 112 |
+
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 |
|