@gullabs/google 0.6.0 → 0.7.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.
- package/README.md +2 -1
- package/dist/index.cjs +20 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -28,12 +28,13 @@ import { createClient, geminiPricingSource } from '@gullabs/core'
|
|
|
28
28
|
|
|
29
29
|
const client = createClient({
|
|
30
30
|
adapters: [geminiAdapter()],
|
|
31
|
-
|
|
31
|
+
pricingSources: { google: geminiPricingSource() },
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
// Auth is required per call — the library never reads environment variables.
|
|
35
35
|
const result = await client.generate(
|
|
36
36
|
{
|
|
37
|
+
provider: 'google',
|
|
37
38
|
model: 'gemini-2.5-flash',
|
|
38
39
|
messages: [{ role: 'user', parts: [{ kind: 'text', text: 'Hello' }] }],
|
|
39
40
|
},
|
package/dist/index.cjs
CHANGED
|
@@ -3,14 +3,22 @@
|
|
|
3
3
|
var core = require('@gullabs/core');
|
|
4
4
|
|
|
5
5
|
// src/adapter.ts
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
function requireApiKey(auth) {
|
|
7
|
+
if (!("apiKey" in auth) || typeof auth.apiKey !== "string" || auth.apiKey.trim() === "") {
|
|
8
|
+
throw new core.LlmError("@gullabs/google requires auth.apiKey", {
|
|
9
|
+
kind: "invalid_auth",
|
|
10
|
+
retryable: false,
|
|
11
|
+
provider: "google"
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return auth.apiKey;
|
|
15
|
+
}
|
|
8
16
|
var FLEX_DEFAULT_TIMEOUT_MS = 15e5;
|
|
9
17
|
var STANDARD_DEFAULT_TIMEOUT_MS = 3e5;
|
|
10
18
|
var TRANSPORT_TIMEOUT_BUFFER_MS = 5e3;
|
|
11
19
|
async function buildGoogleClient(auth) {
|
|
12
20
|
const { GoogleGenAI } = await import('@google/genai');
|
|
13
|
-
const ai = new GoogleGenAI({ apiKey: auth
|
|
21
|
+
const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
|
|
14
22
|
return {
|
|
15
23
|
models: {
|
|
16
24
|
async generateContent(params) {
|
|
@@ -343,6 +351,12 @@ function geminiAdapter(opts) {
|
|
|
343
351
|
return {
|
|
344
352
|
id: "google",
|
|
345
353
|
async run(req, ctx) {
|
|
354
|
+
if (req.provider !== "google") {
|
|
355
|
+
throw new core.LlmError(
|
|
356
|
+
`geminiAdapter received a request for provider "${req.provider}", expected "google".`,
|
|
357
|
+
{ kind: "bad_request", retryable: false }
|
|
358
|
+
);
|
|
359
|
+
}
|
|
346
360
|
const warnings = [];
|
|
347
361
|
const model = req.model;
|
|
348
362
|
const mapPart = (p) => {
|
|
@@ -671,7 +685,7 @@ var DEFAULT_TIMEOUT_MS = 3e5;
|
|
|
671
685
|
var realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
672
686
|
async function buildFilesClient(auth) {
|
|
673
687
|
const { GoogleGenAI } = await import('@google/genai');
|
|
674
|
-
const ai = new GoogleGenAI({ apiKey: auth
|
|
688
|
+
const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
|
|
675
689
|
return {
|
|
676
690
|
async upload(params) {
|
|
677
691
|
const fileArg = params.file instanceof Uint8Array ? new Blob(
|
|
@@ -858,7 +872,7 @@ var DEFAULT_SKEW_SECONDS = 30;
|
|
|
858
872
|
var DEFAULT_EXTENSION_SECONDS = 3600;
|
|
859
873
|
async function buildCachesClient(auth) {
|
|
860
874
|
const { GoogleGenAI } = await import('@google/genai');
|
|
861
|
-
const ai = new GoogleGenAI({ apiKey: auth
|
|
875
|
+
const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
|
|
862
876
|
return {
|
|
863
877
|
async create(params) {
|
|
864
878
|
const result = await ai.caches.create(params);
|
|
@@ -1113,5 +1127,6 @@ exports.buildGoogleClient = buildGoogleClient;
|
|
|
1113
1127
|
exports.geminiAdapter = geminiAdapter;
|
|
1114
1128
|
exports.isGeminiCapacityError = isGeminiCapacityError;
|
|
1115
1129
|
exports.normalizeGroundingCitations = normalizeGroundingCitations;
|
|
1130
|
+
exports.requireApiKey = requireApiKey;
|
|
1116
1131
|
//# sourceMappingURL=index.cjs.map
|
|
1117
1132
|
//# sourceMappingURL=index.cjs.map
|