Skip to content

Commit ec9c222

Browse files
committed
♻️ refactor: rename params
1 parent aaa5118 commit ec9c222

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

src/libs/agent-runtime/anthropic/index.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,9 @@ export class LobeAnthropicAI implements LobeRuntimeAI {
8080
debugStream(debug.toReadableStream()).catch(console.error);
8181
}
8282

83-
return StreamingResponse(
84-
AnthropicStream(prod, { callbacks: options?.callback }, { inputStartAt }),
85-
{
86-
headers: options?.headers,
87-
},
88-
);
83+
return StreamingResponse(AnthropicStream(prod, { callbacks: options?.callback, inputStartAt }), {
84+
headers: options?.headers,
85+
});
8986
} catch (error) {
9087
throw this.handleError(error);
9188
}
@@ -107,12 +104,12 @@ export class LobeAnthropicAI implements LobeRuntimeAI {
107104

108105
const systemPrompts = !!system_message?.content
109106
? ([
110-
{
111-
cache_control: enabledContextCaching ? { type: 'ephemeral' } : undefined,
112-
text: system_message?.content as string,
113-
type: 'text',
114-
},
115-
] as Anthropic.TextBlockParam[])
107+
{
108+
cache_control: enabledContextCaching ? { type: 'ephemeral' } : undefined,
109+
text: system_message?.content as string,
110+
type: 'text',
111+
},
112+
] as Anthropic.TextBlockParam[])
116113
: undefined;
117114

118115
const postMessages = await buildAnthropicMessages(user_messages, { enabledContextCaching });

src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
257257
return StreamingResponse(
258258
chatCompletion?.handleStream
259259
? chatCompletion.handleStream(prod, streamOptions.callbacks)
260-
: OpenAIStream(prod, streamOptions, { inputStartAt }),
260+
: OpenAIStream(prod, { ...streamOptions, inputStartAt }),
261261
{
262262
headers: options?.headers,
263263
},
@@ -277,7 +277,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
277277
return StreamingResponse(
278278
chatCompletion?.handleStream
279279
? chatCompletion.handleStream(stream, streamOptions.callbacks)
280-
: OpenAIStream(stream, streamOptions, { inputStartAt }),
280+
: OpenAIStream(stream, { ...streamOptions, inputStartAt }),
281281
{
282282
headers: options?.headers,
283283
},

src/libs/agent-runtime/utils/streams/anthropic.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('AnthropicStream', () => {
168168

169169
const protocolStream = AnthropicStream(mockReadableStream, {
170170
callbacks: {
171-
onToolCall: onToolCallMock,
171+
onToolsCalling: onToolCallMock,
172172
},
173173
});
174174

@@ -322,7 +322,7 @@ describe('AnthropicStream', () => {
322322

323323
const protocolStream = AnthropicStream(mockReadableStream, {
324324
callbacks: {
325-
onToolCall: onToolCallMock,
325+
onToolsCalling: onToolCallMock,
326326
},
327327
});
328328

src/libs/agent-runtime/utils/streams/anthropic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ export const transformAnthropicStream = (
191191

192192
export interface AnthropicStreamOptions {
193193
callbacks?: ChatStreamCallbacks;
194+
inputStartAt?: number;
194195
}
195196

196197
export const AnthropicStream = (
197198
stream: Stream<Anthropic.MessageStreamEvent> | ReadableStream,
198-
{ callbacks }: AnthropicStreamOptions = {},
199-
{ inputStartAt }: { inputStartAt?: number } = {},
199+
{ callbacks, inputStartAt }: AnthropicStreamOptions = {},
200200
) => {
201201
const streamStack: StreamContext = { id: '' };
202202

src/libs/agent-runtime/utils/streams/openai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ export interface OpenAIStreamOptions {
219219
name: string;
220220
}) => ILobeAgentRuntimeErrorType | undefined;
221221
callbacks?: ChatStreamCallbacks;
222+
inputStartAt?: number;
222223
provider?: string;
223224
}
224225

225226
export const OpenAIStream = (
226227
stream: Stream<OpenAI.ChatCompletionChunk> | ReadableStream,
227-
{ callbacks, provider, bizErrorTypeTransformer }: OpenAIStreamOptions = {},
228-
{ inputStartAt }: { inputStartAt?: number } = {},
228+
{ callbacks, provider, bizErrorTypeTransformer, inputStartAt }: OpenAIStreamOptions = {},
229229
) => {
230230
const streamStack: StreamContext = { id: '' };
231231

0 commit comments

Comments
 (0)