koishi-plugin-chatluna-google-gemini-adapter 1.0.0-beta.15 → 1.0.0-beta.17
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/lib/index.cjs +7 -7
- package/lib/index.d.ts +3 -2
- package/lib/index.mjs +7 -7
- package/package.json +5 -5
package/lib/index.cjs
CHANGED
|
@@ -42,7 +42,6 @@ var import_outputs = require("@langchain/core/outputs");
|
|
|
42
42
|
var import_json = require("@streamparser/json");
|
|
43
43
|
var import_api = require("koishi-plugin-chatluna/llm-core/platform/api");
|
|
44
44
|
var import_error = require("koishi-plugin-chatluna/utils/error");
|
|
45
|
-
var import_request = require("koishi-plugin-chatluna/utils/request");
|
|
46
45
|
var import_sse = require("koishi-plugin-chatluna/utils/sse");
|
|
47
46
|
var import_stream = require("koishi-plugin-chatluna/utils/stream");
|
|
48
47
|
|
|
@@ -247,9 +246,10 @@ __name(messageTypeToGeminiRole, "messageTypeToGeminiRole");
|
|
|
247
246
|
|
|
248
247
|
// src/requester.ts
|
|
249
248
|
var GeminiRequester = class extends import_api.ModelRequester {
|
|
250
|
-
constructor(_config) {
|
|
249
|
+
constructor(_config, _plugin) {
|
|
251
250
|
super();
|
|
252
251
|
this._config = _config;
|
|
252
|
+
this._plugin = _plugin;
|
|
253
253
|
}
|
|
254
254
|
static {
|
|
255
255
|
__name(this, "GeminiRequester");
|
|
@@ -468,7 +468,7 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
const body = JSON.stringify(data);
|
|
471
|
-
return
|
|
471
|
+
return this._plugin.fetch(requestUrl, {
|
|
472
472
|
body,
|
|
473
473
|
headers: this._buildHeaders(),
|
|
474
474
|
method: "POST",
|
|
@@ -477,7 +477,7 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
477
477
|
}
|
|
478
478
|
_get(url) {
|
|
479
479
|
const requestUrl = this._concatUrl(url);
|
|
480
|
-
return
|
|
480
|
+
return this._plugin.fetch(requestUrl, {
|
|
481
481
|
method: "GET",
|
|
482
482
|
headers: this._buildHeaders()
|
|
483
483
|
});
|
|
@@ -503,10 +503,10 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
503
503
|
|
|
504
504
|
// src/client.ts
|
|
505
505
|
var GeminiClient = class extends import_client.PlatformModelAndEmbeddingsClient {
|
|
506
|
-
constructor(ctx, _config, clientConfig) {
|
|
506
|
+
constructor(ctx, _config, clientConfig, plugin) {
|
|
507
507
|
super(ctx, clientConfig);
|
|
508
508
|
this._config = _config;
|
|
509
|
-
this._requester = new GeminiRequester(clientConfig);
|
|
509
|
+
this._requester = new GeminiRequester(clientConfig, plugin);
|
|
510
510
|
}
|
|
511
511
|
static {
|
|
512
512
|
__name(this, "GeminiClient");
|
|
@@ -596,7 +596,7 @@ function apply(ctx, config) {
|
|
|
596
596
|
});
|
|
597
597
|
});
|
|
598
598
|
await plugin.registerClient(
|
|
599
|
-
(_, clientConfig) => new GeminiClient(ctx, config, clientConfig)
|
|
599
|
+
(_, clientConfig) => new GeminiClient(ctx, config, clientConfig, plugin)
|
|
600
600
|
);
|
|
601
601
|
await plugin.initClients();
|
|
602
602
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -86,7 +86,8 @@ export function messageTypeToGeminiRole(type: MessageType): ChatCompletionRespon
|
|
|
86
86
|
export function convertDeltaToMessageChunk(delta: Record<string, any>, defaultRole?: ChatCompletionResponseMessageRoleEnum): HumanMessageChunk | AIMessageChunk | SystemMessageChunk | ChatMessageChunk;
|
|
87
87
|
export class GeminiRequester extends ModelRequester implements EmbeddingsRequester {
|
|
88
88
|
private _config;
|
|
89
|
-
|
|
89
|
+
private _plugin;
|
|
90
|
+
constructor(_config: ClientConfig, _plugin: ChatLunaPlugin);
|
|
90
91
|
completionStream(params: ModelRequestParams): AsyncGenerator<ChatGenerationChunk>;
|
|
91
92
|
embeddings(params: EmbeddingsRequestParams): Promise<number[] | number[][]>;
|
|
92
93
|
getModels(): Promise<string[]>;
|
|
@@ -102,7 +103,7 @@ export class GeminiClient extends PlatformModelAndEmbeddingsClient {
|
|
|
102
103
|
platform: string;
|
|
103
104
|
private _requester;
|
|
104
105
|
private _models;
|
|
105
|
-
constructor(ctx: Context, _config: Config, clientConfig: ClientConfig);
|
|
106
|
+
constructor(ctx: Context, _config: Config, clientConfig: ClientConfig, plugin: ChatLunaPlugin);
|
|
106
107
|
init(): Promise<void>;
|
|
107
108
|
refreshModels(): Promise<ModelInfo[]>;
|
|
108
109
|
getModels(): Promise<ModelInfo[]>;
|
package/lib/index.mjs
CHANGED
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
ChatLunaError,
|
|
31
31
|
ChatLunaErrorCode
|
|
32
32
|
} from "koishi-plugin-chatluna/utils/error";
|
|
33
|
-
import { chatLunaFetch } from "koishi-plugin-chatluna/utils/request";
|
|
34
33
|
import { sse } from "koishi-plugin-chatluna/utils/sse";
|
|
35
34
|
import { readableStreamToAsyncIterable } from "koishi-plugin-chatluna/utils/stream";
|
|
36
35
|
|
|
@@ -240,9 +239,10 @@ __name(messageTypeToGeminiRole, "messageTypeToGeminiRole");
|
|
|
240
239
|
|
|
241
240
|
// src/requester.ts
|
|
242
241
|
var GeminiRequester = class extends ModelRequester {
|
|
243
|
-
constructor(_config) {
|
|
242
|
+
constructor(_config, _plugin) {
|
|
244
243
|
super();
|
|
245
244
|
this._config = _config;
|
|
245
|
+
this._plugin = _plugin;
|
|
246
246
|
}
|
|
247
247
|
static {
|
|
248
248
|
__name(this, "GeminiRequester");
|
|
@@ -461,7 +461,7 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
const body = JSON.stringify(data);
|
|
464
|
-
return
|
|
464
|
+
return this._plugin.fetch(requestUrl, {
|
|
465
465
|
body,
|
|
466
466
|
headers: this._buildHeaders(),
|
|
467
467
|
method: "POST",
|
|
@@ -470,7 +470,7 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
470
470
|
}
|
|
471
471
|
_get(url) {
|
|
472
472
|
const requestUrl = this._concatUrl(url);
|
|
473
|
-
return
|
|
473
|
+
return this._plugin.fetch(requestUrl, {
|
|
474
474
|
method: "GET",
|
|
475
475
|
headers: this._buildHeaders()
|
|
476
476
|
});
|
|
@@ -496,10 +496,10 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
496
496
|
|
|
497
497
|
// src/client.ts
|
|
498
498
|
var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
|
|
499
|
-
constructor(ctx, _config, clientConfig) {
|
|
499
|
+
constructor(ctx, _config, clientConfig, plugin) {
|
|
500
500
|
super(ctx, clientConfig);
|
|
501
501
|
this._config = _config;
|
|
502
|
-
this._requester = new GeminiRequester(clientConfig);
|
|
502
|
+
this._requester = new GeminiRequester(clientConfig, plugin);
|
|
503
503
|
}
|
|
504
504
|
static {
|
|
505
505
|
__name(this, "GeminiClient");
|
|
@@ -589,7 +589,7 @@ function apply(ctx, config) {
|
|
|
589
589
|
});
|
|
590
590
|
});
|
|
591
591
|
await plugin.registerClient(
|
|
592
|
-
(_, clientConfig) => new GeminiClient(ctx, config, clientConfig)
|
|
592
|
+
(_, clientConfig) => new GeminiClient(ctx, config, clientConfig, plugin)
|
|
593
593
|
);
|
|
594
594
|
await plugin.initClients();
|
|
595
595
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-google-gemini-adapter",
|
|
3
3
|
"description": "google-gemini adapter for chatluna",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.17",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -48,18 +48,18 @@
|
|
|
48
48
|
"adapter"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@langchain/core": "^0.2.
|
|
51
|
+
"@langchain/core": "^0.2.17",
|
|
52
52
|
"@streamparser/json": "^0.0.21",
|
|
53
|
-
"zod": "^3.24.0-canary.
|
|
53
|
+
"zod": "^3.24.0-canary.20240701T200529",
|
|
54
54
|
"zod-to-json-schema": "^3.23.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"atsc": "^2.1.0",
|
|
58
|
-
"koishi": "^4.17.
|
|
58
|
+
"koishi": "^4.17.10"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"koishi": "^4.17.9",
|
|
62
|
-
"koishi-plugin-chatluna": "^1.0.0-beta.
|
|
62
|
+
"koishi-plugin-chatluna": "^1.0.0-beta.58"
|
|
63
63
|
},
|
|
64
64
|
"koishi": {
|
|
65
65
|
"description": {
|