@shaxpir/duiduidui-models 1.25.6 → 1.25.8
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/models/Chat.d.ts +3 -1
- package/dist/models/Chat.js +20 -1
- package/package.json +1 -1
package/dist/models/Chat.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export interface ChatError {
|
|
|
82
82
|
export interface ChatCacheBreakpoints {
|
|
83
83
|
system_prompt?: CacheBreakpoint;
|
|
84
84
|
tools?: CacheBreakpoint;
|
|
85
|
+
auto?: CacheBreakpoint;
|
|
85
86
|
}
|
|
86
87
|
export interface ChatPayload {
|
|
87
88
|
title?: string;
|
|
@@ -135,7 +136,8 @@ export declare class Chat extends SharedContent {
|
|
|
135
136
|
* Set a cache breakpoint for the system prompt or tools at the conversation level.
|
|
136
137
|
* These record that the server is using prompt caching for API calls in this chat.
|
|
137
138
|
*/
|
|
138
|
-
setCacheBreakpoint(target: 'system_prompt' | 'tools', ttl: CacheTTL): void;
|
|
139
|
+
setCacheBreakpoint(target: 'system_prompt' | 'tools' | 'auto', ttl: CacheTTL): void;
|
|
140
|
+
removeCacheBreakpoint(target: 'system_prompt' | 'tools' | 'auto'): void;
|
|
139
141
|
get cacheBreakpoints(): ChatCacheBreakpoints | undefined;
|
|
140
142
|
clearExpiredBreakpoints(): void;
|
|
141
143
|
}
|
package/dist/models/Chat.js
CHANGED
|
@@ -223,7 +223,23 @@ class Chat extends SharedContent_1.SharedContent {
|
|
|
223
223
|
const expiresAt = shaxpir_common_1.Time.plus(now, durationMinutes, 'minutes');
|
|
224
224
|
const breakpoint = { ttl, created_at: now, expires_at: expiresAt };
|
|
225
225
|
const batch = new Operation_1.BatchOperation(this);
|
|
226
|
-
|
|
226
|
+
// If cache_breakpoints doesn't exist on the payload yet, create the
|
|
227
|
+
// entire object in one operation. OT can't insert into a non-existent
|
|
228
|
+
// parent, so we must create the parent first.
|
|
229
|
+
if (!this.payload.cache_breakpoints) {
|
|
230
|
+
batch.setPathValue(['payload', 'cache_breakpoints'], { [target]: breakpoint });
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
batch.setPathValue(['payload', 'cache_breakpoints', target], breakpoint);
|
|
234
|
+
}
|
|
235
|
+
batch.commit();
|
|
236
|
+
}
|
|
237
|
+
removeCacheBreakpoint(target) {
|
|
238
|
+
this.checkDisposed('Chat.removeCacheBreakpoint');
|
|
239
|
+
if (!this.payload.cache_breakpoints?.[target])
|
|
240
|
+
return;
|
|
241
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
242
|
+
batch.removeValueAtPath(['payload', 'cache_breakpoints', target]);
|
|
227
243
|
batch.commit();
|
|
228
244
|
}
|
|
229
245
|
get cacheBreakpoints() {
|
|
@@ -249,6 +265,9 @@ class Chat extends SharedContent_1.SharedContent {
|
|
|
249
265
|
if (cb.tools && shaxpir_common_1.Time.isDateTimeBefore(cb.tools.expires_at, now)) {
|
|
250
266
|
batch.removeValueAtPath(['payload', 'cache_breakpoints', 'tools']);
|
|
251
267
|
}
|
|
268
|
+
if (cb.auto && shaxpir_common_1.Time.isDateTimeBefore(cb.auto.expires_at, now)) {
|
|
269
|
+
batch.removeValueAtPath(['payload', 'cache_breakpoints', 'auto']);
|
|
270
|
+
}
|
|
252
271
|
batch.commit();
|
|
253
272
|
}
|
|
254
273
|
}
|