File tree Expand file tree Collapse file tree 5 files changed +34
-9
lines changed Expand file tree Collapse file tree 5 files changed +34
-9
lines changed Original file line number Diff line number Diff line change @@ -606,6 +606,9 @@ export const AnthropicChatCompleteStreamChunkTransform: (
606
606
streamState ,
607
607
strictOpenAiCompliance
608
608
) => {
609
+ if ( streamState . toolIndex == undefined ) {
610
+ streamState . toolIndex = - 1 ;
611
+ }
609
612
let chunk = responseChunk . trim ( ) ;
610
613
if (
611
614
chunk . startsWith ( 'event: ping' ) ||
@@ -724,9 +727,7 @@ export const AnthropicChatCompleteStreamChunkTransform: (
724
727
parsedChunk . type === 'content_block_start' &&
725
728
parsedChunk . content_block ?. type === 'tool_use' ;
726
729
if ( isToolBlockStart ) {
727
- streamState . toolIndex = streamState . toolIndex
728
- ? streamState . toolIndex + 1
729
- : 0 ;
730
+ streamState . toolIndex = streamState . toolIndex + 1 ;
730
731
}
731
732
const isToolBlockDelta : boolean =
732
733
parsedChunk . type === 'content_block_delta' &&
Original file line number Diff line number Diff line change 1
1
import { ProviderAPIConfig } from '../types' ;
2
2
3
3
export const dashscopeAPIConfig : ProviderAPIConfig = {
4
- getBaseURL : ( ) => 'https://dashscope.aliyuncs.com/compatible-mode/v1' ,
4
+ getBaseURL : ( ) => 'https://dashscope-intl .aliyuncs.com/compatible-mode/v1' ,
5
5
headers ( { providerOptions } ) {
6
6
const { apiKey } = providerOptions ;
7
7
return { Authorization : `Bearer ${ apiKey } ` } ;
Original file line number Diff line number Diff line change @@ -8,7 +8,30 @@ import { ProviderConfigs } from '../types';
8
8
import { dashscopeAPIConfig } from './api' ;
9
9
10
10
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
+ ) ,
12
35
embed : embedParams ( [ ] , { model : 'text-embedding-v1' } ) ,
13
36
api : dashscopeAPIConfig ,
14
37
responseTransforms : responseTransformers ( DASHSCOPE , {
Original file line number Diff line number Diff line change @@ -806,6 +806,9 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
806
806
streamState ,
807
807
strictOpenAiCompliance
808
808
) => {
809
+ if ( streamState . toolIndex == undefined ) {
810
+ streamState . toolIndex = - 1 ;
811
+ }
809
812
let chunk = responseChunk . trim ( ) ;
810
813
811
814
if (
@@ -916,9 +919,7 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
916
919
parsedChunk . type === 'content_block_start' &&
917
920
parsedChunk . content_block ?. type === 'tool_use' ;
918
921
if ( isToolBlockStart ) {
919
- streamState . toolIndex = streamState . toolIndex
920
- ? streamState . toolIndex + 1
921
- : 0 ;
922
+ streamState . toolIndex = streamState . toolIndex + 1 ;
922
923
}
923
924
const isToolBlockDelta : boolean =
924
925
parsedChunk . type === 'content_block_delta' &&
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ export const OpenAIChatCompleteJSONToStreamResponseTransform: (
181
181
const streamChunkTemplate : Record < string , any > = {
182
182
id,
183
183
object : 'chat.completion.chunk' ,
184
- created : Date . now ( ) ,
184
+ created : Math . floor ( Date . now ( ) / 1000 ) ,
185
185
model : model || '' ,
186
186
system_fingerprint : system_fingerprint || null ,
187
187
provider,
You can’t perform that action at this time.
0 commit comments