Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
W. Gustavo Cevallos
commited on
Add support to @cf models with cloudflare.com (#1378)
Browse filesAdd 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 |
-
|
|
|
|
|
|
|
|
|
|
|
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) => ({
|