diff --git a/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts b/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts index d8506f8a429..559db97feda 100644 --- a/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts +++ b/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts @@ -18,7 +18,7 @@ export async function endpointCloudflare( const { accountId, apiToken, model } = endpointCloudflareParametersSchema.parse(input); const apiURL = `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/run/@hf/${model.id}`; - return async ({ messages, preprompt }) => { + return async ({ messages, preprompt, generateSettings }) => { let messagesFormatted = messages.map((message) => ({ role: message.from, content: message.content, @@ -28,9 +28,16 @@ export async function endpointCloudflare( messagesFormatted = [{ role: "system", content: preprompt ?? "" }, ...messagesFormatted]; } + const parameters = { ...model.parameters, ...generateSettings }; + const payload = JSON.stringify({ messages: messagesFormatted, stream: true, + max_tokens: parameters?.max_new_tokens, + temperature: parameters?.temperature, + top_p: parameters?.top_p, + top_k: parameters?.top_k, + repetition_penalty: parameters?.repetition_penalty, }); const res = await fetch(apiURL, {