Spaces:
Runtime error
Runtime error
Commit
·
cb01cad
1
Parent(s):
35b9b9e
update code runner
Browse files
app.py
CHANGED
|
@@ -142,8 +142,11 @@ def Code_Runner(code_raw: str):
|
|
| 142 |
global CurrentAgent
|
| 143 |
if CurrentAgent == "Zero Short React 2":
|
| 144 |
code_raw = RemoveIndent(code_raw)
|
| 145 |
-
if '!pip' in code_raw:
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
| 147 |
interpreter = CodeInterpreter(language="shell", debug_mode=True)
|
| 148 |
else:
|
| 149 |
interpreter = CodeInterpreter(language="python", debug_mode=True)
|
|
@@ -152,8 +155,11 @@ def Code_Runner(code_raw: str):
|
|
| 152 |
interpreter.active_block = code_block
|
| 153 |
output = interpreter.run()
|
| 154 |
print("Real Output: \n", output)
|
| 155 |
-
|
| 156 |
-
output
|
|
|
|
|
|
|
|
|
|
| 157 |
return output
|
| 158 |
|
| 159 |
def RemoveIndent(code_string, indentation_level=4):
|
|
|
|
| 142 |
global CurrentAgent
|
| 143 |
if CurrentAgent == "Zero Short React 2":
|
| 144 |
code_raw = RemoveIndent(code_raw)
|
| 145 |
+
if '!pip' in code_raw or 'pip install' in code_raw:
|
| 146 |
+
try:
|
| 147 |
+
code_raw=code_raw.replace('!pip', 'pip')
|
| 148 |
+
except Exception as e:
|
| 149 |
+
print(e)
|
| 150 |
interpreter = CodeInterpreter(language="shell", debug_mode=True)
|
| 151 |
else:
|
| 152 |
interpreter = CodeInterpreter(language="python", debug_mode=True)
|
|
|
|
| 155 |
interpreter.active_block = code_block
|
| 156 |
output = interpreter.run()
|
| 157 |
print("Real Output: \n", output)
|
| 158 |
+
try:
|
| 159 |
+
if output.strip() =="" or output == []:
|
| 160 |
+
output = "It is Done. No Error Found."
|
| 161 |
+
except Exception as e:
|
| 162 |
+
print(e)
|
| 163 |
return output
|
| 164 |
|
| 165 |
def RemoveIndent(code_string, indentation_level=4):
|