@elizaos/plugin-google-genai 2.0.0-alpha.9 → 2.0.0-beta.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.
Files changed (60) hide show
  1. package/README.md +124 -0
  2. package/auto-enable.ts +21 -0
  3. package/dist/browser/index.browser.js +415 -175
  4. package/dist/browser/index.browser.js.map +11 -11
  5. package/dist/build.d.ts +3 -0
  6. package/dist/build.d.ts.map +1 -0
  7. package/dist/build.js +117 -0
  8. package/dist/cjs/index.node.cjs +439 -181
  9. package/dist/cjs/index.node.js.map +11 -11
  10. package/dist/generated/specs/specs.d.ts +55 -0
  11. package/dist/generated/specs/specs.d.ts.map +1 -0
  12. package/dist/generated/specs/specs.js +34 -0
  13. package/dist/index.browser.d.ts +5 -0
  14. package/dist/index.browser.d.ts.map +1 -0
  15. package/dist/index.browser.js +4 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +252 -0
  18. package/dist/index.node.d.ts +5 -0
  19. package/dist/index.node.d.ts.map +1 -0
  20. package/dist/index.node.js +4 -0
  21. package/dist/init.d.ts +16 -0
  22. package/dist/init.d.ts.map +1 -0
  23. package/dist/init.js +27 -0
  24. package/dist/models/embedding.d.ts +6 -0
  25. package/dist/models/embedding.d.ts.map +1 -0
  26. package/dist/models/embedding.js +57 -0
  27. package/dist/models/image.d.ts +7 -0
  28. package/dist/models/image.d.ts.map +1 -0
  29. package/dist/models/image.js +91 -0
  30. package/dist/models/index.d.ts +13 -0
  31. package/dist/models/index.d.ts.map +1 -0
  32. package/dist/models/index.js +12 -0
  33. package/dist/models/object.d.ts +10 -0
  34. package/dist/models/object.d.ts.map +1 -0
  35. package/dist/models/object.js +84 -0
  36. package/dist/models/text.d.ts +51 -0
  37. package/dist/models/text.d.ts.map +1 -0
  38. package/dist/models/text.js +257 -0
  39. package/dist/node/index.node.d.ts +2 -0
  40. package/dist/node/index.node.js +415 -175
  41. package/dist/node/index.node.js.map +11 -11
  42. package/dist/types/index.d.ts +47 -0
  43. package/dist/types/index.d.ts.map +1 -0
  44. package/dist/types/index.js +1 -0
  45. package/dist/utils/config.d.ts +25 -0
  46. package/dist/utils/config.d.ts.map +1 -0
  47. package/dist/utils/config.js +115 -0
  48. package/dist/utils/events.d.ts +12 -0
  49. package/dist/utils/events.d.ts.map +1 -0
  50. package/dist/utils/events.js +14 -0
  51. package/dist/utils/index.d.ts +4 -0
  52. package/dist/utils/index.d.ts.map +1 -0
  53. package/dist/utils/index.js +3 -0
  54. package/dist/utils/tokenization.d.ts +2 -0
  55. package/dist/utils/tokenization.d.ts.map +1 -0
  56. package/dist/utils/tokenization.js +3 -0
  57. package/dist/vitest.config.d.ts +3 -0
  58. package/dist/vitest.config.d.ts.map +1 -0
  59. package/dist/vitest.config.js +8 -0
  60. package/package.json +33 -16
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # @elizaos/plugin-google-genai
2
+
3
+ Google Generative AI (Gemini) plugin for elizaOS with native support for TypeScript, Python, and Rust.
4
+
5
+ ## Features
6
+
7
+ - **Text Generation**: Generate text using Gemini 2.0 Flash and 2.5 Pro models
8
+ - **Embeddings**: Generate text embeddings with text-embedding-004
9
+ - **Image Analysis**: Analyze and describe images with multimodal capabilities
10
+ - **JSON Object Generation**: Generate structured JSON with schema validation
11
+
12
+ ## Available Models
13
+
14
+ | Model Type | Default Model | Description |
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 |
20
+
21
+ ## Installation
22
+
23
+ ### TypeScript/JavaScript (npm)
24
+
25
+ ```bash
26
+ npm install @elizaos/plugin-google-genai
27
+ # or
28
+ bun add @elizaos/plugin-google-genai
29
+ ```
30
+ ## Configuration
31
+
32
+ Set the following environment variables:
33
+
34
+ | Variable | Required | Description |
35
+ | ------------------------------ | -------- | ---------------------------------------------------------------------------- |
36
+ | `GOOGLE_GENERATIVE_AI_API_KEY` | Yes | Your Google AI API key from [Google AI Studio](https://aistudio.google.com/) |
37
+ | `GOOGLE_SMALL_MODEL` | No | Override small model (default: gemini-2.0-flash-001) |
38
+ | `GOOGLE_LARGE_MODEL` | No | Override large model (default: gemini-2.5-pro-preview-03-25) |
39
+ | `GOOGLE_EMBEDDING_MODEL` | No | Override embedding model (default: text-embedding-004) |
40
+ | `GOOGLE_IMAGE_MODEL` | No | Override image analysis model |
41
+ | `GOOGLE_TIMEOUT_SECONDS` | No | Request timeout (default: 60) |
42
+
43
+ ## Usage
44
+
45
+ ### TypeScript (elizaOS Plugin)
46
+
47
+ ```typescript
48
+ import { googleGenAIPlugin } from "@elizaos/plugin-google-genai";
49
+
50
+ // Register the plugin with your elizaOS agent
51
+ const agent = new Agent({
52
+ plugins: [googleGenAIPlugin],
53
+ });
54
+
55
+ // Use via runtime
56
+ const text = await runtime.useModel(ModelType.TEXT_LARGE, {
57
+ prompt: "Explain quantum mechanics in simple terms.",
58
+ });
59
+
60
+ const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
61
+ text: "Hello, world!",
62
+ });
63
+
64
+ // Structured output: route through TEXT_* with `responseSchema`. Google's
65
+ // SDK accepts the schema via `responseJsonSchema` + `responseMimeType` set
66
+ // internally by the handler.
67
+ const structured = await runtime.useModel(ModelType.TEXT_SMALL, {
68
+ prompt: "Generate a person profile with name and age.",
69
+ responseSchema: {
70
+ type: "object",
71
+ properties: {
72
+ name: { type: "string" },
73
+ age: { type: "number" },
74
+ },
75
+ required: ["name", "age"],
76
+ },
77
+ });
78
+ ```
79
+ ## Project Structure
80
+
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
+
92
+ ## Development
93
+
94
+ ### TypeScript
95
+
96
+ ```bash
97
+ # Install dependencies
98
+ bun install
99
+
100
+ # Build
101
+ bun run build
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
116
+ ```
117
+
118
+ ## License
119
+
120
+ MIT
121
+
122
+ ## Contributing
123
+
124
+ See the main [elizaOS contribution guidelines](https://github.com/elizaos/eliza/blob/main/CONTRIBUTING.md).
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
+ }