@ragpipe/plugin-gemini
Advanced tools
+5
-3
@@ -30,7 +30,8 @@ "use strict"; | ||
| function geminiEmbedding(options) { | ||
| const model = options.model ?? "gemini-embedding-001"; | ||
| const { model } = options; | ||
| return { | ||
| name: "gemini", | ||
| dimensions: 3072, | ||
| dimensions: options.dimensions ?? 3072, | ||
| rateLimit: { delayMs: 800 }, | ||
| model, | ||
| async embed(text) { | ||
@@ -79,3 +80,3 @@ const res = await fetch( | ||
| function geminiGeneration(options) { | ||
| const model = options.model ?? "gemini-2.5-flash"; | ||
| const { model } = options; | ||
| function buildBody(question, context, opts) { | ||
@@ -100,2 +101,3 @@ const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context."; | ||
| name: "gemini", | ||
| model, | ||
| async generate(question, context, opts) { | ||
@@ -102,0 +104,0 @@ const body = buildBody(question, context, opts); |
+3
-2
@@ -5,3 +5,4 @@ import { EmbeddingPlugin, GenerationPlugin } from 'ragpipe'; | ||
| apiKey: string; | ||
| model?: string; | ||
| model: string; | ||
| dimensions?: number; | ||
| } | ||
@@ -12,3 +13,3 @@ declare function geminiEmbedding(options: GeminiEmbeddingOptions): EmbeddingPlugin; | ||
| apiKey: string; | ||
| model?: string; | ||
| model: string; | ||
| systemPrompt?: string; | ||
@@ -15,0 +16,0 @@ } |
+3
-2
@@ -5,3 +5,4 @@ import { EmbeddingPlugin, GenerationPlugin } from 'ragpipe'; | ||
| apiKey: string; | ||
| model?: string; | ||
| model: string; | ||
| dimensions?: number; | ||
| } | ||
@@ -12,3 +13,3 @@ declare function geminiEmbedding(options: GeminiEmbeddingOptions): EmbeddingPlugin; | ||
| apiKey: string; | ||
| model?: string; | ||
| model: string; | ||
| systemPrompt?: string; | ||
@@ -15,0 +16,0 @@ } |
+5
-3
| // src/embedding.ts | ||
| function geminiEmbedding(options) { | ||
| const model = options.model ?? "gemini-embedding-001"; | ||
| const { model } = options; | ||
| return { | ||
| name: "gemini", | ||
| dimensions: 3072, | ||
| dimensions: options.dimensions ?? 3072, | ||
| rateLimit: { delayMs: 800 }, | ||
| model, | ||
| async embed(text) { | ||
@@ -51,3 +52,3 @@ const res = await fetch( | ||
| function geminiGeneration(options) { | ||
| const model = options.model ?? "gemini-2.5-flash"; | ||
| const { model } = options; | ||
| function buildBody(question, context, opts) { | ||
@@ -72,2 +73,3 @@ const systemPrompt = opts?.systemPrompt ?? options.systemPrompt ?? "Answer based on the provided context."; | ||
| name: "gemini", | ||
| model, | ||
| async generate(question, context, opts) { | ||
@@ -74,0 +76,0 @@ const body = buildBody(question, context, opts); |
+63
-60
| { | ||
| "name": "@ragpipe/plugin-gemini", | ||
| "version": "0.2.0-alpha.1", | ||
| "description": "Gemini embedding and generation plugin for ragpipe", | ||
| "type": "module", | ||
| "license": "MIT", | ||
| "author": { | ||
| "name": "yungblud", | ||
| "url": "https://github.com/yungblud" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/yungblud/ragpipe", | ||
| "directory": "packages/plugin-gemini" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/yungblud/ragpipe/issues" | ||
| }, | ||
| "homepage": "https://github.com/yungblud/ragpipe#readme", | ||
| "publishConfig": { | ||
| "registry": "https://registry.npmjs.org/", | ||
| "access": "public" | ||
| }, | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.cjs" | ||
| } | ||
| }, | ||
| "main": "./dist/index.cjs", | ||
| "module": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "files": ["dist", "README.md"], | ||
| "scripts": { | ||
| "build": "tsup", | ||
| "dev": "tsup --watch", | ||
| "typecheck": "tsc --noEmit", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "test:coverage": "vitest run --coverage" | ||
| }, | ||
| "keywords": [ | ||
| "ragpipe", | ||
| "rag", | ||
| "gemini", | ||
| "google-ai", | ||
| "embedding", | ||
| "generation", | ||
| "plugin" | ||
| ], | ||
| "peerDependencies": { | ||
| "ragpipe": ">=0.0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "ragpipe": "workspace:*", | ||
| "tsup": "^8.4.0", | ||
| "typescript": "^5.8.3", | ||
| "vitest": "^3.1.1" | ||
| } | ||
| } | ||
| "name": "@ragpipe/plugin-gemini", | ||
| "version": "0.2.0", | ||
| "description": "Gemini embedding and generation plugin for ragpipe", | ||
| "type": "module", | ||
| "license": "MIT", | ||
| "author": { | ||
| "name": "yungblud", | ||
| "url": "https://github.com/yungblud" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/yungblud/ragpipe", | ||
| "directory": "packages/plugin-gemini" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/yungblud/ragpipe/issues" | ||
| }, | ||
| "homepage": "https://github.com/yungblud/ragpipe#readme", | ||
| "publishConfig": { | ||
| "registry": "https://registry.npmjs.org/", | ||
| "access": "public" | ||
| }, | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.cjs" | ||
| } | ||
| }, | ||
| "main": "./dist/index.cjs", | ||
| "module": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "files": [ | ||
| "dist", | ||
| "README.md" | ||
| ], | ||
| "keywords": [ | ||
| "ragpipe", | ||
| "rag", | ||
| "gemini", | ||
| "google-ai", | ||
| "embedding", | ||
| "generation", | ||
| "plugin" | ||
| ], | ||
| "peerDependencies": { | ||
| "ragpipe": ">=0.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "tsup": "^8.4.0", | ||
| "typescript": "^5.8.3", | ||
| "vitest": "^3.1.1", | ||
| "ragpipe": "0.2.0" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsup", | ||
| "dev": "tsup --watch", | ||
| "typecheck": "tsc --noEmit", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "test:coverage": "vitest run --coverage" | ||
| } | ||
| } |
+4
-4
@@ -20,7 +20,7 @@ # @ragpipe/plugin-gemini | ||
| apiKey: process.env.GEMINI_API_KEY ?? "", | ||
| model: "gemini-embedding-001", // default | ||
| model: "gemini-embedding-001", | ||
| }), | ||
| generation: geminiGeneration({ | ||
| apiKey: process.env.GEMINI_API_KEY ?? "", | ||
| model: "gemini-2.5-flash", // default | ||
| model: "gemini-3.1-flash-lite-preview", | ||
| systemPrompt: "Answer based on the provided context.", | ||
@@ -41,3 +41,3 @@ }), | ||
| | `apiKey` | `string` | — | Google AI API key (required) | | ||
| | `model` | `string` | `"gemini-embedding-001"` | Embedding model name | | ||
| | `model` | `string` | - | Embedding model name (required) | | ||
@@ -55,3 +55,3 @@ - **Dimensions**: 3072 | ||
| | `apiKey` | `string` | — | Google AI API key (required) | | ||
| | `model` | `string` | `"gemini-2.5-flash"` | Generation model name | | ||
| | `model` | `string` | - | Generation model name (required) | | ||
| | `systemPrompt` | `string` | `"Answer based on the provided context."` | Default system instruction | | ||
@@ -58,0 +58,0 @@ |
13810
0.66%306
1.66%