@quatrain/ai-gemini 1.1.2 → 1.1.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeminiAdapter.d.ts","sourceRoot":"","sources":["../src/GeminiAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"GeminiAdapter.d.ts","sourceRoot":"","sources":["../src/GeminiAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAK3C,qBAAa,aAAc,SAAQ,iBAAiB;IACjD,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAO;IACxC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAA;gBAEb,MAAM,EAAE,MAAM;IAQ1B,IAAI,IAAI,IAAI;IAWN,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB5D,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAmBpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeminiAdapter.js","sourceRoot":"","sources":["../src/GeminiAdapter.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAChD,yCAA2C;
|
|
1
|
+
{"version":3,"file":"GeminiAdapter.js","sourceRoot":"","sources":["../src/GeminiAdapter.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAChD,yCAA2C;AAK3C,MAAa,aAAc,SAAQ,sBAAiB;IACvC,GAAG,G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C,CAAC;CACH;AA/DD,sCA+DC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/ai-gemini",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"description": "AI adapter for Google Gemini",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@google/genai": "latest",
|
|
24
|
-
"@quatrain/ai": "^1.1.
|
|
24
|
+
"@quatrain/ai": "^1.1.3",
|
|
25
25
|
"@quatrain/core": "^1.2.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
package/src/GeminiAdapter.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { AbstractAiAdapter } from '@quatrain/ai'
|
|
2
2
|
import { GoogleGenAI } from '@google/genai'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* AI Adapter implementation for Google's Gemini models using the official genai SDK.
|
|
6
|
+
*/
|
|
4
7
|
export class GeminiAdapter extends AbstractAiAdapter {
|
|
5
8
|
protected _ai: GoogleGenAI | null = null
|
|
6
9
|
protected _apiKey: string
|
|
@@ -10,10 +13,20 @@ export class GeminiAdapter extends AbstractAiAdapter {
|
|
|
10
13
|
this._apiKey = apiKey
|
|
11
14
|
}
|
|
12
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the internal GoogleGenAI client with the provided API key.
|
|
18
|
+
*/
|
|
13
19
|
init(): void {
|
|
14
20
|
this._ai = new GoogleGenAI({ apiKey: this._apiKey })
|
|
15
21
|
}
|
|
16
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Sends a textual prompt to the Gemini API and retrieves the generated text response.
|
|
25
|
+
*
|
|
26
|
+
* @param prompt - The instruction or query to send to the model.
|
|
27
|
+
* @param options - Configuration options. Can include a `model` string identifier.
|
|
28
|
+
* @returns The generated response string.
|
|
29
|
+
*/
|
|
17
30
|
async generateText(prompt: string, options?: any): Promise<string> {
|
|
18
31
|
if (!this._ai) this.init()
|
|
19
32
|
|
|
@@ -26,6 +39,15 @@ export class GeminiAdapter extends AbstractAiAdapter {
|
|
|
26
39
|
return response.text || ''
|
|
27
40
|
}
|
|
28
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Instructs the Gemini model to output structured JSON data conforming to a given schema.
|
|
44
|
+
*
|
|
45
|
+
* @param prompt - The instruction or context.
|
|
46
|
+
* @param schema - The expected JSON schema structure.
|
|
47
|
+
* @param options - Additional options including the `model` identifier.
|
|
48
|
+
* @returns The parsed JSON object returned by the model.
|
|
49
|
+
* @throws {Error} If the API does not return valid text.
|
|
50
|
+
*/
|
|
29
51
|
async generateStructured(prompt: string, schema: any, options?: any): Promise<any> {
|
|
30
52
|
if (!this._ai) this.init()
|
|
31
53
|
|