falaw.results#
Result wrapper: parse fal responses into typed assets, lazy download.
Functions
|
Best-effort parser over the common fal response shapes. |
|
Extension implied by the leading bytes ('' if unrecognised). |
Classes
|
A single piece of generated media. |
|
A fal call result with parsed assets and the original raw response. |
- class falaw.results.Asset(url, kind, content_type='', width=0, height=0, duration_s=0.0, metadata=<factory>)[source]#
Bases:
objectA single piece of generated media.
Holds the URL plus minimal typed metadata.
downloadmaterializes it.- download(*, to=None, fix_suffix=False)[source]#
Download the asset to a file. Returns the local path.
The bytes are sniffed: some models return a different format than the usual one (Recraft’s
vector_illustration/*styles return SVG, not PNG). If the suffix oftocontradicts the content, aUserWarningis issued; withfix_suffix=Truethe suffix is corrected instead (so the returned path may differ fromto).- Return type:
- class falaw.results.Result(assets=<factory>, raw=<factory>, application='', arguments=<factory>)[source]#
Bases:
objectA fal call result with parsed assets and the original raw response.
The raw response is kept so callers can inspect provider-specific fields (timings, seed, has_nsfw_concepts, …) that we do not normalize.
- falaw.results.parse_response(raw, *, application, arguments)[source]#
Best-effort parser over the common fal response shapes.
fal models return a variety of layouts (lists, single objects, bare URLs). We normalize each into Asset(url, kind, …). Unknown shapes pass through as
rawonly — callers can readresult.rawfor anything we miss.- Return type: