koishi-plugin-chatluna-google-gemini-adapter 1.0.0-beta.13 → 1.0.0-beta.15

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,624 @@
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 { chatLunaFetch } from "koishi-plugin-chatluna/utils/request";
34
+ import { sse } from "koishi-plugin-chatluna/utils/sse";
35
+ import { readableStreamToAsyncIterable } from "koishi-plugin-chatluna/utils/stream";
36
+
37
+ // src/utils.ts
38
+ import {
39
+ AIMessageChunk,
40
+ ChatMessageChunk,
41
+ HumanMessageChunk,
42
+ SystemMessageChunk
43
+ } from "@langchain/core/messages";
44
+ import { zodToJsonSchema } from "zod-to-json-schema";
45
+ async function langchainMessageToGeminiMessage(messages, model) {
46
+ const mappedMessage = await Promise.all(
47
+ messages.map(async (rawMessage) => {
48
+ const role = messageTypeToGeminiRole(rawMessage._getType());
49
+ if (role === "function" || rawMessage.additional_kwargs?.function_call != null) {
50
+ return {
51
+ role: "function",
52
+ parts: [
53
+ {
54
+ functionResponse: rawMessage.additional_kwargs?.function_call != null ? void 0 : {
55
+ name: rawMessage.name,
56
+ response: {
57
+ name: rawMessage.name,
58
+ content: (() => {
59
+ try {
60
+ const result3 = JSON.parse(
61
+ rawMessage.content
62
+ );
63
+ if (typeof result3 === "string") {
64
+ return {
65
+ response: result3
66
+ };
67
+ } else {
68
+ return result3;
69
+ }
70
+ } catch (e) {
71
+ return {
72
+ response: rawMessage.content
73
+ };
74
+ }
75
+ })()
76
+ }
77
+ },
78
+ functionCall: rawMessage.additional_kwargs?.function_call != null ? {
79
+ name: rawMessage.additional_kwargs.function_call.name,
80
+ args: (() => {
81
+ try {
82
+ const result3 = JSON.parse(
83
+ rawMessage.additional_kwargs.function_call.arguments
84
+ );
85
+ if (typeof result3 === "string") {
86
+ return {
87
+ input: result3
88
+ };
89
+ } else {
90
+ return result3;
91
+ }
92
+ } catch (e) {
93
+ return {
94
+ input: rawMessage.additional_kwargs.function_call.arguments
95
+ };
96
+ }
97
+ })()
98
+ } : void 0
99
+ }
100
+ ]
101
+ };
102
+ }
103
+ const images = rawMessage.additional_kwargs.images;
104
+ const result2 = {
105
+ role,
106
+ parts: [
107
+ {
108
+ text: rawMessage.content
109
+ }
110
+ ]
111
+ };
112
+ if ((model.includes("vision") || model.includes("gemini-1.5")) && images != null) {
113
+ for (const image of images) {
114
+ result2.parts.push({
115
+ inline_data: {
116
+ // base64 image match type
117
+ data: image.replace(/^data:image\/\w+;base64,/, ""),
118
+ mime_type: "image/jpeg"
119
+ }
120
+ });
121
+ }
122
+ }
123
+ return result2;
124
+ })
125
+ );
126
+ const result = [];
127
+ for (let i = 0; i < mappedMessage.length; i++) {
128
+ const message = mappedMessage[i];
129
+ if (message.role !== "system") {
130
+ result.push(message);
131
+ continue;
132
+ }
133
+ result.push({
134
+ role: "user",
135
+ parts: message.parts
136
+ });
137
+ if (mappedMessage?.[i + 1]?.role === "model") {
138
+ continue;
139
+ }
140
+ if (mappedMessage?.[i + 1]?.role === "user") {
141
+ result.push({
142
+ role: "model",
143
+ parts: [{ text: "Okay, what do I need to do?" }]
144
+ });
145
+ }
146
+ }
147
+ if (result[result.length - 1].role === "model") {
148
+ result.push({
149
+ role: "user",
150
+ parts: [
151
+ {
152
+ text: "Continue what I said to you last message. Follow these instructions."
153
+ }
154
+ ]
155
+ });
156
+ }
157
+ if (model.includes("vision")) {
158
+ const textBuffer = [];
159
+ const last = result.pop();
160
+ for (let i = 0; i < result.length; i++) {
161
+ const message = result[i];
162
+ const text = message.parts[0].text;
163
+ textBuffer.push(`${message.role}: ${text}`);
164
+ }
165
+ const lastParts = last.parts;
166
+ let lastImagesParts = lastParts.filter(
167
+ (part) => part.inline_data?.mime_type === "image/jpeg"
168
+ );
169
+ if (lastImagesParts.length < 1) {
170
+ for (let i = result.length - 1; i >= 0; i--) {
171
+ const message = result[i];
172
+ const images = message.parts.filter(
173
+ (part) => part.inline_data?.mime_type === "image/jpeg"
174
+ );
175
+ if (images.length > 0) {
176
+ lastImagesParts = images;
177
+ break;
178
+ }
179
+ }
180
+ }
181
+ ;
182
+ lastParts.filter(
183
+ (part) => part.text !== void 0 && part.text !== null
184
+ ).forEach((part) => {
185
+ textBuffer.push(`${last.role}: ${part.text}`);
186
+ });
187
+ return [
188
+ {
189
+ role: "user",
190
+ parts: [
191
+ {
192
+ text: textBuffer.join("\n")
193
+ },
194
+ ...lastImagesParts
195
+ ]
196
+ }
197
+ ];
198
+ }
199
+ return result;
200
+ }
201
+ __name(langchainMessageToGeminiMessage, "langchainMessageToGeminiMessage");
202
+ function partAsType(part) {
203
+ return part;
204
+ }
205
+ __name(partAsType, "partAsType");
206
+ function formatToolsToGeminiAITools(tools) {
207
+ if (tools.length < 1) {
208
+ return void 0;
209
+ }
210
+ return tools.map(formatToolToGeminiAITool);
211
+ }
212
+ __name(formatToolsToGeminiAITools, "formatToolsToGeminiAITools");
213
+ function formatToolToGeminiAITool(tool) {
214
+ const parameters = zodToJsonSchema(tool.schema);
215
+ delete parameters["$schema"];
216
+ delete parameters["additionalProperties"];
217
+ return {
218
+ name: tool.name,
219
+ description: tool.description,
220
+ // any?
221
+ parameters
222
+ };
223
+ }
224
+ __name(formatToolToGeminiAITool, "formatToolToGeminiAITool");
225
+ function messageTypeToGeminiRole(type) {
226
+ switch (type) {
227
+ case "system":
228
+ return "system";
229
+ case "ai":
230
+ return "model";
231
+ case "human":
232
+ return "user";
233
+ case "function":
234
+ return "function";
235
+ default:
236
+ throw new Error(`Unknown message type: ${type}`);
237
+ }
238
+ }
239
+ __name(messageTypeToGeminiRole, "messageTypeToGeminiRole");
240
+
241
+ // src/requester.ts
242
+ var GeminiRequester = class extends ModelRequester {
243
+ constructor(_config) {
244
+ super();
245
+ this._config = _config;
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
+ try {
401
+ const response = await this._post(
402
+ `models/${params.model}:embedContent`,
403
+ {
404
+ model: `models/${params.model}`,
405
+ content: {
406
+ parts: [
407
+ {
408
+ text: params.input
409
+ }
410
+ ]
411
+ }
412
+ }
413
+ );
414
+ data = await response.text();
415
+ data = JSON.parse(data);
416
+ if (data.embedding && data.embedding.values?.length > 0) {
417
+ return data.embedding.values;
418
+ }
419
+ throw new Error(
420
+ "error when calling gemini embeddings, Result: " + JSON.stringify(data)
421
+ );
422
+ } catch (e) {
423
+ const error = new Error(
424
+ "error when calling gemini embeddings, Result: " + JSON.stringify(data)
425
+ );
426
+ error.stack = e.stack;
427
+ error.cause = e.cause;
428
+ logger.debug(e);
429
+ throw new ChatLunaError(ChatLunaErrorCode.API_REQUEST_FAILED, error);
430
+ }
431
+ }
432
+ async getModels() {
433
+ let data;
434
+ try {
435
+ const response = await this._get("models");
436
+ data = await response.text();
437
+ data = JSON.parse(data);
438
+ if (!data.models || !data.models.length) {
439
+ throw new Error(
440
+ "error when listing gemini models, Result:" + JSON.stringify(data)
441
+ );
442
+ }
443
+ return data.models.map((model) => model.name).filter(
444
+ (model) => model.includes("gemini") || model.includes("embedding")
445
+ );
446
+ } catch (e) {
447
+ const error = new Error(
448
+ "error when listing gemini models, Result: " + JSON.stringify(data)
449
+ );
450
+ error.stack = e.stack;
451
+ error.cause = e.cause;
452
+ throw error;
453
+ }
454
+ }
455
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
456
+ _post(url, data, params = {}) {
457
+ const requestUrl = this._concatUrl(url);
458
+ for (const key in data) {
459
+ if (data[key] === void 0) {
460
+ delete data[key];
461
+ }
462
+ }
463
+ const body = JSON.stringify(data);
464
+ return chatLunaFetch(requestUrl, {
465
+ body,
466
+ headers: this._buildHeaders(),
467
+ method: "POST",
468
+ ...params
469
+ });
470
+ }
471
+ _get(url) {
472
+ const requestUrl = this._concatUrl(url);
473
+ return chatLunaFetch(requestUrl, {
474
+ method: "GET",
475
+ headers: this._buildHeaders()
476
+ });
477
+ }
478
+ _concatUrl(url) {
479
+ const apiEndPoint = this._config.apiEndpoint;
480
+ if (apiEndPoint.endsWith("/")) {
481
+ return apiEndPoint + url + `?key=${this._config.apiKey}`;
482
+ }
483
+ return apiEndPoint + "/" + url + `?key=${this._config.apiKey}`;
484
+ }
485
+ _buildHeaders() {
486
+ return {
487
+ /* Authorization: `Bearer ${this._config.apiKey}`, */
488
+ "Content-Type": "application/json"
489
+ };
490
+ }
491
+ async init() {
492
+ }
493
+ async dispose() {
494
+ }
495
+ };
496
+
497
+ // src/client.ts
498
+ var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
499
+ constructor(ctx, _config, clientConfig) {
500
+ super(ctx, clientConfig);
501
+ this._config = _config;
502
+ this._requester = new GeminiRequester(clientConfig);
503
+ }
504
+ static {
505
+ __name(this, "GeminiClient");
506
+ }
507
+ platform = "gemini";
508
+ _requester;
509
+ _models;
510
+ async init() {
511
+ await this.getModels();
512
+ }
513
+ async refreshModels() {
514
+ try {
515
+ const rawModels = await this._requester.getModels();
516
+ if (!rawModels.length) {
517
+ throw new ChatLunaError2(
518
+ ChatLunaErrorCode2.MODEL_INIT_ERROR,
519
+ new Error("No model found")
520
+ );
521
+ }
522
+ return rawModels.map((model) => model.replace("models/", "")).map((model) => {
523
+ return {
524
+ name: model,
525
+ maxTokens: model.includes("vision") ? 12288 : 30720,
526
+ type: model.includes("embedding") ? ModelType.embeddings : ModelType.llm,
527
+ functionCall: !model.includes("vision"),
528
+ supportMode: ["all"]
529
+ };
530
+ });
531
+ } catch (e) {
532
+ throw new ChatLunaError2(ChatLunaErrorCode2.MODEL_INIT_ERROR, e);
533
+ }
534
+ }
535
+ async getModels() {
536
+ if (this._models) {
537
+ return Object.values(this._models);
538
+ }
539
+ const models = await this.refreshModels();
540
+ this._models = {};
541
+ for (const model of models) {
542
+ this._models[model.name] = model;
543
+ }
544
+ }
545
+ _createModel(model) {
546
+ const info = this._models[model];
547
+ if (info == null) {
548
+ throw new ChatLunaError2(ChatLunaErrorCode2.MODEL_NOT_FOUND);
549
+ }
550
+ if (info.type === ModelType.llm) {
551
+ return new ChatLunaChatModel({
552
+ modelInfo: info,
553
+ requester: this._requester,
554
+ model,
555
+ maxTokens: this._config.maxTokens,
556
+ timeout: this._config.timeout,
557
+ temperature: this._config.temperature,
558
+ maxRetries: this._config.maxRetries,
559
+ llmType: "gemini"
560
+ });
561
+ }
562
+ return new ChatLunaEmbeddings({
563
+ client: this._requester,
564
+ model,
565
+ maxRetries: this._config.maxRetries
566
+ });
567
+ }
568
+ };
569
+
570
+ // src/index.ts
571
+ import { createLogger } from "koishi-plugin-chatluna/utils/logger";
572
+ var logger;
573
+ function apply(ctx, config) {
574
+ const plugin = new ChatLunaPlugin(ctx, config, "gemini");
575
+ logger = createLogger(ctx, "chatluna-gemini-adapter");
576
+ ctx.on("ready", async () => {
577
+ await plugin.registerToService();
578
+ await plugin.parseConfig((config2) => {
579
+ return config2.apiKeys.map(([apiKey, apiEndpoint]) => {
580
+ return {
581
+ apiKey,
582
+ apiEndpoint,
583
+ platform: "gemini",
584
+ chatLimit: config2.chatTimeLimit,
585
+ timeout: config2.timeout,
586
+ maxRetries: config2.maxRetries,
587
+ concurrentMaxSize: config2.chatConcurrentMaxSize
588
+ };
589
+ });
590
+ });
591
+ await plugin.registerClient(
592
+ (_, clientConfig) => new GeminiClient(ctx, config, clientConfig)
593
+ );
594
+ await plugin.initClients();
595
+ });
596
+ }
597
+ __name(apply, "apply");
598
+ var Config = Schema.intersect([
599
+ ChatLunaPlugin.Config,
600
+ Schema.object({
601
+ apiKeys: Schema.array(
602
+ Schema.tuple([
603
+ Schema.string().role("secret").description("Gemini 的 API Key").required(),
604
+ Schema.string().description("请求 Gemini API 的地址").default("https://generativelanguage.googleapis.com/v1beta")
605
+ ])
606
+ ).description("Gemini 的 API Key 和请求地址列表").default([["", "https://generativelanguage.googleapis.com/v1beta"]])
607
+ }).description("请求设置"),
608
+ Schema.object({
609
+ maxTokens: Schema.number().description(
610
+ "回复的最大 Token 数(16~32800,必须是16的倍数)(注意如果你目前使用的模型的最大 Token 为 8000 及以上的话才建议设置超过 512 token)"
611
+ ).min(16).max(128e3).step(16).default(1024),
612
+ temperature: Schema.percent().description("回复温度,越高越随机").min(0).max(1).step(0.1).default(0.8)
613
+ }).description("模型设置")
614
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
615
+ ]);
616
+ var inject = ["chatluna"];
617
+ var name = "chatluna-google-gemini-adapter";
618
+ export {
619
+ Config,
620
+ apply,
621
+ inject,
622
+ logger,
623
+ name
624
+ };
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.13",
5
- "main": "lib/index.js",
4
+ "version": "1.0.0-beta.15",
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,18 +48,18 @@
38
48
  "adapter"
39
49
  ],
40
50
  "dependencies": {
41
- "@langchain/core": "^0.2.5",
51
+ "@langchain/core": "^0.2.8",
42
52
  "@streamparser/json": "^0.0.21",
43
53
  "zod": "^3.24.0-canary.20240523T174819",
44
- "zod-to-json-schema": "^3.23.0"
54
+ "zod-to-json-schema": "^3.23.1"
45
55
  },
46
56
  "devDependencies": {
47
- "atsc": "^2.0.1",
48
- "koishi": "^4.17.7"
57
+ "atsc": "^2.1.0",
58
+ "koishi": "^4.17.9"
49
59
  },
50
60
  "peerDependencies": {
51
- "koishi": "^4.17.0",
52
- "koishi-plugin-chatluna": "^1.0.0-beta.51"
61
+ "koishi": "^4.17.9",
62
+ "koishi-plugin-chatluna": "^1.0.0-beta.54"
53
63
  },
54
64
  "koishi": {
55
65
  "description": {
package/lib/client.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import { Context } from 'koishi';
2
- import { PlatformModelAndEmbeddingsClient } from 'koishi-plugin-chatluna/lib/llm-core/platform/client';
3
- import { ClientConfig } from 'koishi-plugin-chatluna/lib/llm-core/platform/config';
4
- import { ChatHubBaseEmbeddings, ChatLunaChatModel } from 'koishi-plugin-chatluna/lib/llm-core/platform/model';
5
- import { ModelInfo } from 'koishi-plugin-chatluna/lib/llm-core/platform/types';
6
- import { Config } from '.';
7
- export declare class GeminiClient extends PlatformModelAndEmbeddingsClient {
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
- }