Skip to content

Commit a9a982b

Browse files
authored
Merge branch 'main' into chore/finish-reason-mapping-part-2
2 parents 79741c7 + 1464cb4 commit a9a982b

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

src/providers/anthropic/chatComplete.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ export const AnthropicChatCompleteStreamChunkTransform: (
606606
streamState,
607607
strictOpenAiCompliance
608608
) => {
609+
if (streamState.toolIndex == undefined) {
610+
streamState.toolIndex = -1;
611+
}
609612
let chunk = responseChunk.trim();
610613
if (
611614
chunk.startsWith('event: ping') ||
@@ -724,9 +727,7 @@ export const AnthropicChatCompleteStreamChunkTransform: (
724727
parsedChunk.type === 'content_block_start' &&
725728
parsedChunk.content_block?.type === 'tool_use';
726729
if (isToolBlockStart) {
727-
streamState.toolIndex = streamState.toolIndex
728-
? streamState.toolIndex + 1
729-
: 0;
730+
streamState.toolIndex = streamState.toolIndex + 1;
730731
}
731732
const isToolBlockDelta: boolean =
732733
parsedChunk.type === 'content_block_delta' &&

src/providers/dashscope/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ProviderAPIConfig } from '../types';
22

33
export const dashscopeAPIConfig: ProviderAPIConfig = {
4-
getBaseURL: () => 'https://dashscope.aliyuncs.com/compatible-mode/v1',
4+
getBaseURL: () => 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1',
55
headers({ providerOptions }) {
66
const { apiKey } = providerOptions;
77
return { Authorization: `Bearer ${apiKey}` };

src/providers/dashscope/index.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,30 @@ import { ProviderConfigs } from '../types';
88
import { dashscopeAPIConfig } from './api';
99

1010
export const DashScopeConfig: ProviderConfigs = {
11-
chatComplete: chatCompleteParams([], { model: 'qwen-turbo' }),
11+
chatComplete: chatCompleteParams(
12+
[],
13+
{ model: 'qwen-turbo' },
14+
{
15+
top_k: {
16+
param: 'top_k',
17+
},
18+
repetition_penalty: {
19+
param: 'repetition_penalty',
20+
},
21+
stop: {
22+
param: 'stop',
23+
},
24+
enable_search: {
25+
param: 'enable_search',
26+
},
27+
enable_thinking: {
28+
param: 'enable_thinking',
29+
},
30+
thinking_budget: {
31+
param: 'thinking_budget',
32+
},
33+
}
34+
),
1235
embed: embedParams([], { model: 'text-embedding-v1' }),
1336
api: dashscopeAPIConfig,
1437
responseTransforms: responseTransformers(DASHSCOPE, {

src/providers/google-vertex-ai/chatComplete.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
806806
streamState,
807807
strictOpenAiCompliance
808808
) => {
809+
if (streamState.toolIndex == undefined) {
810+
streamState.toolIndex = -1;
811+
}
809812
let chunk = responseChunk.trim();
810813

811814
if (
@@ -916,9 +919,7 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
916919
parsedChunk.type === 'content_block_start' &&
917920
parsedChunk.content_block?.type === 'tool_use';
918921
if (isToolBlockStart) {
919-
streamState.toolIndex = streamState.toolIndex
920-
? streamState.toolIndex + 1
921-
: 0;
922+
streamState.toolIndex = streamState.toolIndex + 1;
922923
}
923924
const isToolBlockDelta: boolean =
924925
parsedChunk.type === 'content_block_delta' &&

src/providers/openai/chatComplete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const OpenAIChatCompleteJSONToStreamResponseTransform: (
181181
const streamChunkTemplate: Record<string, any> = {
182182
id,
183183
object: 'chat.completion.chunk',
184-
created: Date.now(),
184+
created: Math.floor(Date.now() / 1000),
185185
model: model || '',
186186
system_fingerprint: system_fingerprint || null,
187187
provider,

0 commit comments

Comments
 (0)