From bf070e31c3aaf55547e4a423e424f0c1f06485d7 Mon Sep 17 00:00:00 2001 From: Gustavo Cevallos Date: Mon, 29 Jul 2024 20:26:53 -0400 Subject: [PATCH] Add support to @cf models in cloudflare.com --- src/lib/server/endpoints/cloudflare/endpointCloudflare.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts b/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts index 00c813bea1b..ca6390b9621 100644 --- a/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts +++ b/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts @@ -16,7 +16,12 @@ export async function endpointCloudflare( input: z.input ): Promise { const { accountId, apiToken, model } = endpointCloudflareParametersSchema.parse(input); - const apiURL = `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/run/@hf/${model.id}`; + + if (!model.id.startsWith("@")) { + model.id = "@hf/" + model.id; + } + + const apiURL = `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/run/${model.id}`; return async ({ messages, preprompt, generateSettings }) => { let messagesFormatted = messages.map((message) => ({