runware-sdk 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
runware/__init__.py ADDED
@@ -0,0 +1,245 @@
1
+ """
2
+ Runware Python SDK.
3
+
4
+ Public surface mirrors the TypeScript SDK's exports.
5
+
6
+ Client:
7
+ Runware — async client class
8
+
9
+ Errors:
10
+ RunwareError — exception class for all SDK errors
11
+ ErrorCode — Literal type of stable error codes
12
+ is_runware_error — type guard
13
+ create_runware_error — programmatic constructor
14
+ parse_api_error — parse a server error response into RunwareError
15
+
16
+ Options & config:
17
+ SDKConfig — config dataclass
18
+ RunOptions — per-call options for client.run()
19
+ StreamOptions — per-call options for client.stream()
20
+ RuntimeDependencies — inject custom aiohttp session / WS connect
21
+ WebSocketConnectFactory — type alias for the WS connect callable
22
+
23
+ Streaming:
24
+ TextStream — LLM stream result with async iterators
25
+ TextStreamChunk — one parsed SSE chunk
26
+ TextStreamResult — final accumulated stream state
27
+ parse_sse_line — low-level SSE parser
28
+
29
+ Registry:
30
+ Registry — model registry with TTL + ETag + offline fallback
31
+ RegistryData — parsed registry payload
32
+ RegistryModelEntry — single model entry
33
+ create_registry — factory
34
+ models — bundled curated-model map (from generated types)
35
+ architecture_task_types — bundled architecture → taskType map
36
+ modality_task_types — bundled modality → taskType map
37
+ operation_task_types — bundled operation (caption-image, upscale-video, …) → taskType map
38
+
39
+ Logging:
40
+ Logger — logger class
41
+ LogEntry — one structured log line
42
+ LogCategory — Literal of log channel names (matches TS)
43
+ LogSink — pluggable sink protocol
44
+ create_logger — factory
45
+
46
+ Validation:
47
+ clear_validator_cache — reset the in-process compiled-validator cache
48
+
49
+ Helpers:
50
+ file_to_data_uri — encode files/bytes as data URIs for inputs
51
+
52
+ Schemas pin:
53
+ SCHEMAS_VERSION — the pinned schemas-bundle version
54
+ ModelEntry — generated curated-model entry shape
55
+ TaskType — Literal union of all known task types
56
+ """
57
+
58
+ from .client import Runware
59
+ from .content import ContentClient
60
+ from .errors import (
61
+ ErrorCode,
62
+ RunwareError,
63
+ create_runware_error,
64
+ is_runware_error,
65
+ parse_api_error,
66
+ )
67
+ from .logger import LogCategory, LogEntry, Logger, LogSink, create_logger
68
+ from .registry import Registry, RegistryData, RegistryModelEntry, create_registry
69
+ from .stream import TextStream, parse_sse_line
70
+ from .types.content import (
71
+ ArchitectureMetadata,
72
+ Capability,
73
+ CollectionMetadata,
74
+ CollectionWithModels,
75
+ Creator,
76
+ CreatorWithModels,
77
+ ExampleMetadata,
78
+ GetModelExamplesOptions,
79
+ GuideMetadata,
80
+ ListCollectionsOptions,
81
+ ListModelsOptions,
82
+ ModelMetadata,
83
+ PaginatedResponse,
84
+ PricingExample,
85
+ PricingModelListItem,
86
+ )
87
+ from .types.sdk import (
88
+ RunOptions,
89
+ RuntimeDependencies,
90
+ SDKConfig,
91
+ StreamOptions,
92
+ WebSocketConnectFactory,
93
+ )
94
+ from .types.stream import TextStreamChunk, TextStreamResult
95
+ from .types.task_map import (
96
+ SCHEMAS_VERSION,
97
+ AccountManagementParams,
98
+ AccountManagementResult,
99
+ AudioInferenceParams,
100
+ AudioInferenceResult,
101
+ CaptionImageParams,
102
+ CaptionParams,
103
+ CaptionResult,
104
+ CaptionVideoParams,
105
+ ControlnetPreprocessParams,
106
+ ControlNetPreprocessResult,
107
+ GetResponseParams,
108
+ GetResponseResult,
109
+ GetTaskDetailsParams,
110
+ GetTaskDetailsResult,
111
+ ImageInferenceParams,
112
+ ImageInferenceResult,
113
+ ImageMaskingResult,
114
+ ImageUploadParams,
115
+ ImageUploadResult,
116
+ MaskingParams,
117
+ ModelEntry,
118
+ ModelSearchParams,
119
+ ModelSearchResult,
120
+ ModelUploadParams,
121
+ ModelUploadResult,
122
+ PromptEnhanceParams,
123
+ PromptEnhanceResult,
124
+ RemoveBackgroundImageParams,
125
+ RemoveBackgroundParams,
126
+ RemoveBackgroundResult,
127
+ RemoveBackgroundVideoParams,
128
+ TaskType,
129
+ TextInferenceParams,
130
+ TextInferenceResult,
131
+ ThreeDInferenceParams,
132
+ ThreeDInferenceResult,
133
+ TrainingParams,
134
+ TrainingResult,
135
+ UpscaleImageParams,
136
+ UpscaleParams,
137
+ UpscaleResult,
138
+ UpscaleVideoParams,
139
+ VectorizeParams,
140
+ VectorizeResult,
141
+ VideoInferenceParams,
142
+ VideoInferenceResult,
143
+ architecture_task_types,
144
+ modality_task_types,
145
+ models,
146
+ operation_task_types,
147
+ )
148
+ from .utils.file import file_to_data_uri
149
+ from .validate import clear_validator_cache
150
+
151
+ __all__ = [
152
+ "SCHEMAS_VERSION",
153
+ "AccountManagementParams",
154
+ "AccountManagementResult",
155
+ "ArchitectureMetadata",
156
+ "AudioInferenceParams",
157
+ "AudioInferenceResult",
158
+ "Capability",
159
+ "CaptionImageParams",
160
+ "CaptionParams",
161
+ "CaptionResult",
162
+ "CaptionVideoParams",
163
+ "CollectionMetadata",
164
+ "CollectionWithModels",
165
+ "ContentClient",
166
+ "ControlNetPreprocessResult",
167
+ "ControlnetPreprocessParams",
168
+ "Creator",
169
+ "CreatorWithModels",
170
+ "ErrorCode",
171
+ "ExampleMetadata",
172
+ "GetModelExamplesOptions",
173
+ "GetResponseParams",
174
+ "GetResponseResult",
175
+ "GetTaskDetailsParams",
176
+ "GetTaskDetailsResult",
177
+ "GuideMetadata",
178
+ "ImageInferenceParams",
179
+ "ImageInferenceResult",
180
+ "ImageMaskingResult",
181
+ "ImageUploadParams",
182
+ "ImageUploadResult",
183
+ "ListCollectionsOptions",
184
+ "ListModelsOptions",
185
+ "LogCategory",
186
+ "LogEntry",
187
+ "LogSink",
188
+ "Logger",
189
+ "MaskingParams",
190
+ "ModelEntry",
191
+ "ModelMetadata",
192
+ "ModelSearchParams",
193
+ "ModelSearchResult",
194
+ "ModelUploadParams",
195
+ "ModelUploadResult",
196
+ "PaginatedResponse",
197
+ "PricingExample",
198
+ "PricingModelListItem",
199
+ "PromptEnhanceParams",
200
+ "PromptEnhanceResult",
201
+ "Registry",
202
+ "RegistryData",
203
+ "RegistryModelEntry",
204
+ "RemoveBackgroundImageParams",
205
+ "RemoveBackgroundParams",
206
+ "RemoveBackgroundResult",
207
+ "RemoveBackgroundVideoParams",
208
+ "RunOptions",
209
+ "RuntimeDependencies",
210
+ "Runware",
211
+ "RunwareError",
212
+ "SDKConfig",
213
+ "StreamOptions",
214
+ "TaskType",
215
+ "TextInferenceParams",
216
+ "TextInferenceResult",
217
+ "TextStream",
218
+ "TextStreamChunk",
219
+ "TextStreamResult",
220
+ "ThreeDInferenceParams",
221
+ "ThreeDInferenceResult",
222
+ "TrainingParams",
223
+ "TrainingResult",
224
+ "UpscaleImageParams",
225
+ "UpscaleParams",
226
+ "UpscaleResult",
227
+ "UpscaleVideoParams",
228
+ "VectorizeParams",
229
+ "VectorizeResult",
230
+ "VideoInferenceParams",
231
+ "VideoInferenceResult",
232
+ "WebSocketConnectFactory",
233
+ "architecture_task_types",
234
+ "clear_validator_cache",
235
+ "create_logger",
236
+ "create_registry",
237
+ "create_runware_error",
238
+ "file_to_data_uri",
239
+ "is_runware_error",
240
+ "modality_task_types",
241
+ "models",
242
+ "operation_task_types",
243
+ "parse_api_error",
244
+ "parse_sse_line",
245
+ ]
runware/_docs_cache.py ADDED
@@ -0,0 +1,26 @@
1
+ """
2
+ Tiny module that owns the per-model documentation-URL cache.
3
+
4
+ Lives separately from `validate.py` (which writes it) and `errors.py` (which
5
+ reads it via `_docs_for_model`) so neither needs to import the other — that
6
+ import edge would create an `errors↔validate` cycle.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ _docs_url_cache: dict[str, str | None] = {}
12
+
13
+
14
+ def get_docs_url_for_model(model: str) -> str | None:
15
+ """Cached documentation URL base for a model. Populated by `/resolve` calls."""
16
+ return _docs_url_cache.get(model)
17
+
18
+
19
+ def set_docs_url_for_model(model: str, url: str) -> None:
20
+ """Set the cached URL for a model. Called by `validate._fetch_model_schema`."""
21
+ _docs_url_cache[model] = url
22
+
23
+
24
+ def clear_docs_url_cache() -> None:
25
+ """Reset the docs-URL cache. Used by `clear_validator_cache`."""
26
+ _docs_url_cache.clear()
@@ -0,0 +1,12 @@
1
+ """
2
+ Pinned schemas bundle version used by the type generator.
3
+
4
+ Managed by ``scripts/bump_schemas.sh`` — run that to advance to the current
5
+ latest release. Don't edit by hand except when intentionally rolling back to
6
+ an older pin (historical reference, hotfix branch, debugging a regression).
7
+
8
+ Read at build time only — runtime schema validation hits the live
9
+ ``/resolve/<model>`` endpoint and doesn't consult this constant.
10
+ """
11
+
12
+ SCHEMAS_VERSION = "20260618151239"