Client
UAEFClient calls a deployed UAEF service over HTTP instead of evaluating in-process. Use
it when the heavy metric backends should live in the service, not in your application.
uaef.client
Optional UAEF client SDK.
UAEFClient is a thin HTTP wrapper that gives remote users the same
ergonomics as the local uaef.api.evaluate / batch_evaluate functions
while hiding the asynchronous POST-then-poll mechanics of the UAEF service.
This module ships with the library behind the client extra::
pip install 'uaef[client]'
The only third-party dependency is requests. It is imported lazily/guarded
so that importing the core uaef package never fails when the client
extra is not installed.
Example
from uaef.client import UAEFClient client = UAEFClient(endpoint="https://api.example.com", token=jwt) result = client.evaluate(trace=trace, ground_truth=gt, persist=True, ... experiment_name="remote-run")
JobFailedError
Bases: RuntimeError
Raised when a polled job reaches a FAILED terminal state.
Carries the job's error code and message so callers can inspect the
failure programmatically (Requirement 10.8).
Source code in uaef/client/__init__.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
UAEFClient
Synchronous client for the UAEF HTTP service.
The client submits an evaluation request, polls the job-status endpoint at a fixed interval until the job reaches a terminal state, and returns the result, hiding the POST-and-poll mechanics from the caller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Base URL of the UAEF service (e.g. |
required |
token
|
str
|
Cognito-issued JWT used as a bearer token on every request. |
required |
poll_interval
|
float
|
Seconds between job-status polls. Fixed at 2.0s per Requirement 10.5. |
_DEFAULT_POLL_INTERVAL
|
timeout
|
float
|
Maximum seconds to wait for a terminal state before raising a timeout error. Defaults to 900s (15 minutes) per Requirement 10.6. This is the OVERALL job wait, spread across many short polls — it is not the per-request timeout below. |
_DEFAULT_TIMEOUT
|
request_timeout
|
Union[float, Tuple[float, float]]
|
Per-request (connect, read) timeout in seconds for the quick API calls (submit, presign, status poll). A single float sets both. Prevents an unresponsive connection from hanging forever without capping total job time. Defaults to (10, 60). |
_DEFAULT_REQUEST_TIMEOUT
|
transfer_timeout
|
Union[float, Tuple[float, float]]
|
Per-request (connect, read) timeout in seconds for the data-transfer calls (S3 payload upload and result download), which may move large payloads. Defaults to (10, 300). |
_DEFAULT_TRANSFER_TIMEOUT
|
Source code in uaef/client/__init__.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
batch_evaluate(traces, ground_truths=None, adapter=None, metrics=None, max_workers=4, persist=False, experiment_name=None, experiment_objective=None)
Submit a batch evaluation and return the result.
Mirrors the core arguments of uaef.api.batch_evaluate. The call is
made against the service's POST /batch-evaluate endpoint, which is
asynchronous: the request body is submitted, a jobId is returned,
and this method polls the job until it reaches a terminal state before
returning the completed result payload (Requirements 10.3, 10.4).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces
|
List of agent traces to evaluate. |
required | |
ground_truths
|
List of expected correct outputs (optional). |
None
|
|
adapter
|
Optional[str]
|
Framework adapter name. |
None
|
metrics
|
Optional[List[str]]
|
Flat list of curated, server-side metric names. |
None
|
max_workers
|
int
|
Maximum number of parallel workers on the service side. |
4
|
persist
|
bool
|
If True, the service creates and persists an experiment. |
False
|
experiment_name
|
Optional[str]
|
Name for the new experiment when |
None
|
experiment_objective
|
Optional[str]
|
Description/objective for the experiment. |
None
|
Returns:
| Type | Description |
|---|---|
|
The completed batch evaluation result payload (the full result |
|
|
fetched from |
|
|
|
Source code in uaef/client/__init__.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
evaluate(trace, ground_truth=None, adapter=None, metrics=None, context=None, persist=False, experiment_name=None, experiment_objective=None)
Submit a single evaluation and return the result.
Mirrors the core arguments of uaef.api.evaluate. The call is made
against the service's POST /evaluate endpoint, which is
asynchronous: the request body is submitted, a jobId is returned,
and this method polls the job until it reaches a terminal state before
returning the completed result payload (Requirements 10.2, 10.4).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
Agent trace to evaluate (canonical or raw output dict). |
required | |
ground_truth
|
Expected correct outputs (optional). |
None
|
|
adapter
|
Optional[str]
|
Framework adapter name ("langgraph", "bedrock", etc.). |
None
|
metrics
|
Optional[List[str]]
|
Flat list of curated, server-side metric names. |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional). |
None
|
persist
|
bool
|
If True, the service creates and persists an experiment. |
False
|
experiment_name
|
Optional[str]
|
Name for the new experiment when |
None
|
experiment_objective
|
Optional[str]
|
Description/objective for the experiment. |
None
|
Returns:
| Type | Description |
|---|---|
|
The completed evaluation result payload (the full result fetched |
|
|
from |
|
|
|
Source code in uaef/client/__init__.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
get_job(job_id)
Fetch the current status record for a job.
Source code in uaef/client/__init__.py
270 271 272 | |