File tree Expand file tree Collapse file tree 4 files changed +37
-2
lines changed Expand file tree Collapse file tree 4 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -170,9 +170,12 @@ export const GoogleApiConfig: ProviderAPIConfig = {
170
170
}
171
171
172
172
case 'anthropic' : {
173
- if ( mappedFn === 'chatComplete' ) {
173
+ if ( mappedFn === 'chatComplete' || mappedFn === 'messages' ) {
174
174
return `${ projectRoute } /publishers/${ provider } /models/${ model } :rawPredict` ;
175
- } else if ( mappedFn === 'stream-chatComplete' ) {
175
+ } else if (
176
+ mappedFn === 'stream-chatComplete' ||
177
+ mappedFn === 'stream-messages'
178
+ ) {
176
179
return `${ projectRoute } /publishers/${ provider } /models/${ model } :streamRawPredict` ;
177
180
}
178
181
}
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ import {
47
47
import { GoogleFinetuneRetrieveResponseTransform } from './retrieveFinetune' ;
48
48
import { GoogleFinetuneListResponseTransform } from './listFinetunes' ;
49
49
import { GoogleListFilesRequestHandler } from './listFiles' ;
50
+ import {
51
+ VertexAnthropicMessagesConfig ,
52
+ VertexAnthropicMessagesResponseTransform ,
53
+ } from './messages' ;
50
54
51
55
const VertexConfig : ProviderConfigs = {
52
56
api : VertexApiConfig ,
@@ -112,10 +116,12 @@ const VertexConfig: ProviderConfigs = {
112
116
api : GoogleApiConfig ,
113
117
createBatch : GoogleBatchCreateConfig ,
114
118
createFinetune : baseConfig . createFinetune ,
119
+ messages : VertexAnthropicMessagesConfig ,
115
120
responseTransforms : {
116
121
'stream-chatComplete' :
117
122
VertexAnthropicChatCompleteStreamChunkTransform ,
118
123
chatComplete : VertexAnthropicChatCompleteResponseTransform ,
124
+ messages : VertexAnthropicMessagesResponseTransform ,
119
125
...responseTransforms ,
120
126
} ,
121
127
} ;
Original file line number Diff line number Diff line change
1
+ import { GOOGLE_VERTEX_AI } from '../../globals' ;
2
+ import { MessagesResponse } from '../../types/messagesResponse' ;
3
+ import { getMessagesConfig } from '../anthropic-base/messages' ;
4
+ import { AnthropicErrorResponse } from '../anthropic/types' ;
5
+ import { AnthropicErrorResponseTransform } from '../anthropic/utils' ;
6
+ import { ErrorResponse } from '../types' ;
7
+ import { generateInvalidProviderResponseError } from '../utils' ;
8
+
9
+ export const VertexAnthropicMessagesConfig = getMessagesConfig ( { } ) ;
10
+
11
+ export const VertexAnthropicMessagesResponseTransform = (
12
+ response : MessagesResponse | AnthropicErrorResponse ,
13
+ responseStatus : number
14
+ ) : MessagesResponse | ErrorResponse => {
15
+ if ( responseStatus !== 200 ) {
16
+ const errorResposne = AnthropicErrorResponseTransform (
17
+ response as AnthropicErrorResponse
18
+ ) ;
19
+ if ( errorResposne ) return errorResposne ;
20
+ }
21
+
22
+ if ( 'model' in response ) return response ;
23
+
24
+ return generateInvalidProviderResponseError ( response , GOOGLE_VERTEX_AI ) ;
25
+ } ;
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export type endpointStrings =
80
80
| 'moderate'
81
81
| 'stream-complete'
82
82
| 'stream-chatComplete'
83
+ | 'stream-messages'
83
84
| 'proxy'
84
85
| 'imageGenerate'
85
86
| 'createSpeech'
You can’t perform that action at this time.
0 commit comments