added csv-code executor
Browse files- controller.py +3 -10
controller.py
CHANGED
@@ -214,7 +214,7 @@ class ExecutionRequest(BaseModel):
|
|
214 |
|
215 |
@app.post("/api/code_execution_csv")
|
216 |
async def code_execution_csv(
|
217 |
-
request_data:
|
218 |
authorization: Optional[str] = Header(None)
|
219 |
):
|
220 |
# Auth check remains the same
|
@@ -225,19 +225,12 @@ async def code_execution_csv(
|
|
225 |
try:
|
226 |
# First log the incoming request data
|
227 |
logger.info("Incoming request data:", request_data)
|
228 |
-
|
229 |
-
# Then validate
|
230 |
-
try:
|
231 |
-
request = ExecutionRequest(**request_data)
|
232 |
-
except ValidationError as e:
|
233 |
-
logger.info("Validation error:", e.json())
|
234 |
-
raise HTTPException(status_code=422, detail=e.errors())
|
235 |
|
236 |
# Rest of your processing logic...
|
237 |
-
decoded_url = unquote(
|
238 |
df = clean_data(decoded_url)
|
239 |
executor = PythonExecutor(df)
|
240 |
-
formatted_output = await executor.process_response(
|
241 |
return {"answer": formatted_output}
|
242 |
|
243 |
except Exception as e:
|
|
|
214 |
|
215 |
@app.post("/api/code_execution_csv")
|
216 |
async def code_execution_csv(
|
217 |
+
request_data: ExecutionRequest, # Change from ExecutionRequest to dict to see raw input
|
218 |
authorization: Optional[str] = Header(None)
|
219 |
):
|
220 |
# Auth check remains the same
|
|
|
225 |
try:
|
226 |
# First log the incoming request data
|
227 |
logger.info("Incoming request data:", request_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
# Rest of your processing logic...
|
230 |
+
decoded_url = unquote(request_data.csv_url)
|
231 |
df = clean_data(decoded_url)
|
232 |
executor = PythonExecutor(df)
|
233 |
+
formatted_output = await executor.process_response(request_data.codeExecutionPayload, request_data.chat_id)
|
234 |
return {"answer": formatted_output}
|
235 |
|
236 |
except Exception as e:
|