@ragpipe/plugin-cloudflare 0.0.1 → 0.1.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 CHANGED
@@ -26,15 +26,8 @@ __export(index_exports, {
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/embedding.ts
29
- var DIMENSION_MAP = {
30
- "@cf/baai/bge-base-en-v1.5": 768,
31
- "@cf/baai/bge-large-en-v1.5": 1024,
32
- "@cf/baai/bge-small-en-v1.5": 384
33
- };
34
- var DEFAULT_MODEL = "@cf/baai/bge-base-en-v1.5";
35
29
  function cloudflareEmbedding(options) {
36
- const model = options.model ?? DEFAULT_MODEL;
37
- const dimensions = DIMENSION_MAP[model] ?? 768;
30
+ const { model } = options;
38
31
  const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/run/${model}`;
39
32
  async function callApi(text) {
40
33
  const res = await fetch(baseUrl, {
@@ -58,7 +51,7 @@ function cloudflareEmbedding(options) {
58
51
  }
59
52
  return {
60
53
  name: "cloudflare",
61
- dimensions,
54
+ dimensions: 768,
62
55
  async embed(text) {
63
56
  const vectors = await callApi([text]);
64
57
  return vectors[0];
@@ -70,9 +63,9 @@ function cloudflareEmbedding(options) {
70
63
  }
71
64
 
72
65
  // src/generation.ts
73
- var DEFAULT_MODEL2 = "@cf/meta/llama-3.1-8b-instruct";
66
+ var DEFAULT_MODEL = "@cf/meta/llama-3.1-8b-instruct";
74
67
  function cloudflareGeneration(options) {
75
- const model = options.model ?? DEFAULT_MODEL2;
68
+ const model = options.model ?? DEFAULT_MODEL;
76
69
  const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/run/${model}`;
77
70
  function buildMessages(question, context, opts) {
78
71
  const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context.";
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import { EmbeddingPlugin, GenerationPlugin } from 'ragpipe';
3
3
  interface CloudflareEmbeddingOptions {
4
4
  accountId: string;
5
5
  apiToken: string;
6
- model?: string;
6
+ model: string;
7
7
  }
8
8
  declare function cloudflareEmbedding(options: CloudflareEmbeddingOptions): EmbeddingPlugin;
9
9
 
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { EmbeddingPlugin, GenerationPlugin } from 'ragpipe';
3
3
  interface CloudflareEmbeddingOptions {
4
4
  accountId: string;
5
5
  apiToken: string;
6
- model?: string;
6
+ model: string;
7
7
  }
8
8
  declare function cloudflareEmbedding(options: CloudflareEmbeddingOptions): EmbeddingPlugin;
9
9
 
package/dist/index.js CHANGED
@@ -1,13 +1,6 @@
1
1
  // src/embedding.ts
2
- var DIMENSION_MAP = {
3
- "@cf/baai/bge-base-en-v1.5": 768,
4
- "@cf/baai/bge-large-en-v1.5": 1024,
5
- "@cf/baai/bge-small-en-v1.5": 384
6
- };
7
- var DEFAULT_MODEL = "@cf/baai/bge-base-en-v1.5";
8
2
  function cloudflareEmbedding(options) {
9
- const model = options.model ?? DEFAULT_MODEL;
10
- const dimensions = DIMENSION_MAP[model] ?? 768;
3
+ const { model } = options;
11
4
  const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/run/${model}`;
12
5
  async function callApi(text) {
13
6
  const res = await fetch(baseUrl, {
@@ -31,7 +24,7 @@ function cloudflareEmbedding(options) {
31
24
  }
32
25
  return {
33
26
  name: "cloudflare",
34
- dimensions,
27
+ dimensions: 768,
35
28
  async embed(text) {
36
29
  const vectors = await callApi([text]);
37
30
  return vectors[0];
@@ -43,9 +36,9 @@ function cloudflareEmbedding(options) {
43
36
  }
44
37
 
45
38
  // src/generation.ts
46
- var DEFAULT_MODEL2 = "@cf/meta/llama-3.1-8b-instruct";
39
+ var DEFAULT_MODEL = "@cf/meta/llama-3.1-8b-instruct";
47
40
  function cloudflareGeneration(options) {
48
- const model = options.model ?? DEFAULT_MODEL2;
41
+ const model = options.model ?? DEFAULT_MODEL;
49
42
  const baseUrl = `https://api.cloudflare.com/client/v4/accounts/${options.accountId}/ai/run/${model}`;
50
43
  function buildMessages(question, context, opts) {
51
44
  const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ragpipe/plugin-cloudflare",
3
- "version": "0.0.1",
3
+ "version": "0.1.0-alpha.1",
4
4
  "description": "Cloudflare Workers AI embedding and generation plugin for ragpipe",
5
5
  "type": "module",
6
6
  "license": "MIT",