@librechat/agents-types 1.9.93 → 1.9.95
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/package.json +1 -1
- package/stream.ts +47 -4
package/package.json
CHANGED
package/stream.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
// src/types/stream.ts
|
2
|
+
import type OpenAITypes from 'openai';
|
2
3
|
import type { MessageContentImageUrl, MessageContentText, ToolMessage, BaseMessage } from '@langchain/core/messages';
|
3
4
|
import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
|
4
5
|
import type { LLMResult, Generation } from '@langchain/core/outputs';
|
5
|
-
import { StepTypes, ContentTypes } from '@/common/enum';
|
6
|
+
import { StepTypes, ContentTypes, GraphEvents } from '@/common/enum';
|
6
7
|
|
7
8
|
export type HandleLLMEnd = (output: LLMResult, runId: string, parentRunId?: string, tags?: string[]) => void;
|
8
9
|
|
@@ -54,7 +55,7 @@ export type RunStep = {
|
|
54
55
|
index: number; // #new
|
55
56
|
stepIndex?: number; // #new
|
56
57
|
stepDetails: StepDetails;
|
57
|
-
usage
|
58
|
+
usage?: null | {
|
58
59
|
// Define usage structure if it's ever non-null
|
59
60
|
// prompt_tokens: number; // #new
|
60
61
|
// completion_tokens: number; // #new
|
@@ -178,13 +179,40 @@ export interface MessageDelta {
|
|
178
179
|
tool_call_ids?: string[];
|
179
180
|
}
|
180
181
|
|
182
|
+
/**
|
183
|
+
* Represents a reasoning delta i.e. any changed fields on a message during
|
184
|
+
* streaming.
|
185
|
+
*/
|
186
|
+
export interface ReasoningDeltaEvent {
|
187
|
+
/**
|
188
|
+
* The identifier of the message, which can be referenced in API endpoints.
|
189
|
+
*/
|
190
|
+
id: string;
|
191
|
+
|
192
|
+
/**
|
193
|
+
* The delta containing the fields that have changed.
|
194
|
+
*/
|
195
|
+
delta: ReasoningDelta;
|
196
|
+
}
|
197
|
+
|
198
|
+
/**
|
199
|
+
* The reasoning delta containing the fields that have changed on the Message.
|
200
|
+
*/
|
201
|
+
export interface ReasoningDelta {
|
202
|
+
/**
|
203
|
+
* The content of the message in array of text and/or images.
|
204
|
+
*/
|
205
|
+
content?: MessageContentComplex[];
|
206
|
+
}
|
207
|
+
|
181
208
|
export type MessageDeltaUpdate = { type: ContentTypes.TEXT; text: string; tool_call_ids?: string[] };
|
209
|
+
export type ReasoningDeltaUpdate = { type: ContentTypes.THINK; think: string; };
|
182
210
|
|
183
|
-
export type ContentType = 'text' | 'image_url' | 'tool_call' | string;
|
211
|
+
export type ContentType = 'text' | 'image_url' | 'tool_call' | 'think' | string;
|
184
212
|
|
185
213
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
186
214
|
export type MessageContentComplex = (MessageContentText | MessageContentImageUrl | (Record<string, any> & {
|
187
|
-
type?: 'text' | 'image_url' | string;
|
215
|
+
type?: 'text' | 'image_url' | 'think' | string;
|
188
216
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
189
217
|
}) | (Record<string, any> & {
|
190
218
|
type?: never;
|
@@ -192,3 +220,18 @@ export type MessageContentComplex = (MessageContentText | MessageContentImageUrl
|
|
192
220
|
tool_call_ids?: string[];
|
193
221
|
};
|
194
222
|
// #new
|
223
|
+
|
224
|
+
export type CustomChunk = Partial<OpenAITypes.ChatCompletionChunk> & {
|
225
|
+
choices?: Partial<Array<Partial<OpenAITypes.Chat.Completions.ChatCompletionChunk.Choice> & {
|
226
|
+
delta?: Partial<OpenAITypes.Chat.Completions.ChatCompletionChunk.Choice.Delta> & {
|
227
|
+
reasoning?: string | null;
|
228
|
+
reasoning_content?: string | null;
|
229
|
+
};
|
230
|
+
}>>;
|
231
|
+
}
|
232
|
+
|
233
|
+
export type SplitStreamHandlers = Partial<{
|
234
|
+
[GraphEvents.ON_RUN_STEP]: ({ event, data}: { event: GraphEvents, data: RunStep }) => void;
|
235
|
+
[GraphEvents.ON_MESSAGE_DELTA]: ({ event, data}: { event: GraphEvents, data: MessageDeltaEvent }) => void;
|
236
|
+
[GraphEvents.ON_REASONING_DELTA]: ({ event, data}: { event: GraphEvents, data: ReasoningDeltaEvent }) => void;
|
237
|
+
}>
|