@@ -7,7 +7,10 @@ import {
77import { transformUsingProviderConfig } from '../../services/transformToProviderRequest' ;
88import { Context } from 'hono' ;
99import { BEDROCK , POWERED_BY } from '../../globals' ;
10- import { providerAssumedRoleCredentials } from './utils' ;
10+ import {
11+ getFoundationModelFromInferenceProfile ,
12+ providerAssumedRoleCredentials ,
13+ } from './utils' ;
1114import BedrockAPIConfig from './api' ;
1215import { ProviderConfig , RequestHandler } from '../../providers/types' ;
1316import { Options } from '../../types/requestBody' ;
@@ -315,6 +318,7 @@ const getProviderConfig = (modelSlug: string) => {
315318 else if ( modelSlug . includes ( 'anthropic' ) ) provider = 'anthropic' ;
316319 else if ( modelSlug . includes ( 'ai21' ) ) provider = 'ai21' ;
317320 else if ( modelSlug . includes ( 'cohere' ) ) provider = 'cohere' ;
321+ else if ( modelSlug . includes ( 'amazon' ) ) provider = 'titan' ;
318322 else throw new Error ( 'Invalid model slug' ) ;
319323 return BedrockUploadFileTransformerConfig [ provider ] ;
320324} ;
@@ -332,12 +336,16 @@ export const BedrockUploadFileRequestHandler: RequestHandler<
332336 if ( providerOptions . awsAuthType === 'assumedRole' ) {
333337 await providerAssumedRoleCredentials ( c , providerOptions ) ;
334338 }
335- const { awsRegion, awsS3Bucket, awsBedrockModel } = providerOptions ;
339+ const {
340+ awsRegion,
341+ awsS3Bucket,
342+ awsBedrockModel : modelParam ,
343+ } = providerOptions ;
336344
337345 const awsS3ObjectKey =
338346 providerOptions . awsS3ObjectKey || crypto . randomUUID ( ) + '.jsonl' ;
339347
340- if ( ! awsS3Bucket || ! awsBedrockModel ) {
348+ if ( ! awsS3Bucket || ! modelParam ) {
341349 return new Response (
342350 JSON . stringify ( {
343351 status : 'failure' ,
@@ -353,6 +361,21 @@ export const BedrockUploadFileRequestHandler: RequestHandler<
353361 ) ;
354362 }
355363
364+ let awsBedrockModel = modelParam ;
365+
366+ if ( awsBedrockModel . includes ( 'arn:aws' ) ) {
367+ const foundationModel = awsBedrockModel . includes ( 'foundation-model/' )
368+ ? awsBedrockModel . split ( '/' ) . pop ( )
369+ : await getFoundationModelFromInferenceProfile (
370+ c ,
371+ awsBedrockModel ,
372+ providerOptions
373+ ) ;
374+ if ( foundationModel ) {
375+ awsBedrockModel = foundationModel ;
376+ }
377+ }
378+
356379 const handler = new AwsMultipartUploadHandler (
357380 awsRegion ,
358381 awsS3Bucket ,
0 commit comments