@elizaos/plugin-google-genai 2.0.0-alpha.9 → 2.0.11-beta.7
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 +114 -0
- package/auto-enable.ts +21 -0
- package/package.json +41 -18
- package/dist/browser/index.browser.js +0 -540
- package/dist/browser/index.browser.js.map +0 -18
- package/dist/browser/index.d.ts +0 -2
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.node.cjs +0 -582
- package/dist/cjs/index.node.js.map +0 -18
- package/dist/index.d.ts +0 -2
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.node.js +0 -540
- package/dist/node/index.node.js.map +0 -18
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @elizaos/plugin-google-genai
|
|
2
|
+
|
|
3
|
+
Google Generative AI (Gemini) model provider for [elizaOS](https://github.com/elizaos/eliza) agents. Registers handlers for text generation, embeddings, and image description across all elizaOS model tiers, backed by the Google Generative AI API.
|
|
4
|
+
|
|
5
|
+
## Capabilities
|
|
6
|
+
|
|
7
|
+
- **Text generation** across all model tiers: nano, small, medium, large, mega, response handler, action planner.
|
|
8
|
+
- **Text embeddings** with `text-embedding-004` (768 dimensions).
|
|
9
|
+
- **Image description** — fetch an image by URL, encode it inline, and return a `{ title, description }` object.
|
|
10
|
+
- **Structured output** — pass a JSON Schema as `responseSchema` to any text handler to get `application/json` back from the model.
|
|
11
|
+
- **Tool use** — pass function declarations via `tools` / `toolChoice` to enable function-calling on supported models.
|
|
12
|
+
|
|
13
|
+
## Auto-enable
|
|
14
|
+
|
|
15
|
+
The plugin is automatically enabled by elizaOS when any of the following environment variables is set and non-empty:
|
|
16
|
+
|
|
17
|
+
- `GOOGLE_API_KEY`
|
|
18
|
+
- `GOOGLE_GENERATIVE_AI_API_KEY`
|
|
19
|
+
- `GEMINI_API_KEY`
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun add @elizaos/plugin-google-genai
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or register it explicitly in your agent character file:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"plugins": ["@elizaos/plugin-google-genai"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
| Environment variable | Required | Default | Description |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| `GOOGLE_GENERATIVE_AI_API_KEY` | Yes | — | API key from [Google AI Studio](https://aistudio.google.com/) |
|
|
40
|
+
| `GOOGLE_SMALL_MODEL` | No | `gemini-2.0-flash-001` | Small/fast text model |
|
|
41
|
+
| `GOOGLE_LARGE_MODEL` | No | `gemini-2.5-pro-preview-03-25` | Large/capable text model |
|
|
42
|
+
| `GOOGLE_NANO_MODEL` | No | falls back to small | Nano text model |
|
|
43
|
+
| `GOOGLE_MEDIUM_MODEL` | No | falls back to small | Medium text model |
|
|
44
|
+
| `GOOGLE_MEGA_MODEL` | No | falls back to large | Mega text model |
|
|
45
|
+
| `GOOGLE_RESPONSE_HANDLER_MODEL` | No | falls back to nano | Response handler model |
|
|
46
|
+
| `GOOGLE_ACTION_PLANNER_MODEL` | No | falls back to medium | Action planner model |
|
|
47
|
+
| `GOOGLE_EMBEDDING_MODEL` | No | `text-embedding-004` | Embedding model |
|
|
48
|
+
| `GOOGLE_IMAGE_MODEL` | No | `gemini-2.5-pro-preview-03-25` | Image description model |
|
|
49
|
+
|
|
50
|
+
Generic fallbacks (`SMALL_MODEL`, `LARGE_MODEL`, `IMAGE_MODEL`, etc.) are also respected when the `GOOGLE_*` prefix variants are not set.
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
Once the plugin is loaded, use any Gemini model through the standard elizaOS runtime interface:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { ModelType } from "@elizaos/core";
|
|
58
|
+
|
|
59
|
+
// Text generation
|
|
60
|
+
const text = await runtime.useModel(ModelType.TEXT_LARGE, {
|
|
61
|
+
prompt: "Explain quantum entanglement in plain language.",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Embeddings
|
|
65
|
+
const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
|
|
66
|
+
text: "Hello, world!",
|
|
67
|
+
});
|
|
68
|
+
// embedding is number[] with 768 dimensions
|
|
69
|
+
|
|
70
|
+
// Image description
|
|
71
|
+
const result = await runtime.useModel(
|
|
72
|
+
ModelType.IMAGE_DESCRIPTION,
|
|
73
|
+
"https://example.com/image.jpg",
|
|
74
|
+
);
|
|
75
|
+
// result: { title: string; description: string }
|
|
76
|
+
|
|
77
|
+
// Structured output
|
|
78
|
+
const person = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
79
|
+
prompt: "Generate a sample person profile.",
|
|
80
|
+
responseSchema: {
|
|
81
|
+
type: "object",
|
|
82
|
+
properties: {
|
|
83
|
+
name: { type: "string" },
|
|
84
|
+
age: { type: "number" },
|
|
85
|
+
},
|
|
86
|
+
required: ["name", "age"],
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Available model tiers
|
|
92
|
+
|
|
93
|
+
| ModelType | Default model | Notes |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `TEXT_NANO` | falls back to small | Fastest; shares small model by default |
|
|
96
|
+
| `TEXT_SMALL` | `gemini-2.0-flash-001` | Fast + structured output |
|
|
97
|
+
| `TEXT_MEDIUM` | falls back to small | |
|
|
98
|
+
| `TEXT_LARGE` | `gemini-2.5-pro-preview-03-25` | High-quality + structured output |
|
|
99
|
+
| `TEXT_MEGA` | falls back to large | |
|
|
100
|
+
| `RESPONSE_HANDLER` | falls back to nano | |
|
|
101
|
+
| `ACTION_PLANNER` | falls back to medium | |
|
|
102
|
+
| `TEXT_EMBEDDING` | `text-embedding-004` | 768-dim vectors |
|
|
103
|
+
| `IMAGE_DESCRIPTION` | `gemini-2.5-pro-preview-03-25` | Multimodal; fetches image by URL |
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
bun install
|
|
109
|
+
bun run --cwd plugins/plugin-google-genai build
|
|
110
|
+
bun run --cwd plugins/plugin-google-genai test
|
|
111
|
+
bun run --cwd plugins/plugin-google-genai typecheck
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
See [AGENTS.md](AGENTS.md) for the agent-facing layout reference and extension guide.
|
package/auto-enable.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Auto-enable check for @elizaos/plugin-google-genai.
|
|
2
|
+
//
|
|
3
|
+
// Plugin manifest entry-point — referenced by package.json's
|
|
4
|
+
// `elizaos.plugin.autoEnableModule`. Keep this module light: env reads only,
|
|
5
|
+
// no service init, no transitive imports of the full plugin runtime. The
|
|
6
|
+
// auto-enable engine loads dozens of these per boot.
|
|
7
|
+
import type { PluginAutoEnableContext } from "@elizaos/core";
|
|
8
|
+
|
|
9
|
+
const ENV_KEYS = [
|
|
10
|
+
"GOOGLE_API_KEY",
|
|
11
|
+
"GOOGLE_GENERATIVE_AI_API_KEY",
|
|
12
|
+
"GEMINI_API_KEY",
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
/** Enable when a Google Generative AI / Gemini API key is present. */
|
|
16
|
+
export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
|
|
17
|
+
return ENV_KEYS.some((k) => {
|
|
18
|
+
const v = ctx.env[k];
|
|
19
|
+
return typeof v === "string" && v.trim() !== "";
|
|
20
|
+
});
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-google-genai",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/node/index.node.js",
|
|
6
6
|
"module": "dist/node/index.node.js",
|
|
@@ -27,36 +27,59 @@
|
|
|
27
27
|
"types": "./dist/node/index.d.ts",
|
|
28
28
|
"default": "./dist/node/index.node.js"
|
|
29
29
|
},
|
|
30
|
-
"require": "./dist/cjs/index.node.cjs",
|
|
31
30
|
"default": "./dist/node/index.node.js"
|
|
31
|
+
},
|
|
32
|
+
"./*.css": "./dist/*.css",
|
|
33
|
+
"./*": {
|
|
34
|
+
"types": "./dist/*.d.ts",
|
|
35
|
+
"import": "./dist/*.js",
|
|
36
|
+
"default": "./dist/*.js"
|
|
32
37
|
}
|
|
33
38
|
},
|
|
34
39
|
"files": [
|
|
35
|
-
"dist"
|
|
40
|
+
"dist",
|
|
41
|
+
"auto-enable.ts"
|
|
36
42
|
],
|
|
43
|
+
"elizaos": {
|
|
44
|
+
"plugin": {
|
|
45
|
+
"autoEnableModule": "./auto-enable.ts",
|
|
46
|
+
"capabilities": [
|
|
47
|
+
"text-large",
|
|
48
|
+
"text-small",
|
|
49
|
+
"tool-use",
|
|
50
|
+
"embedding",
|
|
51
|
+
"image-description"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"sideEffects": false,
|
|
37
56
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@google/genai": "^1.5.1",
|
|
40
|
-
"undici": "^7.9.0"
|
|
57
|
+
"@google/genai": "^1.5.1"
|
|
41
58
|
},
|
|
42
59
|
"devDependencies": {
|
|
43
|
-
"@biomejs/biome": "^2.
|
|
60
|
+
"@biomejs/biome": "^2.4.14",
|
|
61
|
+
"@elizaos/core": "2.0.11-beta.7",
|
|
44
62
|
"@types/node": "^25.0.3",
|
|
63
|
+
"bun-types": "^1.3.12",
|
|
45
64
|
"dotenv": "^17.2.3",
|
|
46
|
-
"typescript": "^
|
|
65
|
+
"typescript": "^6.0.3",
|
|
66
|
+
"vitest": "^4.0.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@elizaos/core": "2.0.11-beta.7"
|
|
47
70
|
},
|
|
48
71
|
"scripts": {
|
|
49
72
|
"dev": "bun run build.ts --watch",
|
|
50
|
-
"clean": "rm -rf dist .turbo
|
|
73
|
+
"clean": "rm -rf dist .turbo .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
51
74
|
"format": "bunx @biomejs/biome format --write .",
|
|
52
75
|
"format:check": "bunx @biomejs/biome format .",
|
|
53
|
-
"typecheck": "
|
|
54
|
-
"test": "
|
|
55
|
-
"test:unit": "vitest run --
|
|
56
|
-
"test:integration": "vitest run --
|
|
57
|
-
"test:watch": "vitest",
|
|
58
|
-
"lint": "bunx @biomejs/biome check --write .",
|
|
59
|
-
"lint:check": "bunx @biomejs/biome check .",
|
|
76
|
+
"typecheck": "tsgo --noEmit -p tsconfig.json",
|
|
77
|
+
"test": "bunx vitest run --config vitest.config.ts",
|
|
78
|
+
"test:unit": "bunx vitest run --config vitest.config.ts --dir __tests__/unit",
|
|
79
|
+
"test:integration": "bunx vitest run --config vitest.config.ts --dir __tests__/integration",
|
|
80
|
+
"test:watch": "bunx vitest --config vitest.config.ts",
|
|
81
|
+
"lint": "bunx @biomejs/biome check --write --unsafe build.ts index.ts index.browser.ts index.node.ts init.ts __tests__ generated models types utils",
|
|
82
|
+
"lint:check": "bunx @biomejs/biome check build.ts index.ts index.browser.ts index.node.ts init.ts __tests__ generated models types utils",
|
|
60
83
|
"build": "bun run build.ts",
|
|
61
84
|
"build:ts": "bun run build.ts"
|
|
62
85
|
},
|
|
@@ -123,8 +146,8 @@
|
|
|
123
146
|
}
|
|
124
147
|
}
|
|
125
148
|
},
|
|
126
|
-
"gitHead": "
|
|
127
|
-
"
|
|
149
|
+
"gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e",
|
|
150
|
+
"eliza": {
|
|
128
151
|
"platforms": [
|
|
129
152
|
"browser",
|
|
130
153
|
"node"
|