Skip to content

Commit f5b07dc

Browse files
authored
Merge pull request #1857 from Agenta-AI/fix/different-errors-playground-evaluations
fix(backend): AGE-391 Fix different error info in playground and evals
2 parents 43bfa84 + 511586a commit f5b07dc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

agenta-backend/agenta_backend/services/llm_apps_service.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ async def invoke_app(
8282
url = f"{uri}/generate"
8383
payload = await make_payload(datapoint, parameters, openapi_parameters)
8484
async with aiohttp.ClientSession() as client:
85+
app_response = {}
86+
8587
try:
8688
logger.debug(f"Invoking app {uri} with payload {payload}")
8789
response = await client.post(url, json=payload, timeout=900)
88-
response.raise_for_status()
8990
app_response = await response.json()
91+
response.raise_for_status()
9092
return InvokationResult(
9193
result=Result(
9294
type="text",
@@ -98,8 +100,12 @@ async def invoke_app(
98100
)
99101

100102
except aiohttp.ClientResponseError as e:
101-
error_message = f"HTTP error {e.status}: {e.message}"
102-
stacktrace = "".join(traceback.format_exception_only(type(e), e))
103+
error_message = app_response.get("detail", {}).get(
104+
"error", f"HTTP error {e.status}: {e.message}"
105+
)
106+
stacktrace = app_response.get("detail", {}).get(
107+
"traceback", "".join(traceback.format_exception_only(type(e), e))
108+
)
103109
logger.error(f"HTTP error occurred during request: {error_message}")
104110
common.capture_exception_in_sentry(e)
105111
except aiohttp.ServerTimeoutError as e:
@@ -184,6 +190,7 @@ async def run_with_retry(
184190
if retries == max_retry_count
185191
else f"Error processing {input_data} datapoint"
186192
)
193+
187194
return InvokationResult(
188195
result=Result(
189196
type="error",
@@ -245,6 +252,7 @@ async def run_batch(start_idx: int):
245252

246253
# Gather results of all tasks
247254
results = await asyncio.gather(*tasks)
255+
248256
for result in results:
249257
list_of_app_outputs.append(result)
250258
print(f"Adding outputs to batch {start_idx}")
@@ -257,6 +265,7 @@ async def run_batch(start_idx: int):
257265

258266
# Start the first batch
259267
await run_batch(0)
268+
260269
return list_of_app_outputs
261270

262271

0 commit comments

Comments
 (0)