@xsai/embed 0.3.5 → 0.4.0-beta.10

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/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { CommonRequestOptions } from '@xsai/shared';
1
+ import { WithUnknown, CommonRequestOptions } from '@xsai/shared';
2
2
 
3
3
  interface EmbedOptions extends CommonRequestOptions {
4
- [key: string]: unknown;
5
4
  input: string;
6
5
  }
7
6
  interface EmbedResponse {
@@ -24,10 +23,9 @@ interface EmbedResult {
24
23
  input: string;
25
24
  usage: EmbedResponseUsage;
26
25
  }
27
- declare const embed: (options: EmbedOptions) => Promise<EmbedResult>;
26
+ declare const embed: (options: WithUnknown<EmbedOptions>) => Promise<EmbedResult>;
28
27
 
29
28
  interface EmbedManyOptions extends CommonRequestOptions {
30
- [key: string]: unknown;
31
29
  input: string[];
32
30
  }
33
31
  interface EmbedManyResult {
@@ -35,6 +33,7 @@ interface EmbedManyResult {
35
33
  input: string[];
36
34
  usage: EmbedResponseUsage;
37
35
  }
38
- declare const embedMany: (options: EmbedManyOptions) => Promise<EmbedManyResult>;
36
+ declare const embedMany: (options: WithUnknown<EmbedManyOptions>) => Promise<EmbedManyResult>;
39
37
 
40
- export { type EmbedManyOptions, type EmbedManyResult, type EmbedOptions, type EmbedResponse, type EmbedResponseUsage, type EmbedResult, embed, embedMany };
38
+ export { embed, embedMany };
39
+ export type { EmbedManyOptions, EmbedManyResult, EmbedOptions, EmbedResponse, EmbedResponseUsage, EmbedResult };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { requestURL, requestHeaders, requestBody, responseJSON } from '@xsai/shared';
1
+ import { requestURL, requestHeaders, requestBody, responseCatch, responseJSON } from '@xsai/shared';
2
2
 
3
3
  const embed = async (options) => (options.fetch ?? globalThis.fetch)(requestURL("embeddings", options.baseURL), {
4
4
  body: requestBody(options),
@@ -8,7 +8,7 @@ const embed = async (options) => (options.fetch ?? globalThis.fetch)(requestURL(
8
8
  }, options.apiKey),
9
9
  method: "POST",
10
10
  signal: options.abortSignal
11
- }).then(responseJSON).then(({ data, usage }) => ({
11
+ }).then(responseCatch).then(responseJSON).then(({ data, usage }) => ({
12
12
  embedding: data[0].embedding,
13
13
  input: options.input,
14
14
  usage
@@ -22,7 +22,7 @@ const embedMany = async (options) => (options.fetch ?? globalThis.fetch)(request
22
22
  }, options.apiKey),
23
23
  method: "POST",
24
24
  signal: options.abortSignal
25
- }).then(responseJSON).then(({ data, usage }) => ({
25
+ }).then(responseCatch).then(responseJSON).then(({ data, usage }) => ({
26
26
  embeddings: data.map((data2) => data2.embedding),
27
27
  input: options.input,
28
28
  usage
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/embed",
3
3
  "type": "module",
4
- "version": "0.3.5",
4
+ "version": "0.4.0-beta.10",
5
5
  "description": "extra-small AI SDK.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@xsai/shared": "~0.3.5"
32
+ "@xsai/shared": "~0.4.0-beta.10"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "pkgroll",