File tree Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -68,16 +68,16 @@ export async function makeRequestOptions(
6868 }
6969 switch ( provider ) {
7070 case "replicate" :
71- model = REPLICATE_MODEL_IDS [ model ] ;
71+ model = REPLICATE_MODEL_IDS [ model ] ?? model ;
7272 break ;
7373 case "sambanova" :
74- model = SAMBANOVA_MODEL_IDS [ model ] ;
74+ model = SAMBANOVA_MODEL_IDS [ model ] ?? model ;
7575 break ;
7676 case "together" :
7777 model = TOGETHER_MODEL_IDS [ model ] ?. id ?? model ;
7878 break ;
7979 case "fal-ai" :
80- model = FAL_AI_MODEL_IDS [ model ] ;
80+ model = FAL_AI_MODEL_IDS [ model ] ?? model ;
8181 break ;
8282 default :
8383 break ;
Original file line number Diff line number Diff line change @@ -15,4 +15,7 @@ type ReplicateId = string;
1515export const REPLICATE_MODEL_IDS : Record < ModelId , ReplicateId > = {
1616 "black-forest-labs/FLUX.1-schnell" : "black-forest-labs/flux-schnell" ,
1717 "ByteDance/SDXL-Lightning" : "bytedance/sdxl-lightning-4step" ,
18+ "meta-llama/Meta-Llama-3-8B-Instruct" : "meta/meta-llama-3-8b-instruct" ,
19+ "meta-llama/Meta-Llama-3-70B-Instruct" : "meta/meta-llama-3-70b-instruct" ,
20+ "meta-llama/Meta-Llama-3.1-405B-Instruct" : "meta/meta-llama-3.1-405b-instruct" ,
1821} ;
Original file line number Diff line number Diff line change @@ -26,9 +26,10 @@ export async function request<T>(
2626 }
2727
2828 if ( ! response . ok ) {
29+ const contentType = response . headers . get ( "Content-Type" ) ;
2930 if (
3031 [ "application/json" , "application/problem+json" ] . some (
31- ( contentType ) => response . headers . get ( "Content-Type" ) ?. startsWith ( contentType )
32+ ( ct ) => contentType ?. startsWith ( ct )
3233 )
3334 ) {
3435 const output = await response . json ( ) ;
@@ -41,7 +42,8 @@ export async function request<T>(
4142 throw new Error ( output ) ;
4243 }
4344 }
44- throw new Error ( "An error occurred while fetching the blob" ) ;
45+ const message = contentType ?. startsWith ( "text/plain;" ) ? await response . text ( ) : undefined ;
46+ throw new Error ( message ?? "An error occurred while fetching the blob" ) ;
4547 }
4648
4749 if ( response . headers . get ( "Content-Type" ) ?. startsWith ( "application/json" ) ) {
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ export async function chatCompletion(
1111 args : BaseArgs & ChatCompletionInput ,
1212 options ?: Options
1313) : Promise < ChatCompletionOutput > {
14+ if ( args . provider === "replicate" ) {
15+ throw new Error ( "Replicate does not support the chat completion API" ) ;
16+ }
1417 const res = await request < ChatCompletionOutput > ( args , {
1518 ...options ,
1619 taskHint : "text-generation" ,
You can’t perform that action at this time.
0 commit comments