W. Gustavo Cevallos commited on
Commit
b831f4b
·
unverified ·
1 Parent(s): aa1ef18

Add support to @cf models with cloudflare.com (#1378)

Browse files

Add support to

@cf
models in cloudflare.com

src/lib/server/endpoints/cloudflare/endpointCloudflare.ts CHANGED
@@ -16,7 +16,12 @@ export async function endpointCloudflare(
16
  input: z.input<typeof endpointCloudflareParametersSchema>
17
  ): Promise<Endpoint> {
18
  const { accountId, apiToken, model } = endpointCloudflareParametersSchema.parse(input);
19
- const apiURL = `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/run/@hf/${model.id}`;
 
 
 
 
 
20
 
21
  return async ({ messages, preprompt, generateSettings }) => {
22
  let messagesFormatted = messages.map((message) => ({
 
16
  input: z.input<typeof endpointCloudflareParametersSchema>
17
  ): Promise<Endpoint> {
18
  const { accountId, apiToken, model } = endpointCloudflareParametersSchema.parse(input);
19
+
20
+ if (!model.id.startsWith("@")) {
21
+ model.id = "@hf/" + model.id;
22
+ }
23
+
24
+ const apiURL = `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/run/${model.id}`;
25
 
26
  return async ({ messages, preprompt, generateSettings }) => {
27
  let messagesFormatted = messages.map((message) => ({