@aviaryhq/cloudglue-js 0.5.2 → 0.5.3

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.
@@ -32,8 +32,30 @@ type ChatMessage = {
32
32
  content: string;
33
33
  name?: string | undefined;
34
34
  };
35
+ type ChatCompletionList = {
36
+ object: 'list';
37
+ data: Array<{
38
+ id: string;
39
+ created: number;
40
+ object: 'chat.completion';
41
+ model: string;
42
+ usage: Partial<{
43
+ prompt_tokens: number;
44
+ completion_tokens: number;
45
+ total_tokens: number;
46
+ }>;
47
+ choices: Array<{
48
+ index: number;
49
+ message: ChatMessage;
50
+ }>;
51
+ }>;
52
+ total: number;
53
+ limit: number;
54
+ offset: number;
55
+ };
35
56
  declare const ChatMessage: z.ZodType<ChatMessage>;
36
57
  declare const ChatCompletionRequest: z.ZodType<ChatCompletionRequest>;
58
+ declare const ChatCompletionList: z.ZodType<ChatCompletionList>;
37
59
  export declare const schemas: {
38
60
  ChatMessage: z.ZodType<ChatMessage, z.ZodTypeDef, ChatMessage>;
39
61
  ChatCompletionRequest: z.ZodType<ChatCompletionRequest, z.ZodTypeDef, ChatCompletionRequest>;
@@ -90,6 +112,7 @@ export declare const schemas: {
90
112
  total_tokens: number;
91
113
  }>;
92
114
  }>>;
115
+ ChatCompletionList: z.ZodType<ChatCompletionList, z.ZodTypeDef, ChatCompletionList>;
93
116
  };
94
117
  export declare const ChatApi: import("@zodios/core").ZodiosInstance<[{
95
118
  method: "post";
@@ -197,6 +220,105 @@ export declare const ChatApi: import("@zodios/core").ZodiosInstance<[{
197
220
  error: z.ZodString;
198
221
  }, z.ZodTypeAny, "passthrough">>;
199
222
  }];
223
+ }, {
224
+ method: "get";
225
+ path: "/chat/completions";
226
+ alias: "listChatCompletions";
227
+ description: "List all chat completions with optional filtering";
228
+ requestFormat: "json";
229
+ parameters: [{
230
+ name: "limit";
231
+ type: "Query";
232
+ schema: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
233
+ }, {
234
+ name: "offset";
235
+ type: "Query";
236
+ schema: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
237
+ }, {
238
+ name: "created_before";
239
+ type: "Query";
240
+ schema: z.ZodOptional<z.ZodString>;
241
+ }, {
242
+ name: "created_after";
243
+ type: "Query";
244
+ schema: z.ZodOptional<z.ZodString>;
245
+ }];
246
+ response: z.ZodType<ChatCompletionList, z.ZodTypeDef, ChatCompletionList>;
247
+ }, {
248
+ method: "get";
249
+ path: "/chat/completions/:id";
250
+ alias: "getChatCompletion";
251
+ description: "Retrieve a chat completion";
252
+ requestFormat: "json";
253
+ parameters: [{
254
+ name: "id";
255
+ type: "Path";
256
+ schema: z.ZodString;
257
+ }];
258
+ response: z.ZodType<Partial<{
259
+ id: string;
260
+ object: string;
261
+ created: number;
262
+ model: string;
263
+ choices: Array<Partial<{
264
+ index: number;
265
+ message: ChatMessage;
266
+ citations: Array<Partial<{
267
+ collection_id: string;
268
+ file_id: string;
269
+ segment_id: string;
270
+ start_time: string | number;
271
+ end_time: string | number;
272
+ text: string;
273
+ context: string;
274
+ relevant_sources: Array<Partial<{
275
+ text: string;
276
+ }>>;
277
+ }> & DescribeOutput>;
278
+ }>>;
279
+ usage: Partial<{
280
+ prompt_tokens: number;
281
+ completion_tokens: number;
282
+ total_tokens: number;
283
+ }>;
284
+ }>, z.ZodTypeDef, Partial<{
285
+ id: string;
286
+ object: string;
287
+ created: number;
288
+ model: string;
289
+ choices: Array<Partial<{
290
+ index: number;
291
+ message: ChatMessage;
292
+ citations: Array<Partial<{
293
+ collection_id: string;
294
+ file_id: string;
295
+ segment_id: string;
296
+ start_time: string | number;
297
+ end_time: string | number;
298
+ text: string;
299
+ context: string;
300
+ relevant_sources: Array<Partial<{
301
+ text: string;
302
+ }>>;
303
+ }> & DescribeOutput>;
304
+ }>>;
305
+ usage: Partial<{
306
+ prompt_tokens: number;
307
+ completion_tokens: number;
308
+ total_tokens: number;
309
+ }>;
310
+ }>>;
311
+ errors: [{
312
+ status: 404;
313
+ description: string;
314
+ schema: z.ZodObject<{
315
+ error: z.ZodString;
316
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
317
+ error: z.ZodString;
318
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
319
+ error: z.ZodString;
320
+ }, z.ZodTypeAny, "passthrough">>;
321
+ }];
200
322
  }]>;
201
323
  export declare function createApiClient(baseUrl: string, options?: ZodiosOptions): import("@zodios/core").ZodiosInstance<[{
202
324
  method: "post";
@@ -304,5 +426,104 @@ export declare function createApiClient(baseUrl: string, options?: ZodiosOptions
304
426
  error: z.ZodString;
305
427
  }, z.ZodTypeAny, "passthrough">>;
306
428
  }];
429
+ }, {
430
+ method: "get";
431
+ path: "/chat/completions";
432
+ alias: "listChatCompletions";
433
+ description: "List all chat completions with optional filtering";
434
+ requestFormat: "json";
435
+ parameters: [{
436
+ name: "limit";
437
+ type: "Query";
438
+ schema: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
439
+ }, {
440
+ name: "offset";
441
+ type: "Query";
442
+ schema: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
443
+ }, {
444
+ name: "created_before";
445
+ type: "Query";
446
+ schema: z.ZodOptional<z.ZodString>;
447
+ }, {
448
+ name: "created_after";
449
+ type: "Query";
450
+ schema: z.ZodOptional<z.ZodString>;
451
+ }];
452
+ response: z.ZodType<ChatCompletionList, z.ZodTypeDef, ChatCompletionList>;
453
+ }, {
454
+ method: "get";
455
+ path: "/chat/completions/:id";
456
+ alias: "getChatCompletion";
457
+ description: "Retrieve a chat completion";
458
+ requestFormat: "json";
459
+ parameters: [{
460
+ name: "id";
461
+ type: "Path";
462
+ schema: z.ZodString;
463
+ }];
464
+ response: z.ZodType<Partial<{
465
+ id: string;
466
+ object: string;
467
+ created: number;
468
+ model: string;
469
+ choices: Array<Partial<{
470
+ index: number;
471
+ message: ChatMessage;
472
+ citations: Array<Partial<{
473
+ collection_id: string;
474
+ file_id: string;
475
+ segment_id: string;
476
+ start_time: string | number;
477
+ end_time: string | number;
478
+ text: string;
479
+ context: string;
480
+ relevant_sources: Array<Partial<{
481
+ text: string;
482
+ }>>;
483
+ }> & DescribeOutput>;
484
+ }>>;
485
+ usage: Partial<{
486
+ prompt_tokens: number;
487
+ completion_tokens: number;
488
+ total_tokens: number;
489
+ }>;
490
+ }>, z.ZodTypeDef, Partial<{
491
+ id: string;
492
+ object: string;
493
+ created: number;
494
+ model: string;
495
+ choices: Array<Partial<{
496
+ index: number;
497
+ message: ChatMessage;
498
+ citations: Array<Partial<{
499
+ collection_id: string;
500
+ file_id: string;
501
+ segment_id: string;
502
+ start_time: string | number;
503
+ end_time: string | number;
504
+ text: string;
505
+ context: string;
506
+ relevant_sources: Array<Partial<{
507
+ text: string;
508
+ }>>;
509
+ }> & DescribeOutput>;
510
+ }>>;
511
+ usage: Partial<{
512
+ prompt_tokens: number;
513
+ completion_tokens: number;
514
+ total_tokens: number;
515
+ }>;
516
+ }>>;
517
+ errors: [{
518
+ status: 404;
519
+ description: string;
520
+ schema: z.ZodObject<{
521
+ error: z.ZodString;
522
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
523
+ error: z.ZodString;
524
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
525
+ error: z.ZodString;
526
+ }, z.ZodTypeAny, "passthrough">>;
527
+ }];
307
528
  }]>;
308
529
  export {};
@@ -126,10 +126,42 @@ const ChatCompletionResponse = zod_1.z
126
126
  .partial()
127
127
  .strict()
128
128
  .passthrough();
129
+ const ChatCompletionList = zod_1.z
130
+ .object({
131
+ object: zod_1.z.literal('list'),
132
+ data: zod_1.z.array(zod_1.z
133
+ .object({
134
+ id: zod_1.z.string().uuid(),
135
+ created: zod_1.z.number(),
136
+ object: zod_1.z.literal('chat.completion'),
137
+ model: zod_1.z.string(),
138
+ usage: zod_1.z
139
+ .object({
140
+ prompt_tokens: zod_1.z.number().int(),
141
+ completion_tokens: zod_1.z.number().int(),
142
+ total_tokens: zod_1.z.number().int(),
143
+ })
144
+ .partial()
145
+ .strict()
146
+ .passthrough(),
147
+ choices: zod_1.z.array(zod_1.z
148
+ .object({ index: zod_1.z.number().int(), message: ChatMessage })
149
+ .strict()
150
+ .passthrough()),
151
+ })
152
+ .strict()
153
+ .passthrough()),
154
+ total: zod_1.z.number().int(),
155
+ limit: zod_1.z.number().int(),
156
+ offset: zod_1.z.number().int(),
157
+ })
158
+ .strict()
159
+ .passthrough();
129
160
  exports.schemas = {
130
161
  ChatMessage,
131
162
  ChatCompletionRequest,
132
163
  ChatCompletionResponse,
164
+ ChatCompletionList,
133
165
  };
134
166
  const endpoints = (0, core_1.makeApi)([
135
167
  {
@@ -170,6 +202,58 @@ const endpoints = (0, core_1.makeApi)([
170
202
  },
171
203
  ],
172
204
  },
205
+ {
206
+ method: 'get',
207
+ path: '/chat/completions',
208
+ alias: 'listChatCompletions',
209
+ description: `List all chat completions with optional filtering`,
210
+ requestFormat: 'json',
211
+ parameters: [
212
+ {
213
+ name: 'limit',
214
+ type: 'Query',
215
+ schema: zod_1.z.number().int().lte(100).optional().default(20),
216
+ },
217
+ {
218
+ name: 'offset',
219
+ type: 'Query',
220
+ schema: zod_1.z.number().int().optional().default(0),
221
+ },
222
+ {
223
+ name: 'created_before',
224
+ type: 'Query',
225
+ schema: zod_1.z.string().optional(),
226
+ },
227
+ {
228
+ name: 'created_after',
229
+ type: 'Query',
230
+ schema: zod_1.z.string().optional(),
231
+ },
232
+ ],
233
+ response: ChatCompletionList,
234
+ },
235
+ {
236
+ method: 'get',
237
+ path: '/chat/completions/:id',
238
+ alias: 'getChatCompletion',
239
+ description: `Retrieve a chat completion`,
240
+ requestFormat: 'json',
241
+ parameters: [
242
+ {
243
+ name: 'id',
244
+ type: 'Path',
245
+ schema: zod_1.z.string(),
246
+ },
247
+ ],
248
+ response: ChatCompletionResponse,
249
+ errors: [
250
+ {
251
+ status: 404,
252
+ description: `Chat completion not found`,
253
+ schema: zod_1.z.object({ error: zod_1.z.string() }).strict().passthrough(),
254
+ },
255
+ ],
256
+ },
173
257
  ]);
174
258
  exports.ChatApi = new core_1.Zodios('https://api.cloudglue.dev/v1', endpoints);
175
259
  function createApiClient(baseUrl, options) {
@@ -35,4 +35,60 @@ export declare class EnhancedChatApi {
35
35
  total_tokens: number;
36
36
  }>;
37
37
  }>>;
38
+ getCompletion(id: string): Promise<Partial<{
39
+ id: string;
40
+ object: string;
41
+ created: number;
42
+ model: string;
43
+ choices: Array<Partial<{
44
+ index: number;
45
+ message: {
46
+ role: "system" | "user" | "assistant";
47
+ content: string;
48
+ name?: string | undefined;
49
+ };
50
+ citations: Array<Partial<{
51
+ collection_id: string;
52
+ file_id: string;
53
+ segment_id: string;
54
+ start_time: string | number;
55
+ end_time: string | number;
56
+ text: string;
57
+ context: string;
58
+ relevant_sources: Array<Partial<{
59
+ text: string;
60
+ }>>;
61
+ }> & import("../../generated/common").DescribeOutput>;
62
+ }>>;
63
+ usage: Partial<{
64
+ prompt_tokens: number;
65
+ completion_tokens: number;
66
+ total_tokens: number;
67
+ }>;
68
+ }>>;
69
+ listCompletions(params: z.infer<typeof chatSchemas.ChatCompletionList>): Promise<{
70
+ object: "list";
71
+ data: Array<{
72
+ id: string;
73
+ created: number;
74
+ object: "chat.completion";
75
+ model: string;
76
+ usage: Partial<{
77
+ prompt_tokens: number;
78
+ completion_tokens: number;
79
+ total_tokens: number;
80
+ }>;
81
+ choices: Array<{
82
+ index: number;
83
+ message: {
84
+ role: "system" | "user" | "assistant";
85
+ content: string;
86
+ name?: string | undefined;
87
+ };
88
+ }>;
89
+ }>;
90
+ total: number;
91
+ limit: number;
92
+ offset: number;
93
+ }>;
38
94
  }
@@ -11,5 +11,17 @@ class EnhancedChatApi {
11
11
  ...params,
12
12
  });
13
13
  }
14
+ async getCompletion(id) {
15
+ return this.api.getChatCompletion({
16
+ params: {
17
+ id,
18
+ },
19
+ });
20
+ }
21
+ async listCompletions(params) {
22
+ return this.api.listChatCompletions({
23
+ queries: params,
24
+ });
25
+ }
14
26
  }
15
27
  exports.EnhancedChatApi = EnhancedChatApi;
@@ -46,7 +46,7 @@ class CloudGlue {
46
46
  headers: {
47
47
  Authorization: `Bearer ${this.apiKey}`,
48
48
  'x-sdk-client': 'cloudglue-js',
49
- 'x-sdk-version': '0.5.2',
49
+ 'x-sdk-version': '0.5.3',
50
50
  },
51
51
  baseURL: this.baseUrl,
52
52
  timeout: this.timeout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aviaryhq/cloudglue-js",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Cloudglue API client for Node.js",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",