@xsai/embed 0.0.11 → 0.0.13

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,10 +1,8 @@
1
1
  import { CommonRequestOptions } from '@xsai/shared';
2
2
 
3
- type EmbedModel = 'all-minilm' | 'mxbai-embed-large' | 'nomic-embed-text' | ({} & string);
4
- interface EmbedOptions extends CommonRequestOptions<'embeddings'> {
3
+ interface EmbedOptions extends CommonRequestOptions {
5
4
  [key: string]: unknown;
6
5
  input: string;
7
- model: EmbedModel;
8
6
  }
9
7
  interface EmbedResponseUsage {
10
8
  prompt_tokens: number;
@@ -17,10 +15,9 @@ interface EmbedResult {
17
15
  }
18
16
  declare const embed: (options: EmbedOptions) => Promise<EmbedResult>;
19
17
 
20
- interface EmbedManyOptions extends CommonRequestOptions<'embeddings'> {
18
+ interface EmbedManyOptions extends CommonRequestOptions {
21
19
  [key: string]: unknown;
22
20
  input: string[];
23
- model: EmbedModel;
24
21
  }
25
22
  interface EmbedManyResult {
26
23
  embeddings: number[][];
@@ -29,4 +26,4 @@ interface EmbedManyResult {
29
26
  }
30
27
  declare const embedMany: (options: EmbedManyOptions) => Promise<EmbedManyResult>;
31
28
 
32
- export { type EmbedManyOptions, type EmbedManyResult, type EmbedModel, type EmbedOptions, type EmbedResponseUsage, type EmbedResult, embed as default, embed, embedMany };
29
+ export { type EmbedManyOptions, type EmbedManyResult, type EmbedOptions, type EmbedResponseUsage, type EmbedResult, embed as default, embed, embedMany };
package/dist/index.js CHANGED
@@ -1,17 +1,11 @@
1
- import { requestUrl, clean } from '@xsai/shared';
1
+ import { requestBody, requestHeaders } from '@xsai/shared';
2
2
 
3
- const embed = async (options) => await fetch(requestUrl(options.path ?? "embeddings", options.base), {
4
- body: JSON.stringify(clean({
5
- ...options,
6
- abortSignal: void 0,
7
- base: void 0,
8
- headers: void 0,
9
- path: void 0
10
- })),
11
- headers: {
3
+ const embed = async (options) => await fetch(options.url, {
4
+ body: requestBody(options),
5
+ headers: requestHeaders({
12
6
  "Content-Type": "application/json",
13
7
  ...options.headers
14
- },
8
+ }, options.apiKey),
15
9
  method: "POST",
16
10
  signal: options.abortSignal
17
11
  }).then((res) => res.json()).then(({ data, usage }) => ({
@@ -20,18 +14,12 @@ const embed = async (options) => await fetch(requestUrl(options.path ?? "embeddi
20
14
  usage
21
15
  }));
22
16
 
23
- const embedMany = async (options) => await fetch(requestUrl(options.path ?? "embeddings", options.base), {
24
- body: JSON.stringify(clean({
25
- ...options,
26
- abortSignal: void 0,
27
- base: void 0,
28
- headers: void 0,
29
- path: void 0
30
- })),
31
- headers: {
17
+ const embedMany = async (options) => await fetch(options.url, {
18
+ body: requestBody(options),
19
+ headers: requestHeaders({
32
20
  "Content-Type": "application/json",
33
21
  ...options.headers
34
- },
22
+ }, options.apiKey),
35
23
  method: "POST",
36
24
  signal: options.abortSignal
37
25
  }).then((res) => res.json()).then(({ data, usage }) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsai/embed",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "author": "Moeru AI",
6
6
  "license": "MIT",
@@ -25,6 +25,9 @@
25
25
  "dependencies": {
26
26
  "@xsai/shared": ""
27
27
  },
28
+ "devDependencies": {
29
+ "@xsai/providers": ""
30
+ },
28
31
  "scripts": {
29
32
  "build": "pkgroll",
30
33
  "build:watch": "pkgroll --watch",