Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ragpipe/plugin-cloudflare

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ragpipe/plugin-cloudflare - npm Package Compare versions

Comparing version
0.3.0-alpha.1
to
0.3.0-alpha.2
+5
-14
dist/index.cjs

@@ -69,3 +69,3 @@ "use strict";

const { model } = options;
const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/run/${model}`;
const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/v1/chat/completions`;
function buildMessages(question, context, opts) {

@@ -99,3 +99,3 @@ const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context.";

},
body: JSON.stringify({ messages, stream: false })
body: JSON.stringify({ model, messages, stream: false })
});

@@ -108,12 +108,3 @@ if (!res.ok) {

const data = await res.json();
if (!data.success) {
throw new Error(
"Cloudflare generation error: API returned success=false"
);
}
if (data.result.choices?.length) {
const message = data.result.choices[0].message;
return message.content ?? message.reasoning_content ?? "";
}
return data.result.response ?? "";
return data.choices?.[0]?.message?.content ?? "";
},

@@ -128,3 +119,3 @@ async *generateStream(question, context, opts) {

},
body: JSON.stringify({ messages, stream: true })
body: JSON.stringify({ model, messages, stream: true })
});

@@ -153,3 +144,3 @@ if (!res.ok) {

const data = JSON.parse(payload);
const chunk = data.choices?.[0]?.delta?.content ?? data.response;
const chunk = data.choices?.[0]?.delta?.content;
if (chunk) yield chunk;

@@ -156,0 +147,0 @@ } catch {

@@ -42,3 +42,3 @@ // src/embedding.ts

const { model } = options;
const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/run/${model}`;
const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/v1/chat/completions`;
function buildMessages(question, context, opts) {

@@ -72,3 +72,3 @@ const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context.";

},
body: JSON.stringify({ messages, stream: false })
body: JSON.stringify({ model, messages, stream: false })
});

@@ -81,12 +81,3 @@ if (!res.ok) {

const data = await res.json();
if (!data.success) {
throw new Error(
"Cloudflare generation error: API returned success=false"
);
}
if (data.result.choices?.length) {
const message = data.result.choices[0].message;
return message.content ?? message.reasoning_content ?? "";
}
return data.result.response ?? "";
return data.choices?.[0]?.message?.content ?? "";
},

@@ -101,3 +92,3 @@ async *generateStream(question, context, opts) {

},
body: JSON.stringify({ messages, stream: true })
body: JSON.stringify({ model, messages, stream: true })
});

@@ -126,3 +117,3 @@ if (!res.ok) {

const data = JSON.parse(payload);
const chunk = data.choices?.[0]?.delta?.content ?? data.response;
const chunk = data.choices?.[0]?.delta?.content;
if (chunk) yield chunk;

@@ -129,0 +120,0 @@ } catch {

{
"name": "@ragpipe/plugin-cloudflare",
"version": "0.3.0-alpha.1",
"version": "0.3.0-alpha.2",
"description": "Cloudflare Workers AI embedding and generation plugin for ragpipe",

@@ -5,0 +5,0 @@ "type": "module",