Skip to content

Commit 43f739f

Browse files
committed
tweaks
1 parent 238567a commit 43f739f

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

packages/inference/src/lib/makeRequestOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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;

packages/inference/src/providers/replicate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ type ReplicateId = string;
1515
export 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
};

packages/inference/src/tasks/custom/request.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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")) {

packages/inference/src/tasks/nlp/chatCompletion.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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",

0 commit comments

Comments
 (0)