@ragpipe/plugin-cloudflare 0.2.0-alpha.1 → 0.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -2
- package/dist/index.js +7 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -108,7 +108,11 @@ ${userPrompt}`;
|
|
|
108
108
|
"Cloudflare generation error: API returned success=false"
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
if (data.result.choices?.length) {
|
|
112
|
+
const message = data.result.choices[0].message;
|
|
113
|
+
return message.content ?? message.reasoning_content ?? "";
|
|
114
|
+
}
|
|
115
|
+
return data.result.response ?? "";
|
|
112
116
|
},
|
|
113
117
|
async *generateStream(question, context, opts) {
|
|
114
118
|
const messages = buildMessages(question, context, opts);
|
|
@@ -142,7 +146,8 @@ ${userPrompt}`;
|
|
|
142
146
|
if (payload === "[DONE]") return;
|
|
143
147
|
try {
|
|
144
148
|
const data = JSON.parse(payload);
|
|
145
|
-
|
|
149
|
+
const chunk = data.choices?.[0]?.delta?.content ?? data.response;
|
|
150
|
+
if (chunk) yield chunk;
|
|
146
151
|
} catch {
|
|
147
152
|
}
|
|
148
153
|
}
|
package/dist/index.js
CHANGED
|
@@ -81,7 +81,11 @@ ${userPrompt}`;
|
|
|
81
81
|
"Cloudflare generation error: API returned success=false"
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
if (data.result.choices?.length) {
|
|
85
|
+
const message = data.result.choices[0].message;
|
|
86
|
+
return message.content ?? message.reasoning_content ?? "";
|
|
87
|
+
}
|
|
88
|
+
return data.result.response ?? "";
|
|
85
89
|
},
|
|
86
90
|
async *generateStream(question, context, opts) {
|
|
87
91
|
const messages = buildMessages(question, context, opts);
|
|
@@ -115,7 +119,8 @@ ${userPrompt}`;
|
|
|
115
119
|
if (payload === "[DONE]") return;
|
|
116
120
|
try {
|
|
117
121
|
const data = JSON.parse(payload);
|
|
118
|
-
|
|
122
|
+
const chunk = data.choices?.[0]?.delta?.content ?? data.response;
|
|
123
|
+
if (chunk) yield chunk;
|
|
119
124
|
} catch {
|
|
120
125
|
}
|
|
121
126
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ragpipe/plugin-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
4
|
"description": "Cloudflare Workers AI embedding and generation plugin for ragpipe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"plugin"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"ragpipe": ">=0.
|
|
53
|
+
"ragpipe": ">=0.3.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"ragpipe": "workspace:*",
|