@aigne/example-nano-banana 1.0.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.
@@ -0,0 +1,44 @@
1
+ # Change the name of this file to .env.local and fill in the following values
2
+
3
+ # Uncomment the lines below to enable debug logging
4
+ # DEBUG="aigne:*"
5
+
6
+ # Use different Models
7
+
8
+ # OpenAI
9
+ # MODEL="openai:gpt-4.1"
10
+ # OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
11
+
12
+ # Anthropic claude
13
+ # MODEL="anthropic:claude-3-7-sonnet-latest"
14
+ # ANTHROPIC_API_KEY=""
15
+
16
+ # Gemini
17
+ MODEL="gemini:gemini-2.5-flash-image-preview"
18
+ GEMINI_API_KEY=""
19
+
20
+ # Bedrock nova
21
+ # MODEL=bedrock:us.amazon.nova-premier-v1:0
22
+ # AWS_ACCESS_KEY_ID=""
23
+ # AWS_SECRET_ACCESS_KEY=""
24
+ # AWS_REGION=us-west-2
25
+
26
+ # DeepSeek
27
+ # MODEL="deepseek:deepseek-chat"
28
+ # DEEPSEEK_API_KEY=""
29
+
30
+ # OpenRouter
31
+ # MODEL="openrouter:openai/gpt-4o"
32
+ # OPEN_ROUTER_API_KEY=""
33
+
34
+ # xAI
35
+ # MODEL="xai:grok-2-latest"
36
+ # XAI_API_KEY=""
37
+
38
+ # Ollama
39
+ # MODEL="ollama:llama3.2"
40
+ # OLLAMA_DEFAULT_BASE_URL="http://localhost:11434/v1";
41
+
42
+
43
+ # Setup proxy if needed
44
+ # HTTPS_PROXY=http://localhost:7890
package/LICENSE.md ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that
84
+ organization. **control** means ownership of substantially all the assets of an
85
+ entity, or the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Image Example
2
+
3
+ <p align="center">
4
+ <picture>
5
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo-dark.svg" media="(prefers-color-scheme: dark)">
6
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" media="(prefers-color-scheme: light)">
7
+ <img src="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" alt="AIGNE Logo" width="400" />
8
+ </picture>
9
+ </p>
10
+
11
+ This example demonstrates how to create a chatbot with image capabilities using the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [AIGNE CLI](https://github.com/AIGNE-io/aigne-framework/blob/main/packages/cli/README.md).
12
+
13
+ ## Prerequisites
14
+
15
+ * [Node.js](https://nodejs.org) (>=20.0) and npm installed on your machine
16
+ * An [OpenAI API key](https://platform.openai.com/api-keys) for interacting with OpenAI's services
17
+ * Optional dependencies (if running the example from source code):
18
+ * [Pnpm](https://pnpm.io) for package management
19
+ * [Bun](https://bun.sh) for running unit tests & examples
20
+
21
+ ## Quick Start (No Installation Required)
22
+
23
+ ```bash
24
+ export GEMINI_API_KEY=YOUR_GEMINI_API_KEY # Set your Gemini API key
25
+
26
+ npx -y @aigne/example-nano-banana --input 'Draw an image of a lovely cat'
27
+
28
+ # Run in interactive chat mode
29
+ npx -y @aigne/example-nano-banana --chat
30
+ ```
31
+
32
+ ## Installation
33
+
34
+ ### Clone the Repository
35
+
36
+ ```bash
37
+ git clone https://github.com/AIGNE-io/aigne-framework
38
+ ```
39
+
40
+ ### Install Dependencies
41
+
42
+ ```bash
43
+ cd aigne-framework/examples/nano-banana
44
+
45
+ pnpm install
46
+ ```
47
+
48
+ ### Setup Environment Variables
49
+
50
+ Setup your Gemini API key in the `.env.local` file:
51
+
52
+ ```bash
53
+ GEMINI_API_KEY="" # Set your Gemini API key here
54
+ ```
55
+
56
+ #### Using Different Models
57
+
58
+ You can use different AI models by setting the `MODEL` environment variable along with the corresponding API key. The framework supports multiple providers:
59
+
60
+ * **OpenAI**: `MODEL="openai:gpt-4.1"` with `OPENAI_API_KEY`
61
+ * **Anthropic**: `MODEL="anthropic:claude-3-7-sonnet-latest"` with `ANTHROPIC_API_KEY`
62
+ * **Google Gemini**: `MODEL="gemini:gemini-2.0-flash"` with `GEMINI_API_KEY`
63
+ * **AWS Bedrock**: `MODEL="bedrock:us.amazon.nova-premier-v1:0"` with AWS credentials
64
+ * **DeepSeek**: `MODEL="deepseek:deepseek-chat"` with `DEEPSEEK_API_KEY`
65
+ * **OpenRouter**: `MODEL="openrouter:openai/gpt-4o"` with `OPEN_ROUTER_API_KEY`
66
+ * **xAI**: `MODEL="xai:grok-2-latest"` with `XAI_API_KEY`
67
+ * **Ollama**: `MODEL="ollama:llama3.2"` with `OLLAMA_DEFAULT_BASE_URL`
68
+
69
+ For detailed configuration examples, please refer to the `.env.local.example` file in this directory.
70
+
71
+ ### Run the Example
72
+
73
+ ```bash
74
+ pnpm start
75
+ ```
package/index.ts ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env npx -y bun
2
+
3
+ import { join } from "node:path";
4
+ import { runWithAIGNE } from "@aigne/cli/utils/run-with-aigne.js";
5
+ import { AIAgent } from "@aigne/core";
6
+ import { DefaultMemory } from "@aigne/default-memory";
7
+
8
+ const agent = AIAgent.from({
9
+ name: "nano_banana",
10
+ instructions: "You are a drawer who creates images based on user descriptions.",
11
+ memory: [
12
+ new DefaultMemory({
13
+ storage: { url: `file:${join(import.meta.dirname, "memory.db")}` },
14
+ }),
15
+ ],
16
+ inputKey: "message",
17
+ fileInputKey: "files",
18
+ });
19
+
20
+ await runWithAIGNE(agent, {
21
+ modelOptions: {
22
+ model: "aignehub:gemini/gemini-2.5-flash-image-preview",
23
+ modalities: ["text", "image"],
24
+ },
25
+ chatLoopOptions: {
26
+ welcome: "You can ask me to draw anything! or edit image by @/path/to/image",
27
+ },
28
+ });
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@aigne/example-nano-banana",
3
+ "version": "1.0.0",
4
+ "description": "A demonstration of using AIGNE Framework for image generating or editing.",
5
+ "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
6
+ "homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/nano-banana",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/AIGNE-io/aigne-framework"
11
+ },
12
+ "bin": "index.ts",
13
+ "files": [
14
+ ".env.local.example",
15
+ "*.ts",
16
+ "README.md"
17
+ ],
18
+ "dependencies": {
19
+ "@aigne/agent-library": "^1.21.37",
20
+ "@aigne/cli": "^1.44.0",
21
+ "@aigne/core": "^1.58.0",
22
+ "@aigne/fs-memory": "^1.0.37",
23
+ "@aigne/default-memory": "^1.2.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/bun": "^1.2.18",
27
+ "@aigne/test-utils": "^0.5.44"
28
+ },
29
+ "scripts": {
30
+ "start": "bun run index.ts",
31
+ "lint": "tsc --noEmit",
32
+ "test:llm": "exit 0"
33
+ }
34
+ }