koishi-plugin-chatluna-google-gemini-adapter 1.0.0-beta.2 → 1.0.0-beta.20

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.mjs ADDED
@@ -0,0 +1,645 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/index.ts
5
+ import { ChatLunaPlugin } from "koishi-plugin-chatluna/services/chat";
6
+ import { Schema } from "koishi";
7
+
8
+ // src/client.ts
9
+ import { PlatformModelAndEmbeddingsClient } from "koishi-plugin-chatluna/llm-core/platform/client";
10
+ import {
11
+ ChatLunaChatModel,
12
+ ChatLunaEmbeddings
13
+ } from "koishi-plugin-chatluna/llm-core/platform/model";
14
+ import {
15
+ ModelType
16
+ } from "koishi-plugin-chatluna/llm-core/platform/types";
17
+ import {
18
+ ChatLunaError as ChatLunaError2,
19
+ ChatLunaErrorCode as ChatLunaErrorCode2
20
+ } from "koishi-plugin-chatluna/utils/error";
21
+
22
+ // src/requester.ts
23
+ import { AIMessageChunk as AIMessageChunk2 } from "@langchain/core/messages";
24
+ import { ChatGenerationChunk } from "@langchain/core/outputs";
25
+ import { JSONParser } from "@streamparser/json";
26
+ import {
27
+ ModelRequester
28
+ } from "koishi-plugin-chatluna/llm-core/platform/api";
29
+ import {
30
+ ChatLunaError,
31
+ ChatLunaErrorCode
32
+ } from "koishi-plugin-chatluna/utils/error";
33
+ import { sse } from "koishi-plugin-chatluna/utils/sse";
34
+ import { readableStreamToAsyncIterable } from "koishi-plugin-chatluna/utils/stream";
35
+
36
+ // src/utils.ts
37
+ import {
38
+ AIMessageChunk,
39
+ ChatMessageChunk,
40
+ HumanMessageChunk,
41
+ SystemMessageChunk
42
+ } from "@langchain/core/messages";
43
+ import { zodToJsonSchema } from "zod-to-json-schema";
44
+ async function langchainMessageToGeminiMessage(messages, model) {
45
+ const mappedMessage = await Promise.all(
46
+ messages.map(async (rawMessage) => {
47
+ const role = messageTypeToGeminiRole(rawMessage._getType());
48
+ if (role === "function" || rawMessage.additional_kwargs?.function_call != null) {
49
+ return {
50
+ role: "function",
51
+ parts: [
52
+ {
53
+ functionResponse: rawMessage.additional_kwargs?.function_call != null ? void 0 : {
54
+ name: rawMessage.name,
55
+ response: {
56
+ name: rawMessage.name,
57
+ content: (() => {
58
+ try {
59
+ const result3 = JSON.parse(
60
+ rawMessage.content
61
+ );
62
+ if (typeof result3 === "string") {
63
+ return {
64
+ response: result3
65
+ };
66
+ } else {
67
+ return result3;
68
+ }
69
+ } catch (e) {
70
+ return {
71
+ response: rawMessage.content
72
+ };
73
+ }
74
+ })()
75
+ }
76
+ },
77
+ functionCall: rawMessage.additional_kwargs?.function_call != null ? {
78
+ name: rawMessage.additional_kwargs.function_call.name,
79
+ args: (() => {
80
+ try {
81
+ const result3 = JSON.parse(
82
+ rawMessage.additional_kwargs.function_call.arguments
83
+ );
84
+ if (typeof result3 === "string") {
85
+ return {
86
+ input: result3
87
+ };
88
+ } else {
89
+ return result3;
90
+ }
91
+ } catch (e) {
92
+ return {
93
+ input: rawMessage.additional_kwargs.function_call.arguments
94
+ };
95
+ }
96
+ })()
97
+ } : void 0
98
+ }
99
+ ]
100
+ };
101
+ }
102
+ const images = rawMessage.additional_kwargs.images;
103
+ const result2 = {
104
+ role,
105
+ parts: [
106
+ {
107
+ text: rawMessage.content
108
+ }
109
+ ]
110
+ };
111
+ if ((model.includes("vision") || model.includes("gemini-1.5")) && images != null) {
112
+ for (const image of images) {
113
+ result2.parts.push({
114
+ inline_data: {
115
+ // base64 image match type
116
+ data: image.replace(/^data:image\/\w+;base64,/, ""),
117
+ mime_type: "image/jpeg"
118
+ }
119
+ });
120
+ }
121
+ }
122
+ return result2;
123
+ })
124
+ );
125
+ const result = [];
126
+ for (let i = 0; i < mappedMessage.length; i++) {
127
+ const message = mappedMessage[i];
128
+ if (message.role !== "system") {
129
+ result.push(message);
130
+ continue;
131
+ }
132
+ result.push({
133
+ role: "user",
134
+ parts: message.parts
135
+ });
136
+ if (mappedMessage?.[i + 1]?.role === "model") {
137
+ continue;
138
+ }
139
+ if (mappedMessage?.[i + 1]?.role === "user") {
140
+ result.push({
141
+ role: "model",
142
+ parts: [{ text: "Okay, what do I need to do?" }]
143
+ });
144
+ }
145
+ }
146
+ if (result[result.length - 1].role === "model") {
147
+ result.push({
148
+ role: "user",
149
+ parts: [
150
+ {
151
+ text: "Continue what I said to you last message. Follow these instructions."
152
+ }
153
+ ]
154
+ });
155
+ }
156
+ if (model.includes("vision")) {
157
+ const textBuffer = [];
158
+ const last = result.pop();
159
+ for (let i = 0; i < result.length; i++) {
160
+ const message = result[i];
161
+ const text = message.parts[0].text;
162
+ textBuffer.push(`${message.role}: ${text}`);
163
+ }
164
+ const lastParts = last.parts;
165
+ let lastImagesParts = lastParts.filter(
166
+ (part) => part.inline_data?.mime_type === "image/jpeg"
167
+ );
168
+ if (lastImagesParts.length < 1) {
169
+ for (let i = result.length - 1; i >= 0; i--) {
170
+ const message = result[i];
171
+ const images = message.parts.filter(
172
+ (part) => part.inline_data?.mime_type === "image/jpeg"
173
+ );
174
+ if (images.length > 0) {
175
+ lastImagesParts = images;
176
+ break;
177
+ }
178
+ }
179
+ }
180
+ ;
181
+ lastParts.filter(
182
+ (part) => part.text !== void 0 && part.text !== null
183
+ ).forEach((part) => {
184
+ textBuffer.push(`${last.role}: ${part.text}`);
185
+ });
186
+ return [
187
+ {
188
+ role: "user",
189
+ parts: [
190
+ {
191
+ text: textBuffer.join("\n")
192
+ },
193
+ ...lastImagesParts
194
+ ]
195
+ }
196
+ ];
197
+ }
198
+ return result;
199
+ }
200
+ __name(langchainMessageToGeminiMessage, "langchainMessageToGeminiMessage");
201
+ function partAsType(part) {
202
+ return part;
203
+ }
204
+ __name(partAsType, "partAsType");
205
+ function formatToolsToGeminiAITools(tools) {
206
+ if (tools.length < 1) {
207
+ return void 0;
208
+ }
209
+ return tools.map(formatToolToGeminiAITool);
210
+ }
211
+ __name(formatToolsToGeminiAITools, "formatToolsToGeminiAITools");
212
+ function formatToolToGeminiAITool(tool) {
213
+ const parameters = zodToJsonSchema(tool.schema);
214
+ delete parameters["$schema"];
215
+ delete parameters["additionalProperties"];
216
+ return {
217
+ name: tool.name,
218
+ description: tool.description,
219
+ // any?
220
+ parameters
221
+ };
222
+ }
223
+ __name(formatToolToGeminiAITool, "formatToolToGeminiAITool");
224
+ function messageTypeToGeminiRole(type) {
225
+ switch (type) {
226
+ case "system":
227
+ return "system";
228
+ case "ai":
229
+ return "model";
230
+ case "human":
231
+ return "user";
232
+ case "function":
233
+ return "function";
234
+ default:
235
+ throw new Error(`Unknown message type: ${type}`);
236
+ }
237
+ }
238
+ __name(messageTypeToGeminiRole, "messageTypeToGeminiRole");
239
+
240
+ // src/requester.ts
241
+ var GeminiRequester = class extends ModelRequester {
242
+ constructor(_config, _plugin) {
243
+ super();
244
+ this._config = _config;
245
+ this._plugin = _plugin;
246
+ }
247
+ static {
248
+ __name(this, "GeminiRequester");
249
+ }
250
+ async *completionStream(params) {
251
+ try {
252
+ const response = await this._post(
253
+ `models/${params.model}:streamGenerateContent`,
254
+ {
255
+ contents: await langchainMessageToGeminiMessage(
256
+ params.input,
257
+ params.model
258
+ ),
259
+ safetySettings: [
260
+ {
261
+ category: "HARM_CATEGORY_HARASSMENT",
262
+ threshold: "BLOCK_NONE"
263
+ },
264
+ {
265
+ category: "HARM_CATEGORY_HATE_SPEECH",
266
+ threshold: "BLOCK_NONE"
267
+ },
268
+ {
269
+ category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
270
+ threshold: "BLOCK_NONE"
271
+ },
272
+ {
273
+ category: "HARM_CATEGORY_DANGEROUS_CONTENT",
274
+ threshold: "BLOCK_NONE"
275
+ }
276
+ ],
277
+ generationConfig: {
278
+ stopSequences: params.stop,
279
+ temperature: params.temperature,
280
+ maxOutputTokens: params.model.includes("vision") ? void 0 : params.maxTokens,
281
+ topP: params.topP
282
+ },
283
+ tools: !params.model.includes("vision") && params.tools != null ? {
284
+ functionDeclarations: formatToolsToGeminiAITools(params.tools)
285
+ } : void 0
286
+ },
287
+ {
288
+ signal: params.signal
289
+ }
290
+ );
291
+ let errorCount = 0;
292
+ const stream = new TransformStream();
293
+ const iterable = readableStreamToAsyncIterable(
294
+ stream.readable
295
+ );
296
+ const jsonParser = new JSONParser();
297
+ const writable = stream.writable.getWriter();
298
+ jsonParser.onEnd = async () => {
299
+ await writable.close();
300
+ };
301
+ jsonParser.onValue = async ({ value }) => {
302
+ const transformValue = value;
303
+ if (transformValue.candidates && transformValue.candidates[0]) {
304
+ const parts = transformValue.candidates[0]?.content?.parts;
305
+ if (parts == null || parts.length < 1) {
306
+ throw new Error(JSON.stringify(value));
307
+ }
308
+ for (const part of parts) {
309
+ await writable.write(part);
310
+ }
311
+ }
312
+ };
313
+ await sse(
314
+ response,
315
+ async (rawData) => {
316
+ jsonParser.write(rawData);
317
+ return true;
318
+ },
319
+ 0
320
+ );
321
+ let content = "";
322
+ let isOldVisionModel = params.model.includes("vision");
323
+ const functionCall = {
324
+ name: "",
325
+ args: "",
326
+ arguments: ""
327
+ };
328
+ for await (const chunk of iterable) {
329
+ const messagePart = partAsType(chunk);
330
+ const chatFunctionCallingPart = partAsType(chunk);
331
+ if (messagePart.text) {
332
+ if (params.tools != null) {
333
+ content = messagePart.text;
334
+ } else {
335
+ content += messagePart.text;
336
+ }
337
+ if (isOldVisionModel && /\s*model:\s*/.test(content)) {
338
+ isOldVisionModel = false;
339
+ content = messagePart.text.replace(/\s*model:\s*/, "");
340
+ }
341
+ }
342
+ const deltaFunctionCall = chatFunctionCallingPart.functionCall;
343
+ if (deltaFunctionCall) {
344
+ let args = deltaFunctionCall.args?.input ?? deltaFunctionCall.args;
345
+ try {
346
+ let parsedArgs = JSON.parse(args);
347
+ if (typeof parsedArgs !== "string") {
348
+ args = parsedArgs;
349
+ }
350
+ parsedArgs = JSON.parse(args);
351
+ if (typeof parsedArgs !== "string") {
352
+ args = parsedArgs;
353
+ }
354
+ } catch (e) {
355
+ }
356
+ functionCall.args = JSON.stringify(args);
357
+ functionCall.name = deltaFunctionCall.name;
358
+ functionCall.arguments = deltaFunctionCall.args;
359
+ }
360
+ try {
361
+ const messageChunk = new AIMessageChunk2(content);
362
+ messageChunk.additional_kwargs = {
363
+ function_call: functionCall.name.length > 0 ? {
364
+ name: functionCall.name,
365
+ arguments: functionCall.args,
366
+ args: functionCall.arguments
367
+ } : void 0
368
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
369
+ };
370
+ messageChunk.content = content;
371
+ const generationChunk = new ChatGenerationChunk({
372
+ message: messageChunk,
373
+ text: messageChunk.content
374
+ });
375
+ yield generationChunk;
376
+ content = messageChunk.content;
377
+ } catch (e) {
378
+ if (errorCount > 5) {
379
+ logger.error("error with chunk", chunk);
380
+ throw new ChatLunaError(
381
+ ChatLunaErrorCode.API_REQUEST_FAILED,
382
+ e
383
+ );
384
+ } else {
385
+ errorCount++;
386
+ continue;
387
+ }
388
+ }
389
+ }
390
+ } catch (e) {
391
+ if (e instanceof ChatLunaError) {
392
+ throw e;
393
+ } else {
394
+ throw new ChatLunaError(ChatLunaErrorCode.API_REQUEST_FAILED, e);
395
+ }
396
+ }
397
+ }
398
+ async embeddings(params) {
399
+ let data;
400
+ if (typeof params.input === "string") {
401
+ params.input = [params.input];
402
+ }
403
+ try {
404
+ const response = await this._post(
405
+ `models/${params.model}:batchEmbedContents`,
406
+ {
407
+ requests: params.input.map((input) => {
408
+ return {
409
+ model: `models/${params.model}`,
410
+ content: {
411
+ parts: [
412
+ {
413
+ text: input
414
+ }
415
+ ]
416
+ }
417
+ };
418
+ })
419
+ }
420
+ );
421
+ data = await response.text();
422
+ data = JSON.parse(data);
423
+ if (data.embeddings && data.embeddings.length > 0) {
424
+ return data.embeddings.map((embedding) => {
425
+ return embedding.values;
426
+ });
427
+ }
428
+ throw new Error(
429
+ "error when calling gemini embeddings, Result: " + JSON.stringify(data)
430
+ );
431
+ } catch (e) {
432
+ const error = new Error(
433
+ "error when calling gemini embeddings, Result: " + JSON.stringify(data)
434
+ );
435
+ error.stack = e.stack;
436
+ error.cause = e.cause;
437
+ logger.debug(e);
438
+ throw new ChatLunaError(ChatLunaErrorCode.API_REQUEST_FAILED, error);
439
+ }
440
+ }
441
+ async getModels() {
442
+ let data;
443
+ try {
444
+ const response = await this._get("models");
445
+ data = await response.text();
446
+ data = JSON.parse(data);
447
+ if (!data.models || !data.models.length) {
448
+ throw new Error(
449
+ "error when listing gemini models, Result:" + JSON.stringify(data)
450
+ );
451
+ }
452
+ return data.models.map((model) => model.name).filter(
453
+ (model) => model.includes("gemini") || model.includes("embedding")
454
+ );
455
+ } catch (e) {
456
+ const error = new Error(
457
+ "error when listing gemini models, Result: " + JSON.stringify(data)
458
+ );
459
+ error.stack = e.stack;
460
+ error.cause = e.cause;
461
+ throw error;
462
+ }
463
+ }
464
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
465
+ _post(url, data, params = {}) {
466
+ const requestUrl = this._concatUrl(url);
467
+ for (const key in data) {
468
+ if (data[key] === void 0) {
469
+ delete data[key];
470
+ }
471
+ }
472
+ const body = JSON.stringify(data);
473
+ return this._plugin.fetch(requestUrl, {
474
+ body,
475
+ headers: this._buildHeaders(),
476
+ method: "POST",
477
+ ...params
478
+ });
479
+ }
480
+ _get(url) {
481
+ const requestUrl = this._concatUrl(url);
482
+ return this._plugin.fetch(requestUrl, {
483
+ method: "GET",
484
+ headers: this._buildHeaders()
485
+ });
486
+ }
487
+ _concatUrl(url) {
488
+ const apiEndPoint = this._config.apiEndpoint;
489
+ if (apiEndPoint.endsWith("/")) {
490
+ return apiEndPoint + url + `?key=${this._config.apiKey}`;
491
+ }
492
+ return apiEndPoint + "/" + url + `?key=${this._config.apiKey}`;
493
+ }
494
+ _buildHeaders() {
495
+ return {
496
+ /* Authorization: `Bearer ${this._config.apiKey}`, */
497
+ "Content-Type": "application/json"
498
+ };
499
+ }
500
+ async init() {
501
+ }
502
+ async dispose() {
503
+ }
504
+ };
505
+
506
+ // src/client.ts
507
+ var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
508
+ constructor(ctx, _config, clientConfig, plugin) {
509
+ super(ctx, clientConfig);
510
+ this._config = _config;
511
+ this._requester = new GeminiRequester(clientConfig, plugin);
512
+ }
513
+ static {
514
+ __name(this, "GeminiClient");
515
+ }
516
+ platform = "gemini";
517
+ _requester;
518
+ _models;
519
+ async init() {
520
+ await this.getModels();
521
+ }
522
+ async refreshModels() {
523
+ try {
524
+ const rawModels = await this._requester.getModels();
525
+ if (!rawModels.length) {
526
+ throw new ChatLunaError2(
527
+ ChatLunaErrorCode2.MODEL_INIT_ERROR,
528
+ new Error("No model found")
529
+ );
530
+ }
531
+ return rawModels.map((model) => model.replace("models/", "")).map((model) => {
532
+ return {
533
+ name: model,
534
+ maxTokens: ((model2) => {
535
+ if (model2.includes("gemini-1.5-pro")) {
536
+ return 1048576;
537
+ }
538
+ if (model2.includes("gemini-1.5-flash")) {
539
+ return 2097152;
540
+ }
541
+ if (model2.includes("gemini-1.0-pro")) {
542
+ return 30720;
543
+ }
544
+ return 30720;
545
+ })(model),
546
+ type: model.includes("embedding") ? ModelType.embeddings : ModelType.llm,
547
+ functionCall: !model.includes("vision"),
548
+ supportMode: ["all"]
549
+ };
550
+ });
551
+ } catch (e) {
552
+ throw new ChatLunaError2(ChatLunaErrorCode2.MODEL_INIT_ERROR, e);
553
+ }
554
+ }
555
+ async getModels() {
556
+ if (this._models) {
557
+ return Object.values(this._models);
558
+ }
559
+ const models = await this.refreshModels();
560
+ this._models = {};
561
+ for (const model of models) {
562
+ this._models[model.name] = model;
563
+ }
564
+ }
565
+ _createModel(model) {
566
+ const info = this._models[model];
567
+ if (info == null) {
568
+ throw new ChatLunaError2(ChatLunaErrorCode2.MODEL_NOT_FOUND);
569
+ }
570
+ if (info.type === ModelType.llm) {
571
+ return new ChatLunaChatModel({
572
+ modelInfo: info,
573
+ requester: this._requester,
574
+ model,
575
+ modelMaxContextSize: info.maxTokens,
576
+ maxTokens: this._config.maxTokens,
577
+ timeout: this._config.timeout,
578
+ temperature: this._config.temperature,
579
+ maxRetries: this._config.maxRetries,
580
+ llmType: "gemini"
581
+ });
582
+ }
583
+ return new ChatLunaEmbeddings({
584
+ client: this._requester,
585
+ model,
586
+ maxRetries: this._config.maxRetries
587
+ });
588
+ }
589
+ };
590
+
591
+ // src/index.ts
592
+ import { createLogger } from "koishi-plugin-chatluna/utils/logger";
593
+ var logger;
594
+ function apply(ctx, config) {
595
+ const plugin = new ChatLunaPlugin(ctx, config, "gemini");
596
+ logger = createLogger(ctx, "chatluna-gemini-adapter");
597
+ ctx.on("ready", async () => {
598
+ await plugin.registerToService();
599
+ await plugin.parseConfig((config2) => {
600
+ return config2.apiKeys.map(([apiKey, apiEndpoint]) => {
601
+ return {
602
+ apiKey,
603
+ apiEndpoint,
604
+ platform: "gemini",
605
+ chatLimit: config2.chatTimeLimit,
606
+ timeout: config2.timeout,
607
+ maxRetries: config2.maxRetries,
608
+ concurrentMaxSize: config2.chatConcurrentMaxSize
609
+ };
610
+ });
611
+ });
612
+ await plugin.registerClient(
613
+ (_, clientConfig) => new GeminiClient(ctx, config, clientConfig, plugin)
614
+ );
615
+ await plugin.initClients();
616
+ });
617
+ }
618
+ __name(apply, "apply");
619
+ var Config = Schema.intersect([
620
+ ChatLunaPlugin.Config,
621
+ Schema.object({
622
+ apiKeys: Schema.array(
623
+ Schema.tuple([
624
+ Schema.string().role("secret").description("Gemini 的 API Key").required(),
625
+ Schema.string().description("请求 Gemini API 的地址").default("https://generativelanguage.googleapis.com/v1beta")
626
+ ])
627
+ ).description("Gemini 的 API Key 和请求地址列表").default([["", "https://generativelanguage.googleapis.com/v1beta"]])
628
+ }).description("请求设置"),
629
+ Schema.object({
630
+ maxTokens: Schema.number().description(
631
+ "回复的最大 Token 数(16~2097000,必须是16的倍数)(注意如果你目前使用的模型的最大 Token 为 8000 及以上的话才建议设置超过 512 token)"
632
+ ).min(16).max(2097e3).step(16).default(8064),
633
+ temperature: Schema.percent().description("回复温度,越高越随机").min(0).max(1).step(0.1).default(0.8)
634
+ }).description("模型设置")
635
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
636
+ ]);
637
+ var inject = ["chatluna"];
638
+ var name = "chatluna-google-gemini-adapter";
639
+ export {
640
+ Config,
641
+ apply,
642
+ inject,
643
+ logger,
644
+ name
645
+ };
package/package.json CHANGED
@@ -1,13 +1,23 @@
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.2",
5
- "main": "lib/index.js",
4
+ "version": "1.0.0-beta.20",
5
+ "main": "lib/index.cjs",
6
+ "module": "lib/index.mjs",
6
7
  "typings": "lib/index.d.ts",
7
8
  "files": [
8
9
  "lib",
9
10
  "dist"
10
11
  ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./lib/index.mjs",
15
+ "require": "./lib/index.cjs",
16
+ "types": "./lib/index.d.ts"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "type": "module",
11
21
  "author": "dingyi222666 <dingyi222666@foxmail.com>",
12
22
  "repository": {
13
23
  "type": "git",
@@ -38,16 +48,18 @@
38
48
  "adapter"
39
49
  ],
40
50
  "dependencies": {
41
- "@streamparser/json": "^0.0.19",
42
- "langchain": "^0.0.186"
51
+ "@langchain/core": "^0.2.27",
52
+ "@streamparser/json": "^0.0.21",
53
+ "zod": "^3.24.0-canary.20240701T200529",
54
+ "zod-to-json-schema": "^3.23.2"
43
55
  },
44
56
  "devDependencies": {
45
- "atsc": "^1.2.2",
46
- "koishi": "^4.16.1"
57
+ "atsc": "^2.1.0",
58
+ "koishi": "^4.17.12"
47
59
  },
48
60
  "peerDependencies": {
49
- "koishi": "^4.16.0",
50
- "koishi-plugin-chatluna": "^1.0.0-beta.28"
61
+ "koishi": "^4.17.9",
62
+ "koishi-plugin-chatluna": "^1.0.0-beta.76"
51
63
  },
52
64
  "koishi": {
53
65
  "description": {
package/lib/client.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import { PlatformModelAndEmbeddingsClient } from 'koishi-plugin-chatluna/lib/llm-core/platform/client';
2
- import { ClientConfig } from 'koishi-plugin-chatluna/lib/llm-core/platform/config';
3
- import { ChatHubBaseEmbeddings, ChatLunaChatModel } from 'koishi-plugin-chatluna/lib/llm-core/platform/model';
4
- import { ModelInfo } from 'koishi-plugin-chatluna/lib/llm-core/platform/types';
5
- import { Context } from 'koishi';
6
- import { Config } from '.';
7
- export declare class GeminiClient extends PlatformModelAndEmbeddingsClient<ClientConfig> {
8
- private _config;
9
- platform: string;
10
- private _requester;
11
- private _models;
12
- constructor(ctx: Context, _config: Config, clientConfig: ClientConfig);
13
- init(): Promise<void>;
14
- refreshModels(): Promise<ModelInfo[]>;
15
- getModels(): Promise<ModelInfo[]>;
16
- protected _createModel(model: string): ChatLunaChatModel | ChatHubBaseEmbeddings;
17
- }