gemini-branch 1.0.0 → 1.0.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.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # GeminiBranch
2
+ [![npm version](https://img.shields.io/npm/v/gemini-branch.svg)](https://www.npmjs.com/package/gemini-branch)
3
+ [![license](https://img.shields.io/npm/l/gemini-branch.svg)](LICENSE)
4
+
5
+ This library performs conditional branching using natural language, powered by Google's Gemini API.
6
+ Think of it as a natural language `if/else` or `switch` statement.
7
+
8
+ ## Features
9
+ - **Natural Language branching**: Branch complex, nuanced, or subjective conditions that are difficult to express with traditional code.
10
+ - **Dynamic Branching**: Select the most appropriate option from a set of choices based on a natural language prompt.
11
+ - **Simple & Typed API**: Easy-to-use, typed interface for seamless integration into TypeScript projects.
12
+ - **Error Handling**: Built-in error handling for API failures and unexpected responses.
13
+
14
+ ## Installation
15
+ ```shell
16
+ npm install gemini-branch
17
+ ```
18
+
19
+ ## Usage
20
+ First, obtain a Google Gemini API key. You can get one from the [Google AI Studio](https://aistudio.google.com/app/apikey).
21
+
22
+ =========ここにサンプル後で書く=========
23
+ ```
24
+
25
+ ```
26
+
27
+ ## Model Selection
28
+ You need to select a model from the [Gemini](https://ai.google.dev/gemini-api/docs/models) or [Gemma 3](https://ai.google.dev/gemma/docs/core) model list.
29
+
30
+
31
+ ## API Reference
32
+ GeminiBranch is the main function that performs the conditional branching.
33
+
34
+ ### GeminiBranchOptions
35
+ | Parameter | Type | Description | Required |
36
+ |-----------|------|-------------|----------|
37
+ | condition | string | The natural language condition used for branching. | Yes |
38
+ | choices | string[] | A list of candidate values. Gemini selects the single best-matching option. | Yes |
39
+ | apiKey | string | Your Google Gemini API Key. | Yes |
40
+ | model | string | The model to use for branching. | Yes |
41
+ | else | string | A fallback value returned when no choice sufficiently matches the condition. | No |
42
+ | consoleErrors | boolean | Log internal errors to the console. Default is false. | No |
43
+
44
+ ### GeminiBranchResult
45
+ | Parameter | Type | Description |
46
+ |-----------|------|-------------|
47
+ | response | boolean | **true** : The library executed correctly (including when the fallback `else` value is returned). <br> **false** : An internal error occurred (API failure, schema violation, etc.). |
48
+ | result | string | On success, a Gemini-selected value from `choices` or the fallback (`else`) value; on failure, `""` or the `else` value if provided. |
49
+ | message | string | Error message on failure, `"Success"` on success, "No matching choice" when `else` is selected |
50
+
51
+ ⚠️ If `else` is not provided, the model is instructed to output `""` when no choice matches.
52
+
53
+ ## License
54
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,19 @@
1
+ export interface GeminiBranchOptions {
2
+ condition: string;
3
+ choices: string[];
4
+ apiKey: string;
5
+ model: string;
6
+ else?: string;
7
+ consoleErrors?: boolean;
8
+ }
9
+ export interface GeminiBranchResult {
10
+ response: boolean;
11
+ /**
12
+ * true : No internal library errors (branching behaved as designed by the user)
13
+ * false : Library failure such as schema errors or API errors
14
+ */
15
+ result: string;
16
+ message: string;
17
+ }
18
+ export declare function GeminiBranch(args: GeminiBranchOptions): Promise<GeminiBranchResult>;
19
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemini-branch",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Perform conditional branching using Gemini in natural language.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {