Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -145,16 +145,10 @@ class SuperSmartAgent:
|
|
| 145 |
return state
|
| 146 |
|
| 147 |
def execute_python_code(self, state):
|
| 148 |
-
question = state["question"]
|
| 149 |
file_name = state.get("file_name")
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
if code_blocks:
|
| 154 |
-
code = textwrap.dedent(code_blocks[0]).strip()
|
| 155 |
-
elif file_name and file_name.endswith(".py"):
|
| 156 |
-
# Case 2: Load code from attached Python file
|
| 157 |
-
file_path = os.path.join("data", file_name) # Make sure this path matches the actual mount
|
| 158 |
try:
|
| 159 |
with open(file_path, "r") as f:
|
| 160 |
code = f.read()
|
|
@@ -162,14 +156,8 @@ class SuperSmartAgent:
|
|
| 162 |
state["response"] = f"Error loading Python file: {e}"
|
| 163 |
return state
|
| 164 |
else:
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
def calculate():
|
| 168 |
-
return 5
|
| 169 |
-
|
| 170 |
-
result = calculate()
|
| 171 |
-
print(result)
|
| 172 |
-
"""
|
| 173 |
|
| 174 |
try:
|
| 175 |
result = code_interpreter(code)
|
|
@@ -182,6 +170,7 @@ class SuperSmartAgent:
|
|
| 182 |
|
| 183 |
|
| 184 |
|
|
|
|
| 185 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 186 |
"""
|
| 187 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 145 |
return state
|
| 146 |
|
| 147 |
def execute_python_code(self, state):
|
|
|
|
| 148 |
file_name = state.get("file_name")
|
| 149 |
|
| 150 |
+
if file_name and file_name.endswith(".py"):
|
| 151 |
+
file_path = os.path.join("data", file_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
try:
|
| 153 |
with open(file_path, "r") as f:
|
| 154 |
code = f.read()
|
|
|
|
| 156 |
state["response"] = f"Error loading Python file: {e}"
|
| 157 |
return state
|
| 158 |
else:
|
| 159 |
+
state["response"] = "No valid Python file attached."
|
| 160 |
+
return state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
try:
|
| 163 |
result = code_interpreter(code)
|
|
|
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
+
|
| 174 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 175 |
"""
|
| 176 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|