@yetter/client 0.0.12 → 0.0.13
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.
- package/README.md +52 -3
- package/dist/api.d.ts +3 -0
- package/dist/api.js +110 -60
- package/dist/client.d.ts +27 -52
- package/dist/client.js +264 -262
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +6 -1
- package/bowow2.jpeg +0 -0
- package/examples/stream.ts +0 -54
- package/examples/submit.ts +0 -80
- package/examples/subscribe.ts +0 -41
- package/examples/upload-and-generate.ts +0 -39
- package/src/api.ts +0 -159
- package/src/client.ts +0 -697
- package/src/index.ts +0 -12
- package/src/types.ts +0 -192
- package/tsconfig.json +0 -13
package/src/types.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
export interface ClientOptions {
|
|
2
|
-
apiKey: string;
|
|
3
|
-
endpoint?: string;
|
|
4
|
-
is_bearer?: boolean;
|
|
5
|
-
promptEnhancerModel?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface LoraWeight {
|
|
9
|
-
path: string;
|
|
10
|
-
scale?: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface GenerateRequest {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface GenerateResponse {
|
|
18
|
-
status: string;
|
|
19
|
-
request_id: string;
|
|
20
|
-
response_url: string;
|
|
21
|
-
status_url: string;
|
|
22
|
-
cancel_url: string;
|
|
23
|
-
queue_position: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface LogEntry {
|
|
27
|
-
message: string;
|
|
28
|
-
// Add other potential log fields here, e.g., timestamp, level
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface GetStatusRequest {
|
|
32
|
-
url: string;
|
|
33
|
-
logs?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface GetStatusResponse {
|
|
37
|
-
status: string;
|
|
38
|
-
request_id?: string;
|
|
39
|
-
response_url?: string;
|
|
40
|
-
status_url?: string;
|
|
41
|
-
cancel_url?: string;
|
|
42
|
-
queue_position?: number;
|
|
43
|
-
logs?: LogEntry[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface CancelRequest {
|
|
47
|
-
url: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface CancelResponse {
|
|
51
|
-
status: string;
|
|
52
|
-
request_id?: string;
|
|
53
|
-
response_url?: string;
|
|
54
|
-
status_url?: string;
|
|
55
|
-
cancel_url?: string;
|
|
56
|
-
queue_position?: number;
|
|
57
|
-
logs?: string[];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface GetResponseRequest {
|
|
61
|
-
url: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface GetResponseResponse {
|
|
65
|
-
images: string[] | Record<string, any>[];
|
|
66
|
-
prompt: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface SubscribeOptions {
|
|
70
|
-
input: Omit<GenerateRequest, 'model'>; // model is a direct param to subscribe
|
|
71
|
-
logs?: boolean;
|
|
72
|
-
onQueueUpdate?: (update: GetStatusResponse) => void;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface SubmitQueueOptions {
|
|
76
|
-
input: Omit<GenerateRequest, 'model'>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface GetResultOptions {
|
|
80
|
-
requestId: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface GetResultResponse {
|
|
84
|
-
data: GetResponseResponse;
|
|
85
|
-
requestId: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface StatusOptions {
|
|
89
|
-
requestId: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface StatusResponse {
|
|
93
|
-
data: GetStatusResponse;
|
|
94
|
-
requestId: string;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// --- Stream Types ---
|
|
98
|
-
export interface StreamOptions {
|
|
99
|
-
input: Omit<GenerateRequest, 'model'>;
|
|
100
|
-
// logs?: boolean; // Optional: if you want to request logs via stream if API supports it
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Represents an event received from the SSE stream.
|
|
105
|
-
* The `data` field is expected to be compatible with GetStatusResponse.
|
|
106
|
-
*/
|
|
107
|
-
export interface StreamEvent extends GetStatusResponse { // SSE events directly reflect status updates
|
|
108
|
-
// type: string; // Could be 'status', 'error', 'open', etc. if the stream sends typed messages.
|
|
109
|
-
// If the stream ONLY sends GetStatusResponse JSON, this might not be needed.
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface YetterStream extends AsyncIterable<StreamEvent> {
|
|
113
|
-
done(): Promise<GetResponseResponse>; // Resolves with the final image data
|
|
114
|
-
cancel(): Promise<void>; // Cancels the stream and attempts to cancel the underlying API request
|
|
115
|
-
getRequestId(): string; // Helper to get the request ID associated with the stream
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// ============= Upload-Related Types =============
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Options for yetter.uploadFile() and yetter.uploadBlob()
|
|
122
|
-
*/
|
|
123
|
-
export interface UploadOptions {
|
|
124
|
-
/** Optional callback for upload progress (0-100) */
|
|
125
|
-
onProgress?: (progress: number) => void;
|
|
126
|
-
|
|
127
|
-
/** Optional custom filename (browser File uploads) */
|
|
128
|
-
filename?: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Request to get presigned upload URL(s)
|
|
133
|
-
*/
|
|
134
|
-
export interface GetUploadUrlRequest {
|
|
135
|
-
/** Original filename with extension */
|
|
136
|
-
file_name: string;
|
|
137
|
-
|
|
138
|
-
/** MIME type (e.g., "image/jpeg") */
|
|
139
|
-
content_type: string;
|
|
140
|
-
|
|
141
|
-
/** File size in bytes */
|
|
142
|
-
size: number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Response containing presigned URL(s) for upload
|
|
147
|
-
*/
|
|
148
|
-
export interface GetUploadUrlResponse {
|
|
149
|
-
/** Upload mode: "single" for small files, "multipart" for large files */
|
|
150
|
-
mode: "single" | "multipart";
|
|
151
|
-
|
|
152
|
-
/** S3 object key for tracking */
|
|
153
|
-
key: string;
|
|
154
|
-
|
|
155
|
-
/** Presigned PUT URL (single mode only) */
|
|
156
|
-
put_url?: string;
|
|
157
|
-
|
|
158
|
-
/** Size of each part in bytes (multipart mode only) */
|
|
159
|
-
part_size?: number;
|
|
160
|
-
|
|
161
|
-
/** Array of part URLs with part numbers (multipart mode only) */
|
|
162
|
-
part_urls?: Array<{
|
|
163
|
-
part_number: number;
|
|
164
|
-
url: string;
|
|
165
|
-
}>;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Request to notify upload completion
|
|
170
|
-
*/
|
|
171
|
-
export interface UploadCompleteRequest {
|
|
172
|
-
/** S3 object key from GetUploadUrlResponse */
|
|
173
|
-
key: string;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Response after successful upload completion
|
|
178
|
-
*/
|
|
179
|
-
export interface UploadCompleteResponse {
|
|
180
|
-
/** Public URL to access the uploaded file */
|
|
181
|
-
url: string;
|
|
182
|
-
|
|
183
|
-
/** S3 object key */
|
|
184
|
-
key: string;
|
|
185
|
-
|
|
186
|
-
/** Optional metadata */
|
|
187
|
-
metadata?: {
|
|
188
|
-
size: number;
|
|
189
|
-
content_type: string;
|
|
190
|
-
uploaded_at?: string;
|
|
191
|
-
};
|
|
192
|
-
}
|
package/tsconfig.json
DELETED