koishi-plugin-chatluna-google-gemini-adapter 1.0.0-beta.2 → 1.0.0-beta.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/lib/client.js CHANGED
@@ -22,6 +22,9 @@ class GeminiClient extends client_1.PlatformModelAndEmbeddingsClient {
22
22
  async refreshModels() {
23
23
  try {
24
24
  const rawModels = await this._requester.getModels();
25
+ if (!rawModels.length) {
26
+ throw new error_1.ChatLunaError(error_1.ChatLunaErrorCode.MODEL_INIT_ERROR, new Error('No model found'));
27
+ }
25
28
  return rawModels
26
29
  .map((model) => model.replace('models/', ''))
27
30
  .map((model) => {
package/lib/requester.js CHANGED
@@ -149,6 +149,10 @@ class GeminiRequester extends api_1.ModelRequester {
149
149
  const response = await this._get('models');
150
150
  data = await response.text();
151
151
  data = JSON.parse(data);
152
+ if (!data.models || !data.models.length) {
153
+ throw new Error('error when listing gemini models, Result:' +
154
+ JSON.stringify(data));
155
+ }
152
156
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
157
  return data.models
154
158
  .map((model) => model.name)
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.2",
4
+ "version": "1.0.0-beta.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [