@axiom-lattice/client-sdk 2.1.5 → 2.1.7
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/dist/abstract-client.d.ts +80 -1
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +206 -19
- package/dist/abstract-client.js.map +1 -1
- package/dist/index.d.ts +247 -2
- package/dist/index.js +232 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +232 -20
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +167 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,10 @@ interface Thread {
|
|
|
80
80
|
* Thread identifier
|
|
81
81
|
*/
|
|
82
82
|
id: string;
|
|
83
|
+
/**
|
|
84
|
+
* Assistant identifier this thread belongs to
|
|
85
|
+
*/
|
|
86
|
+
assistantId: string;
|
|
83
87
|
/**
|
|
84
88
|
* Thread metadata
|
|
85
89
|
*/
|
|
@@ -87,7 +91,11 @@ interface Thread {
|
|
|
87
91
|
/**
|
|
88
92
|
* Thread creation timestamp
|
|
89
93
|
*/
|
|
90
|
-
createdAt: string;
|
|
94
|
+
createdAt: Date | string;
|
|
95
|
+
/**
|
|
96
|
+
* Thread last update timestamp
|
|
97
|
+
*/
|
|
98
|
+
updatedAt: Date | string;
|
|
91
99
|
}
|
|
92
100
|
/**
|
|
93
101
|
* Chat send options
|
|
@@ -295,6 +303,164 @@ interface AgentState {
|
|
|
295
303
|
}>;
|
|
296
304
|
}>;
|
|
297
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Assistant information
|
|
308
|
+
*/
|
|
309
|
+
interface Assistant {
|
|
310
|
+
/**
|
|
311
|
+
* Assistant identifier
|
|
312
|
+
*/
|
|
313
|
+
id: string;
|
|
314
|
+
/**
|
|
315
|
+
* Assistant name
|
|
316
|
+
*/
|
|
317
|
+
name: string;
|
|
318
|
+
/**
|
|
319
|
+
* Assistant description (optional)
|
|
320
|
+
*/
|
|
321
|
+
description?: string;
|
|
322
|
+
/**
|
|
323
|
+
* Graph definition for the assistant
|
|
324
|
+
*/
|
|
325
|
+
graphDefinition: any;
|
|
326
|
+
/**
|
|
327
|
+
* Creation timestamp
|
|
328
|
+
*/
|
|
329
|
+
createdAt: Date | string;
|
|
330
|
+
/**
|
|
331
|
+
* Last update timestamp
|
|
332
|
+
*/
|
|
333
|
+
updatedAt: Date | string;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Create assistant request options
|
|
337
|
+
*/
|
|
338
|
+
interface CreateAssistantOptions {
|
|
339
|
+
/**
|
|
340
|
+
* Assistant name
|
|
341
|
+
*/
|
|
342
|
+
name: string;
|
|
343
|
+
/**
|
|
344
|
+
* Assistant description (optional)
|
|
345
|
+
*/
|
|
346
|
+
description?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Graph definition for the assistant
|
|
349
|
+
*/
|
|
350
|
+
graphDefinition: any;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Update assistant request options
|
|
354
|
+
*/
|
|
355
|
+
interface UpdateAssistantOptions {
|
|
356
|
+
/**
|
|
357
|
+
* Assistant name (optional)
|
|
358
|
+
*/
|
|
359
|
+
name?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Assistant description (optional)
|
|
362
|
+
*/
|
|
363
|
+
description?: string;
|
|
364
|
+
/**
|
|
365
|
+
* Graph definition for the assistant (optional)
|
|
366
|
+
*/
|
|
367
|
+
graphDefinition?: any;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Assistant list response
|
|
371
|
+
*/
|
|
372
|
+
interface AssistantListResponse {
|
|
373
|
+
/**
|
|
374
|
+
* Whether the operation was successful
|
|
375
|
+
*/
|
|
376
|
+
success: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Response message
|
|
379
|
+
*/
|
|
380
|
+
message: string;
|
|
381
|
+
/**
|
|
382
|
+
* Response data
|
|
383
|
+
*/
|
|
384
|
+
data: {
|
|
385
|
+
/**
|
|
386
|
+
* List of assistants
|
|
387
|
+
*/
|
|
388
|
+
records: Assistant[];
|
|
389
|
+
/**
|
|
390
|
+
* Total number of assistants
|
|
391
|
+
*/
|
|
392
|
+
total: number;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Assistant response
|
|
397
|
+
*/
|
|
398
|
+
interface AssistantResponse {
|
|
399
|
+
/**
|
|
400
|
+
* Whether the operation was successful
|
|
401
|
+
*/
|
|
402
|
+
success: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* Response message
|
|
405
|
+
*/
|
|
406
|
+
message: string;
|
|
407
|
+
/**
|
|
408
|
+
* Assistant data (optional)
|
|
409
|
+
*/
|
|
410
|
+
data?: Assistant;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Thread list response
|
|
414
|
+
*/
|
|
415
|
+
interface ThreadListResponse {
|
|
416
|
+
/**
|
|
417
|
+
* Whether the operation was successful
|
|
418
|
+
*/
|
|
419
|
+
success: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Response message
|
|
422
|
+
*/
|
|
423
|
+
message: string;
|
|
424
|
+
/**
|
|
425
|
+
* Response data
|
|
426
|
+
*/
|
|
427
|
+
data: {
|
|
428
|
+
/**
|
|
429
|
+
* List of threads
|
|
430
|
+
*/
|
|
431
|
+
records: Thread[];
|
|
432
|
+
/**
|
|
433
|
+
* Total number of threads
|
|
434
|
+
*/
|
|
435
|
+
total: number;
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Thread response
|
|
440
|
+
*/
|
|
441
|
+
interface ThreadResponse {
|
|
442
|
+
/**
|
|
443
|
+
* Whether the operation was successful
|
|
444
|
+
*/
|
|
445
|
+
success: boolean;
|
|
446
|
+
/**
|
|
447
|
+
* Response message
|
|
448
|
+
*/
|
|
449
|
+
message: string;
|
|
450
|
+
/**
|
|
451
|
+
* Thread data (optional)
|
|
452
|
+
*/
|
|
453
|
+
data?: Thread;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Update thread request options
|
|
457
|
+
*/
|
|
458
|
+
interface UpdateThreadOptions {
|
|
459
|
+
/**
|
|
460
|
+
* Thread metadata (optional)
|
|
461
|
+
*/
|
|
462
|
+
metadata?: Record<string, any>;
|
|
463
|
+
}
|
|
298
464
|
/**
|
|
299
465
|
* Custom error classes
|
|
300
466
|
*/
|
|
@@ -372,24 +538,28 @@ declare abstract class AbstractClient {
|
|
|
372
538
|
protected abstract streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
|
|
373
539
|
/**
|
|
374
540
|
* Creates a new thread
|
|
541
|
+
* @deprecated Use threads.create() instead
|
|
375
542
|
* @param options - Options for creating a thread
|
|
376
543
|
* @returns A promise that resolves to the thread ID
|
|
377
544
|
*/
|
|
378
545
|
createThread(options: CreateThreadOptions): Promise<string>;
|
|
379
546
|
/**
|
|
380
547
|
* Retrieves thread information
|
|
548
|
+
* @deprecated Use threads.get() instead
|
|
381
549
|
* @param threadId - Thread identifier
|
|
382
550
|
* @returns A promise that resolves to the thread information
|
|
383
551
|
*/
|
|
384
552
|
getThread(threadId: string): Promise<Thread>;
|
|
385
553
|
/**
|
|
386
554
|
* Lists all threads
|
|
555
|
+
* @deprecated Use threads.list() instead
|
|
387
556
|
* @param options - Options for listing threads
|
|
388
557
|
* @returns A promise that resolves to an array of threads
|
|
389
558
|
*/
|
|
390
559
|
listThreads(options?: ListThreadsOptions): Promise<Thread[]>;
|
|
391
560
|
/**
|
|
392
561
|
* Deletes a thread
|
|
562
|
+
* @deprecated Use threads.delete() instead
|
|
393
563
|
* @param threadId - Thread identifier
|
|
394
564
|
* @returns A promise that resolves when the thread is deleted
|
|
395
565
|
*/
|
|
@@ -461,6 +631,81 @@ declare abstract class AbstractClient {
|
|
|
461
631
|
*/
|
|
462
632
|
unregister: (name: string) => void;
|
|
463
633
|
};
|
|
634
|
+
/**
|
|
635
|
+
* Assistants namespace for managing assistants
|
|
636
|
+
*/
|
|
637
|
+
assistants: {
|
|
638
|
+
/**
|
|
639
|
+
* Lists all available assistants
|
|
640
|
+
* Returns both code-configured and stored assistants
|
|
641
|
+
* @returns A promise that resolves to the list of assistants
|
|
642
|
+
*/
|
|
643
|
+
list: () => Promise<Assistant[]>;
|
|
644
|
+
/**
|
|
645
|
+
* Retrieves a single assistant by ID
|
|
646
|
+
* Checks both code-configured and stored assistants
|
|
647
|
+
* @param id - Assistant identifier
|
|
648
|
+
* @returns A promise that resolves to the assistant information
|
|
649
|
+
*/
|
|
650
|
+
get: (id: string) => Promise<Assistant>;
|
|
651
|
+
/**
|
|
652
|
+
* Creates a new assistant
|
|
653
|
+
* Only creates stored assistants (code-configured assistants cannot be created via API)
|
|
654
|
+
* @param options - Options for creating an assistant
|
|
655
|
+
* @returns A promise that resolves to the created assistant
|
|
656
|
+
*/
|
|
657
|
+
create: (options: CreateAssistantOptions) => Promise<Assistant>;
|
|
658
|
+
/**
|
|
659
|
+
* Updates an existing assistant by ID
|
|
660
|
+
* Only works on stored assistants (code-configured assistants cannot be updated)
|
|
661
|
+
* @param id - Assistant identifier
|
|
662
|
+
* @param options - Options for updating an assistant
|
|
663
|
+
* @returns A promise that resolves to the updated assistant
|
|
664
|
+
*/
|
|
665
|
+
update: (id: string, options: UpdateAssistantOptions) => Promise<Assistant>;
|
|
666
|
+
/**
|
|
667
|
+
* Deletes an assistant by ID
|
|
668
|
+
* Only works on stored assistants (code-configured assistants cannot be deleted)
|
|
669
|
+
* @param id - Assistant identifier
|
|
670
|
+
* @returns A promise that resolves when the assistant is deleted
|
|
671
|
+
*/
|
|
672
|
+
delete: (id: string) => Promise<void>;
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
* Threads namespace for managing threads for the current assistant
|
|
676
|
+
*/
|
|
677
|
+
threads: {
|
|
678
|
+
/**
|
|
679
|
+
* Lists all threads for the current assistant
|
|
680
|
+
* @returns A promise that resolves to the list of threads
|
|
681
|
+
*/
|
|
682
|
+
list: () => Promise<Thread[]>;
|
|
683
|
+
/**
|
|
684
|
+
* Retrieves a single thread by ID for the current assistant
|
|
685
|
+
* @param threadId - Thread identifier
|
|
686
|
+
* @returns A promise that resolves to the thread information
|
|
687
|
+
*/
|
|
688
|
+
get: (threadId: string) => Promise<Thread>;
|
|
689
|
+
/**
|
|
690
|
+
* Creates a new thread for the current assistant
|
|
691
|
+
* @param options - Options for creating a thread
|
|
692
|
+
* @returns A promise that resolves to the created thread
|
|
693
|
+
*/
|
|
694
|
+
create: (options: CreateThreadOptions) => Promise<Thread>;
|
|
695
|
+
/**
|
|
696
|
+
* Updates an existing thread by ID for the current assistant
|
|
697
|
+
* @param threadId - Thread identifier
|
|
698
|
+
* @param options - Options for updating a thread
|
|
699
|
+
* @returns A promise that resolves to the updated thread
|
|
700
|
+
*/
|
|
701
|
+
update: (threadId: string, options: UpdateThreadOptions) => Promise<Thread>;
|
|
702
|
+
/**
|
|
703
|
+
* Deletes a thread by ID for the current assistant
|
|
704
|
+
* @param threadId - Thread identifier
|
|
705
|
+
* @returns A promise that resolves when the thread is deleted
|
|
706
|
+
*/
|
|
707
|
+
delete: (threadId: string) => Promise<void>;
|
|
708
|
+
};
|
|
464
709
|
}
|
|
465
710
|
|
|
466
711
|
/**
|
|
@@ -616,4 +861,4 @@ declare function createSimpleMessageMerger(): {
|
|
|
616
861
|
reset: () => void;
|
|
617
862
|
};
|
|
618
863
|
|
|
619
|
-
export { AbstractClient, AgentState, ApiError, AuthenticationError, ChatResponse, ChatSendOptions, ChatStreamOptions, Client, ClientConfig, CreateThreadOptions, GetMessagesOptions, ListThreadsOptions, NetworkError, RegisterToolOptions, ResumeStreamOptions, RetryConfig, RunOptions, StreamCallbacks, Thread, Transport, WeChatClient, createSimpleMessageMerger };
|
|
864
|
+
export { AbstractClient, AgentState, ApiError, Assistant, AssistantListResponse, AssistantResponse, AuthenticationError, ChatResponse, ChatSendOptions, ChatStreamOptions, Client, ClientConfig, CreateAssistantOptions, CreateThreadOptions, GetMessagesOptions, ListThreadsOptions, NetworkError, RegisterToolOptions, ResumeStreamOptions, RetryConfig, RunOptions, StreamCallbacks, Thread, ThreadListResponse, ThreadResponse, Transport, UpdateAssistantOptions, UpdateThreadOptions, WeChatClient, createSimpleMessageMerger };
|
package/dist/index.js
CHANGED
|
@@ -1955,6 +1955,209 @@ var AbstractClient = class {
|
|
|
1955
1955
|
this.registeredTools.delete(name);
|
|
1956
1956
|
}
|
|
1957
1957
|
};
|
|
1958
|
+
/**
|
|
1959
|
+
* Assistants namespace for managing assistants
|
|
1960
|
+
*/
|
|
1961
|
+
this.assistants = {
|
|
1962
|
+
/**
|
|
1963
|
+
* Lists all available assistants
|
|
1964
|
+
* Returns both code-configured and stored assistants
|
|
1965
|
+
* @returns A promise that resolves to the list of assistants
|
|
1966
|
+
*/
|
|
1967
|
+
list: async () => {
|
|
1968
|
+
try {
|
|
1969
|
+
const response = await this.makeRequest(
|
|
1970
|
+
"/api/assistants"
|
|
1971
|
+
);
|
|
1972
|
+
return response.data.records;
|
|
1973
|
+
} catch (error) {
|
|
1974
|
+
throw error;
|
|
1975
|
+
}
|
|
1976
|
+
},
|
|
1977
|
+
/**
|
|
1978
|
+
* Retrieves a single assistant by ID
|
|
1979
|
+
* Checks both code-configured and stored assistants
|
|
1980
|
+
* @param id - Assistant identifier
|
|
1981
|
+
* @returns A promise that resolves to the assistant information
|
|
1982
|
+
*/
|
|
1983
|
+
get: async (id) => {
|
|
1984
|
+
try {
|
|
1985
|
+
const response = await this.makeRequest(
|
|
1986
|
+
`/api/assistants/${id}`
|
|
1987
|
+
);
|
|
1988
|
+
if (!response.data) {
|
|
1989
|
+
throw new ApiError("Assistant not found", 404);
|
|
1990
|
+
}
|
|
1991
|
+
return response.data;
|
|
1992
|
+
} catch (error) {
|
|
1993
|
+
throw error;
|
|
1994
|
+
}
|
|
1995
|
+
},
|
|
1996
|
+
/**
|
|
1997
|
+
* Creates a new assistant
|
|
1998
|
+
* Only creates stored assistants (code-configured assistants cannot be created via API)
|
|
1999
|
+
* @param options - Options for creating an assistant
|
|
2000
|
+
* @returns A promise that resolves to the created assistant
|
|
2001
|
+
*/
|
|
2002
|
+
create: async (options) => {
|
|
2003
|
+
try {
|
|
2004
|
+
const response = await this.makeRequest(
|
|
2005
|
+
"/api/assistants",
|
|
2006
|
+
{
|
|
2007
|
+
method: "POST",
|
|
2008
|
+
body: options
|
|
2009
|
+
}
|
|
2010
|
+
);
|
|
2011
|
+
if (!response.data) {
|
|
2012
|
+
throw new ApiError("Failed to create assistant", 500);
|
|
2013
|
+
}
|
|
2014
|
+
return response.data;
|
|
2015
|
+
} catch (error) {
|
|
2016
|
+
throw error;
|
|
2017
|
+
}
|
|
2018
|
+
},
|
|
2019
|
+
/**
|
|
2020
|
+
* Updates an existing assistant by ID
|
|
2021
|
+
* Only works on stored assistants (code-configured assistants cannot be updated)
|
|
2022
|
+
* @param id - Assistant identifier
|
|
2023
|
+
* @param options - Options for updating an assistant
|
|
2024
|
+
* @returns A promise that resolves to the updated assistant
|
|
2025
|
+
*/
|
|
2026
|
+
update: async (id, options) => {
|
|
2027
|
+
try {
|
|
2028
|
+
const response = await this.makeRequest(
|
|
2029
|
+
`/api/assistants/${id}`,
|
|
2030
|
+
{
|
|
2031
|
+
method: "PUT",
|
|
2032
|
+
body: options
|
|
2033
|
+
}
|
|
2034
|
+
);
|
|
2035
|
+
if (!response.data) {
|
|
2036
|
+
throw new ApiError("Failed to update assistant", 500);
|
|
2037
|
+
}
|
|
2038
|
+
return response.data;
|
|
2039
|
+
} catch (error) {
|
|
2040
|
+
throw error;
|
|
2041
|
+
}
|
|
2042
|
+
},
|
|
2043
|
+
/**
|
|
2044
|
+
* Deletes an assistant by ID
|
|
2045
|
+
* Only works on stored assistants (code-configured assistants cannot be deleted)
|
|
2046
|
+
* @param id - Assistant identifier
|
|
2047
|
+
* @returns A promise that resolves when the assistant is deleted
|
|
2048
|
+
*/
|
|
2049
|
+
delete: async (id) => {
|
|
2050
|
+
try {
|
|
2051
|
+
await this.makeRequest(
|
|
2052
|
+
`/api/assistants/${id}`,
|
|
2053
|
+
{
|
|
2054
|
+
method: "DELETE"
|
|
2055
|
+
}
|
|
2056
|
+
);
|
|
2057
|
+
} catch (error) {
|
|
2058
|
+
throw error;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
/**
|
|
2063
|
+
* Threads namespace for managing threads for the current assistant
|
|
2064
|
+
*/
|
|
2065
|
+
this.threads = {
|
|
2066
|
+
/**
|
|
2067
|
+
* Lists all threads for the current assistant
|
|
2068
|
+
* @returns A promise that resolves to the list of threads
|
|
2069
|
+
*/
|
|
2070
|
+
list: async () => {
|
|
2071
|
+
try {
|
|
2072
|
+
const response = await this.makeRequest(
|
|
2073
|
+
`/api/assistants/${this.assistantId}/threads`
|
|
2074
|
+
);
|
|
2075
|
+
return response.data.records;
|
|
2076
|
+
} catch (error) {
|
|
2077
|
+
throw error;
|
|
2078
|
+
}
|
|
2079
|
+
},
|
|
2080
|
+
/**
|
|
2081
|
+
* Retrieves a single thread by ID for the current assistant
|
|
2082
|
+
* @param threadId - Thread identifier
|
|
2083
|
+
* @returns A promise that resolves to the thread information
|
|
2084
|
+
*/
|
|
2085
|
+
get: async (threadId) => {
|
|
2086
|
+
try {
|
|
2087
|
+
const response = await this.makeRequest(
|
|
2088
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`
|
|
2089
|
+
);
|
|
2090
|
+
if (!response.data) {
|
|
2091
|
+
throw new ApiError("Thread not found", 404);
|
|
2092
|
+
}
|
|
2093
|
+
return response.data;
|
|
2094
|
+
} catch (error) {
|
|
2095
|
+
throw error;
|
|
2096
|
+
}
|
|
2097
|
+
},
|
|
2098
|
+
/**
|
|
2099
|
+
* Creates a new thread for the current assistant
|
|
2100
|
+
* @param options - Options for creating a thread
|
|
2101
|
+
* @returns A promise that resolves to the created thread
|
|
2102
|
+
*/
|
|
2103
|
+
create: async (options) => {
|
|
2104
|
+
try {
|
|
2105
|
+
const response = await this.makeRequest(
|
|
2106
|
+
`/api/assistants/${this.assistantId}/threads`,
|
|
2107
|
+
{
|
|
2108
|
+
method: "POST",
|
|
2109
|
+
body: options
|
|
2110
|
+
}
|
|
2111
|
+
);
|
|
2112
|
+
if (!response.data) {
|
|
2113
|
+
throw new ApiError("Failed to create thread", 500);
|
|
2114
|
+
}
|
|
2115
|
+
return response.data;
|
|
2116
|
+
} catch (error) {
|
|
2117
|
+
throw error;
|
|
2118
|
+
}
|
|
2119
|
+
},
|
|
2120
|
+
/**
|
|
2121
|
+
* Updates an existing thread by ID for the current assistant
|
|
2122
|
+
* @param threadId - Thread identifier
|
|
2123
|
+
* @param options - Options for updating a thread
|
|
2124
|
+
* @returns A promise that resolves to the updated thread
|
|
2125
|
+
*/
|
|
2126
|
+
update: async (threadId, options) => {
|
|
2127
|
+
try {
|
|
2128
|
+
const response = await this.makeRequest(
|
|
2129
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`,
|
|
2130
|
+
{
|
|
2131
|
+
method: "PUT",
|
|
2132
|
+
body: options
|
|
2133
|
+
}
|
|
2134
|
+
);
|
|
2135
|
+
if (!response.data) {
|
|
2136
|
+
throw new ApiError("Failed to update thread", 500);
|
|
2137
|
+
}
|
|
2138
|
+
return response.data;
|
|
2139
|
+
} catch (error) {
|
|
2140
|
+
throw error;
|
|
2141
|
+
}
|
|
2142
|
+
},
|
|
2143
|
+
/**
|
|
2144
|
+
* Deletes a thread by ID for the current assistant
|
|
2145
|
+
* @param threadId - Thread identifier
|
|
2146
|
+
* @returns A promise that resolves when the thread is deleted
|
|
2147
|
+
*/
|
|
2148
|
+
delete: async (threadId) => {
|
|
2149
|
+
try {
|
|
2150
|
+
await this.makeRequest(
|
|
2151
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`,
|
|
2152
|
+
{
|
|
2153
|
+
method: "DELETE"
|
|
2154
|
+
}
|
|
2155
|
+
);
|
|
2156
|
+
} catch (error) {
|
|
2157
|
+
throw error;
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
};
|
|
1958
2161
|
this.config = {
|
|
1959
2162
|
timeout: 3e5,
|
|
1960
2163
|
// Default timeout
|
|
@@ -2017,65 +2220,74 @@ var AbstractClient = class {
|
|
|
2017
2220
|
}
|
|
2018
2221
|
/**
|
|
2019
2222
|
* Creates a new thread
|
|
2223
|
+
* @deprecated Use threads.create() instead
|
|
2020
2224
|
* @param options - Options for creating a thread
|
|
2021
2225
|
* @returns A promise that resolves to the thread ID
|
|
2022
2226
|
*/
|
|
2023
2227
|
async createThread(options) {
|
|
2024
2228
|
try {
|
|
2025
|
-
const
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2229
|
+
const response = await this.makeRequest(
|
|
2230
|
+
`/api/assistants/${this.assistantId}/threads`,
|
|
2231
|
+
{
|
|
2232
|
+
method: "POST",
|
|
2233
|
+
body: options
|
|
2030
2234
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2235
|
+
);
|
|
2236
|
+
if (!response.data) {
|
|
2237
|
+
throw new ApiError("Failed to create thread", 500);
|
|
2238
|
+
}
|
|
2239
|
+
return response.data.id;
|
|
2033
2240
|
} catch (error) {
|
|
2034
2241
|
throw error;
|
|
2035
2242
|
}
|
|
2036
2243
|
}
|
|
2037
2244
|
/**
|
|
2038
2245
|
* Retrieves thread information
|
|
2246
|
+
* @deprecated Use threads.get() instead
|
|
2039
2247
|
* @param threadId - Thread identifier
|
|
2040
2248
|
* @returns A promise that resolves to the thread information
|
|
2041
2249
|
*/
|
|
2042
2250
|
async getThread(threadId) {
|
|
2043
2251
|
try {
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2252
|
+
const response = await this.makeRequest(
|
|
2253
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`
|
|
2254
|
+
);
|
|
2255
|
+
if (!response.data) {
|
|
2256
|
+
throw new ApiError("Thread not found", 404);
|
|
2257
|
+
}
|
|
2258
|
+
return response.data;
|
|
2046
2259
|
} catch (error) {
|
|
2047
2260
|
throw error;
|
|
2048
2261
|
}
|
|
2049
2262
|
}
|
|
2050
2263
|
/**
|
|
2051
2264
|
* Lists all threads
|
|
2265
|
+
* @deprecated Use threads.list() instead
|
|
2052
2266
|
* @param options - Options for listing threads
|
|
2053
2267
|
* @returns A promise that resolves to an array of threads
|
|
2054
2268
|
*/
|
|
2055
2269
|
async listThreads(options) {
|
|
2056
2270
|
try {
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
if (options?.offset !== void 0) {
|
|
2062
|
-
url += `&offset=${options.offset}`;
|
|
2063
|
-
}
|
|
2064
|
-
const data = await this.makeRequest(url);
|
|
2065
|
-
return data.threads;
|
|
2271
|
+
const response = await this.makeRequest(
|
|
2272
|
+
`/api/assistants/${this.assistantId}/threads`
|
|
2273
|
+
);
|
|
2274
|
+
return response.data.records;
|
|
2066
2275
|
} catch (error) {
|
|
2067
2276
|
throw error;
|
|
2068
2277
|
}
|
|
2069
2278
|
}
|
|
2070
2279
|
/**
|
|
2071
2280
|
* Deletes a thread
|
|
2281
|
+
* @deprecated Use threads.delete() instead
|
|
2072
2282
|
* @param threadId - Thread identifier
|
|
2073
2283
|
* @returns A promise that resolves when the thread is deleted
|
|
2074
2284
|
*/
|
|
2075
2285
|
async deleteThread(threadId) {
|
|
2076
2286
|
try {
|
|
2077
|
-
|
|
2078
|
-
|
|
2287
|
+
await this.makeRequest(
|
|
2288
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`,
|
|
2289
|
+
{ method: "DELETE" }
|
|
2290
|
+
);
|
|
2079
2291
|
} catch (error) {
|
|
2080
2292
|
throw error;
|
|
2081
2293
|
}
|