@xsai/shared 1.0.0-beta.4 → 1.0.0-beta.6

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,8 +1,9 @@
1
+ type Fetch = (request: Request) => Promise<Response>;
1
2
  interface HttpOptions {
2
3
  apiKey?: string;
3
4
  /** @example `https://api.openai.com/v1/` */
4
5
  baseURL: string | URL;
5
- fetch?: (request: Request) => Promise<Response>;
6
+ fetch?: Fetch;
6
7
  headers?: Record<string, string | undefined>;
7
8
  model: string;
8
9
  }
@@ -154,4 +155,4 @@ declare class EventSourceParserStream extends TransformStream<string, EventSourc
154
155
  }
155
156
 
156
157
  export { EventSourceParserStream, HttpError, XSAIError, requestURL, sendRequest };
157
- export type { EventSourceMessage, HttpOptions, Promisable, SendRequestOptions, XSAIErrorCause, XSAIErrorCauseMap, XSAIErrorCode, XSAIErrorOptions };
158
+ export type { EventSourceMessage, Fetch, HttpOptions, Promisable, SendRequestOptions, XSAIErrorCause, XSAIErrorCauseMap, XSAIErrorCode, XSAIErrorOptions };
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ const sendRequest = async (options, httpOptions) => {
30
30
  const url = requestURL(options.path, httpOptions.baseURL);
31
31
  const headers = options.headers ?? {
32
32
  ...httpOptions.headers,
33
- "Authorization": httpOptions.apiKey == null ? httpOptions.headers?.Authorization : `Bearer ${httpOptions.apiKey}`,
33
+ "Authorization": httpOptions.apiKey != null && httpOptions.apiKey !== "" ? `Bearer ${httpOptions.apiKey}` : httpOptions.headers?.Authorization,
34
34
  "Content-Type": options.body instanceof FormData ? void 0 : options.body == null ? httpOptions.headers?.["Content-Type"] : "application/json"
35
35
  };
36
36
  const responseCatch = async (res) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/shared",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.4",
4
+ "version": "1.0.0-beta.6",
5
5
  "description": "extra-small AI SDK: shared utilities for xsAI packages.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",