Skip to content

Commit 5898437

Browse files
authored
Show the model name, and request info if possible, on error (#226)
* Show the model name, and request info if possible, on error Signed-off-by: Ed Snible <[email protected]> * Order imports Signed-off-by: Ed Snible <[email protected]> --------- Signed-off-by: Ed Snible <[email protected]>
1 parent fc0a901 commit 5898437

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pathlib import Path
1111
from typing import Any, Generator, Optional, Sequence, TypeVar
1212

13+
import httpx
1314
import litellm
1415
import yaml
1516
from jinja2 import (
@@ -1140,8 +1141,15 @@ def get_transformed_inputs(kwargs):
11401141
if block.modelResponse is not None:
11411142
scope = scope | {block.modelResponse: raw_result}
11421143
return result, background, scope, trace
1144+
except httpx.RequestError as exc:
1145+
message = f"model '{block.model}' encountered {repr(exc)} trying to {exc.request.method} against {exc.request.url}"
1146+
raise PDLRuntimeError(
1147+
message,
1148+
loc=loc,
1149+
trace=ErrorBlock(msg=message, location=loc, program=concrete_block),
1150+
) from exc
11431151
except Exception as exc:
1144-
message = f"Error during model call: {repr(exc)}"
1152+
message = f"Error during '{block.model}' model call: {repr(exc)}"
11451153
raise PDLRuntimeError(
11461154
message,
11471155
loc=loc,

0 commit comments

Comments
 (0)