@elizaos/plugin-google-genai 2.0.0-beta.1 → 2.0.3-beta.2
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 +70 -80
- package/package.json +11 -5
- package/dist/browser/index.browser.js +0 -780
- package/dist/browser/index.browser.js.map +0 -18
- package/dist/browser/index.d.ts +0 -2
- package/dist/build.d.ts +0 -3
- package/dist/build.d.ts.map +0 -1
- package/dist/build.js +0 -117
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.node.cjs +0 -840
- package/dist/cjs/index.node.js.map +0 -18
- package/dist/generated/specs/specs.d.ts +0 -55
- package/dist/generated/specs/specs.d.ts.map +0 -1
- package/dist/generated/specs/specs.js +0 -34
- package/dist/index.browser.d.ts +0 -5
- package/dist/index.browser.d.ts.map +0 -1
- package/dist/index.browser.js +0 -4
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -252
- package/dist/index.node.d.ts +0 -5
- package/dist/index.node.d.ts.map +0 -1
- package/dist/index.node.js +0 -4
- package/dist/init.d.ts +0 -16
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -27
- package/dist/models/embedding.d.ts +0 -6
- package/dist/models/embedding.d.ts.map +0 -1
- package/dist/models/embedding.js +0 -57
- package/dist/models/image.d.ts +0 -7
- package/dist/models/image.d.ts.map +0 -1
- package/dist/models/image.js +0 -91
- package/dist/models/index.d.ts +0 -13
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -12
- package/dist/models/object.d.ts +0 -10
- package/dist/models/object.d.ts.map +0 -1
- package/dist/models/object.js +0 -84
- package/dist/models/text.d.ts +0 -51
- package/dist/models/text.d.ts.map +0 -1
- package/dist/models/text.js +0 -257
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.node.d.ts +0 -2
- package/dist/node/index.node.js +0 -780
- package/dist/node/index.node.js.map +0 -18
- package/dist/types/index.d.ts +0 -47
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -1
- package/dist/utils/config.d.ts +0 -25
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -115
- package/dist/utils/events.d.ts +0 -12
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js +0 -14
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -3
- package/dist/utils/tokenization.d.ts +0 -2
- package/dist/utils/tokenization.d.ts.map +0 -1
- package/dist/utils/tokenization.js +0 -3
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -8
package/README.md
CHANGED
|
@@ -1,71 +1,82 @@
|
|
|
1
1
|
# @elizaos/plugin-google-genai
|
|
2
2
|
|
|
3
|
-
Google Generative AI (Gemini)
|
|
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
4
|
|
|
5
|
-
##
|
|
5
|
+
## Capabilities
|
|
6
6
|
|
|
7
|
-
- **Text
|
|
8
|
-
- **
|
|
9
|
-
- **Image
|
|
10
|
-
- **
|
|
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.
|
|
11
12
|
|
|
12
|
-
##
|
|
13
|
+
## Auto-enable
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
| ----------------- | ---------------------------- | ---------------------------------- |
|
|
16
|
-
| TEXT_SMALL | gemini-2.0-flash-001 | Fast text + structured output (responseSchema, tools) |
|
|
17
|
-
| TEXT_LARGE | gemini-2.5-pro-preview-03-25 | Capable text + structured output (responseSchema, tools) |
|
|
18
|
-
| TEXT_EMBEDDING | text-embedding-004 | Text embeddings (768 dimensions) |
|
|
19
|
-
| IMAGE_DESCRIPTION | gemini-2.5-pro-preview-03-25 | Multimodal image analysis |
|
|
15
|
+
The plugin is automatically enabled by elizaOS when any of the following environment variables is set and non-empty:
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
- `GOOGLE_API_KEY`
|
|
18
|
+
- `GOOGLE_GENERATIVE_AI_API_KEY`
|
|
19
|
+
- `GEMINI_API_KEY`
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
## Installation
|
|
24
22
|
|
|
25
23
|
```bash
|
|
26
|
-
npm install @elizaos/plugin-google-genai
|
|
27
|
-
# or
|
|
28
24
|
bun add @elizaos/plugin-google-genai
|
|
29
25
|
```
|
|
30
|
-
## Configuration
|
|
31
26
|
|
|
32
|
-
|
|
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
|
|
33
36
|
|
|
34
|
-
|
|
|
35
|
-
|
|
36
|
-
| `GOOGLE_GENERATIVE_AI_API_KEY` | Yes
|
|
37
|
-
| `GOOGLE_SMALL_MODEL`
|
|
38
|
-
| `GOOGLE_LARGE_MODEL`
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
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.
|
|
42
51
|
|
|
43
52
|
## Usage
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
Once the plugin is loaded, use any Gemini model through the standard elizaOS runtime interface:
|
|
46
55
|
|
|
47
56
|
```typescript
|
|
48
|
-
import {
|
|
57
|
+
import { ModelType } from "@elizaos/core";
|
|
49
58
|
|
|
50
|
-
//
|
|
51
|
-
const agent = new Agent({
|
|
52
|
-
plugins: [googleGenAIPlugin],
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Use via runtime
|
|
59
|
+
// Text generation
|
|
56
60
|
const text = await runtime.useModel(ModelType.TEXT_LARGE, {
|
|
57
|
-
prompt: "Explain quantum
|
|
61
|
+
prompt: "Explain quantum entanglement in plain language.",
|
|
58
62
|
});
|
|
59
63
|
|
|
64
|
+
// Embeddings
|
|
60
65
|
const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
|
|
61
66
|
text: "Hello, world!",
|
|
62
67
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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.",
|
|
69
80
|
responseSchema: {
|
|
70
81
|
type: "object",
|
|
71
82
|
properties: {
|
|
@@ -76,49 +87,28 @@ const structured = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
|
76
87
|
},
|
|
77
88
|
});
|
|
78
89
|
```
|
|
79
|
-
## Project Structure
|
|
80
90
|
|
|
81
|
-
|
|
82
|
-
plugin-google-genai/
|
|
83
|
-
├── typescript/ # TypeScript implementation
|
|
84
|
-
│ ├── index.ts # Main plugin entry
|
|
85
|
-
│ ├── models/ # Model handlers
|
|
86
|
-
│ ├── utils/ # Utility functions
|
|
87
|
-
│ └── __tests__/ # Unit and integration tests
|
|
88
|
-
├── package.json # npm publishing config
|
|
89
|
-
└── README.md # This file
|
|
90
|
-
```
|
|
91
|
+
## Available model tiers
|
|
91
92
|
|
|
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 |
|
|
93
104
|
|
|
94
|
-
|
|
105
|
+
## Development
|
|
95
106
|
|
|
96
107
|
```bash
|
|
97
|
-
# Install dependencies
|
|
98
108
|
bun install
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
bun run
|
|
102
|
-
|
|
103
|
-
# Run tests
|
|
104
|
-
bun run test
|
|
105
|
-
|
|
106
|
-
# Type checking
|
|
107
|
-
bun run typecheck
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Publishing
|
|
111
|
-
|
|
112
|
-
### npm (TypeScript)
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
npm publish --access public
|
|
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
|
|
116
112
|
```
|
|
117
113
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
MIT
|
|
121
|
-
|
|
122
|
-
## Contributing
|
|
123
|
-
|
|
124
|
-
See the main [elizaOS contribution guidelines](https://github.com/elizaos/eliza/blob/main/CONTRIBUTING.md).
|
|
114
|
+
See [AGENTS.md](AGENTS.md) for the agent-facing layout reference and extension guide.
|
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.3-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/node/index.node.js",
|
|
6
6
|
"module": "dist/node/index.node.js",
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
"default": "./dist/node/index.node.js"
|
|
29
29
|
},
|
|
30
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"
|
|
31
37
|
}
|
|
32
38
|
},
|
|
33
39
|
"files": [
|
|
@@ -52,7 +58,7 @@
|
|
|
52
58
|
},
|
|
53
59
|
"devDependencies": {
|
|
54
60
|
"@biomejs/biome": "^2.4.14",
|
|
55
|
-
"@elizaos/core": "2.0.
|
|
61
|
+
"@elizaos/core": "2.0.3-beta.2",
|
|
56
62
|
"@types/node": "^25.0.3",
|
|
57
63
|
"bun-types": "^1.3.12",
|
|
58
64
|
"dotenv": "^17.2.3",
|
|
@@ -60,14 +66,14 @@
|
|
|
60
66
|
"vitest": "^4.0.0"
|
|
61
67
|
},
|
|
62
68
|
"peerDependencies": {
|
|
63
|
-
"@elizaos/core": "2.0.
|
|
69
|
+
"@elizaos/core": "2.0.3-beta.2"
|
|
64
70
|
},
|
|
65
71
|
"scripts": {
|
|
66
72
|
"dev": "bun run build.ts --watch",
|
|
67
73
|
"clean": "rm -rf dist .turbo .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
68
74
|
"format": "bunx @biomejs/biome format --write .",
|
|
69
75
|
"format:check": "bunx @biomejs/biome format .",
|
|
70
|
-
"typecheck": "
|
|
76
|
+
"typecheck": "tsgo --noEmit -p tsconfig.json",
|
|
71
77
|
"test": "bunx vitest run --config vitest.config.ts",
|
|
72
78
|
"test:unit": "bunx vitest run --config vitest.config.ts --dir __tests__/unit",
|
|
73
79
|
"test:integration": "bunx vitest run --config vitest.config.ts --dir __tests__/integration",
|
|
@@ -140,7 +146,7 @@
|
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
148
|
},
|
|
143
|
-
"gitHead": "
|
|
149
|
+
"gitHead": "82fe0f44215954c2417328203f5bd6510985c1fc",
|
|
144
150
|
"eliza": {
|
|
145
151
|
"platforms": [
|
|
146
152
|
"browser",
|