@adminforth/completion-adapter-google-gemini 2.0.1 → 2.0.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.
- package/dist/index.js +3 -3
- package/index.ts +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import pRetry from 'p-retry';
|
|
|
12
12
|
import { logger } from "adminforth";
|
|
13
13
|
export default class CompletionAdapterGoogleGemini {
|
|
14
14
|
constructor(options) {
|
|
15
|
-
this.complete = (content_1, ...args_1) => __awaiter(this, [content_1, ...args_1], void 0, function* (content, stop = ["."], maxTokens = 50) {
|
|
15
|
+
this.complete = (content_1, ...args_1) => __awaiter(this, [content_1, ...args_1], void 0, function* (content, stop = ["."], maxTokens = 50, outputSchema) {
|
|
16
16
|
const ai = new GoogleGenAI({
|
|
17
17
|
apiKey: this.options.geminiApiKey,
|
|
18
18
|
});
|
|
@@ -22,7 +22,7 @@ export default class CompletionAdapterGoogleGemini {
|
|
|
22
22
|
const response = yield ai.models.generateContent({
|
|
23
23
|
model: this.options.model || "gemini-3-flash-preview",
|
|
24
24
|
contents: content,
|
|
25
|
-
config: Object.assign({ maxOutputTokens: maxTokens }, this.options.extraRequestBodyParameters),
|
|
25
|
+
config: Object.assign({ responseJsonSchema: outputSchema ? outputSchema : undefined, maxOutputTokens: maxTokens }, this.options.extraRequestBodyParameters),
|
|
26
26
|
});
|
|
27
27
|
logger.debug(`Google Gemini SUCCESSFUL API response: ${response}`);
|
|
28
28
|
return {
|
|
@@ -31,7 +31,7 @@ export default class CompletionAdapterGoogleGemini {
|
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
33
|
logger.error(`Error during Google Gemini API call: ${error}`);
|
|
34
|
-
throw new Error(`Error during Google Gemini API call: ${error}`);
|
|
34
|
+
throw new Error(`Error during Google Gemini API call: ${JSON.parse(error.message).error.message}`);
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const result = yield pRetry(tryToGenerate, {
|
package/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ export default class CompletionAdapterGoogleGemini
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
complete = async (content: string, stop = ["."], maxTokens = 50): Promise<{
|
|
22
|
+
complete = async (content: string, stop = ["."], maxTokens = 50, outputSchema?: any): Promise<{
|
|
23
23
|
content?: string;
|
|
24
24
|
finishReason?: string;
|
|
25
25
|
error?: string;
|
|
@@ -36,6 +36,7 @@ export default class CompletionAdapterGoogleGemini
|
|
|
36
36
|
model: this.options.model || "gemini-3-flash-preview",
|
|
37
37
|
contents: content,
|
|
38
38
|
config: {
|
|
39
|
+
responseJsonSchema: outputSchema ? outputSchema : undefined,
|
|
39
40
|
maxOutputTokens: maxTokens,
|
|
40
41
|
...this.options.extraRequestBodyParameters,
|
|
41
42
|
},
|
|
@@ -46,7 +47,7 @@ export default class CompletionAdapterGoogleGemini
|
|
|
46
47
|
};
|
|
47
48
|
} catch (error) {
|
|
48
49
|
logger.error(`Error during Google Gemini API call: ${error}`);
|
|
49
|
-
throw new Error(`Error during Google Gemini API call: ${error}`);
|
|
50
|
+
throw new Error(`Error during Google Gemini API call: ${JSON.parse(error.message).error.message}`);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
const result = await pRetry(tryToGenerate, {
|