You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api/app/clients/BaseClient.js
+58-14Lines changed: 58 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -347,25 +347,38 @@ class BaseClient {
347
347
* If the token limit would be exceeded by adding a message, that message is not added to the context and remains in the original array.
348
348
* The method uses `push` and `pop` operations for efficient array manipulation, and reverses the context array at the end to maintain the original order of the messages.
349
349
*
350
-
* @param {Array} _messages - An array of messages, each with a `tokenCount` property. The messages should be ordered from oldest to newest.
351
-
* @param {number} [maxContextTokens] - The max number of tokens allowed in the context. If not provided, defaults to `this.maxContextTokens`.
352
-
* @returns {Object} An object with four properties: `context`, `summaryIndex`, `remainingContextTokens`, and `messagesToRefine`.
350
+
* @param {Object} params
351
+
* @param {TMessage[]} params.messages - An array of messages, each with a `tokenCount` property. The messages should be ordered from oldest to newest.
352
+
* @param {number} [params.maxContextTokens] - The max number of tokens allowed in the context. If not provided, defaults to `this.maxContextTokens`.
353
+
* @param {{ role: 'system', content: text, tokenCount: number }} [params.instructions] - Instructions already added to the context at index 0.
354
+
* @returns {Promise<{
355
+
* context: TMessage[],
356
+
* remainingContextTokens: number,
357
+
* messagesToRefine: TMessage[],
358
+
* summaryIndex: number,
359
+
* }>} An object with four properties: `context`, `summaryIndex`, `remainingContextTokens`, and `messagesToRefine`.
353
360
* `context` is an array of messages that fit within the token limit.
354
361
* `summaryIndex` is the index of the first message in the `messagesToRefine` array.
355
362
* `remainingContextTokens` is the number of tokens remaining within the limit after adding the messages to the context.
356
363
* `messagesToRefine` is an array of messages that were not added to the context because they would have exceeded the token limit.
0 commit comments