@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 +3 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
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?:
|
|
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
|
|
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) => {
|