@xsai/shared-chat 0.0.23 → 0.0.25
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 +1 -6
- package/dist/index.js +3 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { CommonRequestOptions } from '@xsai/shared';
|
|
2
2
|
|
|
3
|
-
declare class ChatError extends Error {
|
|
4
|
-
response?: Response;
|
|
5
|
-
constructor(message: string, response?: Response);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
3
|
type Part = AudioPart | ImagePart | RefusalPart | TextPart;
|
|
9
4
|
interface CommonPart<T extends string> {
|
|
10
5
|
type: T;
|
|
@@ -120,4 +115,4 @@ declare namespace message {
|
|
|
120
115
|
export { message_assistant as assistant, message_imagePart as imagePart, message_messages as messages, message_system as system, message_textPart as textPart, message_tool as tool, message_user as user };
|
|
121
116
|
}
|
|
122
117
|
|
|
123
|
-
export { type AssistantMessage, type AssistantMessagePart, type AssistantMessageResponse, type AudioBase64, type AudioPart,
|
|
118
|
+
export { type AssistantMessage, type AssistantMessagePart, type AssistantMessageResponse, type AudioBase64, type AudioPart, type ChatOptions, type CommonMessage, type CommonPart, type FinishReason, type ImagePart, type ImageURLorBase64, type Message, type Part, type RefusalPart, type SystemMessage, type SystemMessagePart, type TextPart, type Tool, type ToolCall, type ToolChoice, type ToolMessage, type ToolMessagePart, type UserMessage, type UserMessagePart, chat, message };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { requestURL, requestBody, requestHeaders } from '@xsai/shared';
|
|
2
|
-
|
|
3
|
-
class ChatError extends Error {
|
|
4
|
-
response;
|
|
5
|
-
constructor(message, response) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "ChatError";
|
|
8
|
-
this.response = response;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import { requestURL, requestBody, requestHeaders, responseCatch } from '@xsai/shared';
|
|
11
2
|
|
|
12
3
|
const chat = async (options) => await (options.fetch ?? globalThis.fetch)(requestURL("chat/completions", options.baseURL), {
|
|
13
4
|
body: requestBody({
|
|
@@ -23,7 +14,7 @@ const chat = async (options) => await (options.fetch ?? globalThis.fetch)(reques
|
|
|
23
14
|
}, options.apiKey),
|
|
24
15
|
method: "POST",
|
|
25
16
|
signal: options.abortSignal
|
|
26
|
-
});
|
|
17
|
+
}).then(responseCatch);
|
|
27
18
|
|
|
28
19
|
const messages = (...messages2) => messages2;
|
|
29
20
|
const system = (content) => ({ content, role: "system" });
|
|
@@ -48,4 +39,4 @@ var message = /*#__PURE__*/Object.freeze({
|
|
|
48
39
|
user: user
|
|
49
40
|
});
|
|
50
41
|
|
|
51
|
-
export {
|
|
42
|
+
export { chat, message };
|