@ragpipe/plugin-gemini 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -17,11 +17,11 @@ import { geminiEmbedding, geminiGeneration } from "@ragpipe/plugin-gemini";
17
17
  export default defineConfig({
18
18
  embedding: geminiEmbedding({
19
19
  apiKey: process.env.GEMINI_API_KEY ?? "",
20
- model: "gemini-embedding-001", // default
20
+ model: "gemini-embedding-001",
21
21
  }),
22
22
  generation: geminiGeneration({
23
23
  apiKey: process.env.GEMINI_API_KEY ?? "",
24
- model: "gemini-2.5-flash", // default
24
+ model: "gemini-3.1-flash-lite-preview",
25
25
  systemPrompt: "Answer based on the provided context.",
26
26
  }),
27
27
  // ... vectorStore
@@ -37,7 +37,7 @@ Returns an `EmbeddingPlugin` that calls the Gemini Embedding API.
37
37
  | Option | Type | Default | Description |
38
38
  |---|---|---|---|
39
39
  | `apiKey` | `string` | — | Google AI API key (required) |
40
- | `model` | `string` | `"gemini-embedding-001"` | Embedding model name |
40
+ | `model` | `string` | - | Embedding model name (required) |
41
41
 
42
42
  - **Dimensions**: 3072
43
43
  - **Rate limit**: 800ms between calls (built-in)
@@ -50,7 +50,7 @@ Returns a `GenerationPlugin` that calls the Gemini Content Generation API.
50
50
  | Option | Type | Default | Description |
51
51
  |---|---|---|---|
52
52
  | `apiKey` | `string` | — | Google AI API key (required) |
53
- | `model` | `string` | `"gemini-2.5-flash"` | Generation model name |
53
+ | `model` | `string` | - | Generation model name (required) |
54
54
  | `systemPrompt` | `string` | `"Answer based on the provided context."` | Default system instruction |
55
55
 
56
56
  - **Streaming**: `generateStream()` returns an `AsyncIterable<string>` via SSE
package/dist/index.cjs CHANGED
@@ -27,11 +27,12 @@ module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/embedding.ts
29
29
  function geminiEmbedding(options) {
30
- const model = options.model ?? "gemini-embedding-001";
30
+ const { model } = options;
31
31
  return {
32
32
  name: "gemini",
33
- dimensions: 3072,
33
+ dimensions: options.dimensions ?? 3072,
34
34
  rateLimit: { delayMs: 800 },
35
+ model,
35
36
  async embed(text) {
36
37
  const res = await fetch(
37
38
  `https://generativelanguage.googleapis.com/v1beta/models/${model}:embedContent?key=${options.apiKey}`,
@@ -75,7 +76,7 @@ function geminiEmbedding(options) {
75
76
 
76
77
  // src/generation.ts
77
78
  function geminiGeneration(options) {
78
- const model = options.model ?? "gemini-2.5-flash";
79
+ const { model } = options;
79
80
  function buildBody(question, context, opts) {
80
81
  const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context.";
81
82
  let userPrompt = `Context:
@@ -95,6 +96,7 @@ ${userPrompt}`;
95
96
  }
96
97
  return {
97
98
  name: "gemini",
99
+ model,
98
100
  async generate(question, context, opts) {
99
101
  const body = buildBody(question, context, opts);
100
102
  const res = await fetch(
package/dist/index.d.cts CHANGED
@@ -2,13 +2,14 @@ import { EmbeddingPlugin, GenerationPlugin } from 'ragpipe';
2
2
 
3
3
  interface GeminiEmbeddingOptions {
4
4
  apiKey: string;
5
- model?: string;
5
+ model: string;
6
+ dimensions?: number;
6
7
  }
7
8
  declare function geminiEmbedding(options: GeminiEmbeddingOptions): EmbeddingPlugin;
8
9
 
9
10
  interface GeminiGenerationOptions {
10
11
  apiKey: string;
11
- model?: string;
12
+ model: string;
12
13
  systemPrompt?: string;
13
14
  }
14
15
  declare function geminiGeneration(options: GeminiGenerationOptions): GenerationPlugin;
package/dist/index.d.ts CHANGED
@@ -2,13 +2,14 @@ import { EmbeddingPlugin, GenerationPlugin } from 'ragpipe';
2
2
 
3
3
  interface GeminiEmbeddingOptions {
4
4
  apiKey: string;
5
- model?: string;
5
+ model: string;
6
+ dimensions?: number;
6
7
  }
7
8
  declare function geminiEmbedding(options: GeminiEmbeddingOptions): EmbeddingPlugin;
8
9
 
9
10
  interface GeminiGenerationOptions {
10
11
  apiKey: string;
11
- model?: string;
12
+ model: string;
12
13
  systemPrompt?: string;
13
14
  }
14
15
  declare function geminiGeneration(options: GeminiGenerationOptions): GenerationPlugin;
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  // src/embedding.ts
2
2
  function geminiEmbedding(options) {
3
- const model = options.model ?? "gemini-embedding-001";
3
+ const { model } = options;
4
4
  return {
5
5
  name: "gemini",
6
- dimensions: 3072,
6
+ dimensions: options.dimensions ?? 3072,
7
7
  rateLimit: { delayMs: 800 },
8
+ model,
8
9
  async embed(text) {
9
10
  const res = await fetch(
10
11
  `https://generativelanguage.googleapis.com/v1beta/models/${model}:embedContent?key=${options.apiKey}`,
@@ -48,7 +49,7 @@ function geminiEmbedding(options) {
48
49
 
49
50
  // src/generation.ts
50
51
  function geminiGeneration(options) {
51
- const model = options.model ?? "gemini-2.5-flash";
52
+ const { model } = options;
52
53
  function buildBody(question, context, opts) {
53
54
  const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context.";
54
55
  let userPrompt = `Context:
@@ -68,6 +69,7 @@ ${userPrompt}`;
68
69
  }
69
70
  return {
70
71
  name: "gemini",
72
+ model,
71
73
  async generate(question, context, opts) {
72
74
  const body = buildBody(question, context, opts);
73
75
  const res = await fetch(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ragpipe/plugin-gemini",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Gemini embedding and generation plugin for ragpipe",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,13 +45,13 @@
45
45
  "plugin"
46
46
  ],
47
47
  "peerDependencies": {
48
- "ragpipe": ">=0.0.1"
48
+ "ragpipe": ">=0.2.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.4.0",
52
52
  "typescript": "^5.8.3",
53
53
  "vitest": "^3.1.1",
54
- "ragpipe": "0.1.0"
54
+ "ragpipe": "0.2.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "tsup",