@xsai/utils-chat 0.0.30
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/LICENSE.md +21 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +24 -0
- package/package.json +39 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Moeru AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Message, SystemMessagePart, SystemMessage, UserMessagePart, UserMessage, TextPart, ImagePart, AssistantMessagePart, ToolCall, AssistantMessage, ToolMessagePart, ToolMessage } from '@xsai/shared-chat';
|
|
2
|
+
|
|
3
|
+
declare const messages: (...messages: Message[]) => Message[];
|
|
4
|
+
declare const system: <C extends string | SystemMessagePart[]>(content: C) => SystemMessage;
|
|
5
|
+
declare const user: <C extends Array<UserMessagePart> | string>(content: C) => UserMessage;
|
|
6
|
+
declare const textPart: (text: string) => TextPart;
|
|
7
|
+
declare const imagePart: (url: string) => ImagePart;
|
|
8
|
+
declare const assistant: <C extends AssistantMessagePart[] | string | ToolCall>(content: C) => AssistantMessage;
|
|
9
|
+
declare const tool: <C extends string | ToolMessagePart[]>(content: C, toolCall: ToolCall) => ToolMessage;
|
|
10
|
+
|
|
11
|
+
declare const message_assistant: typeof assistant;
|
|
12
|
+
declare const message_imagePart: typeof imagePart;
|
|
13
|
+
declare const message_messages: typeof messages;
|
|
14
|
+
declare const message_system: typeof system;
|
|
15
|
+
declare const message_textPart: typeof textPart;
|
|
16
|
+
declare const message_tool: typeof tool;
|
|
17
|
+
declare const message_user: typeof user;
|
|
18
|
+
declare namespace message {
|
|
19
|
+
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 };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { message };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const messages = (...messages2) => messages2;
|
|
2
|
+
const system = (content) => ({ content, role: "system" });
|
|
3
|
+
const user = (content) => ({ content, role: "user" });
|
|
4
|
+
const textPart = (text) => ({ text, type: "text" });
|
|
5
|
+
const imagePart = (url) => ({ image_url: { url }, type: "image_url" });
|
|
6
|
+
const assistant = (content) => typeof content === "string" || Array.isArray(content) ? { content, role: "assistant" } : { role: "assistant", tool_calls: [content] };
|
|
7
|
+
const tool = (content, toolCall) => ({
|
|
8
|
+
content,
|
|
9
|
+
role: "tool",
|
|
10
|
+
tool_call_id: toolCall.id
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var message = /*#__PURE__*/Object.freeze({
|
|
14
|
+
__proto__: null,
|
|
15
|
+
assistant: assistant,
|
|
16
|
+
imagePart: imagePart,
|
|
17
|
+
messages: messages,
|
|
18
|
+
system: system,
|
|
19
|
+
textPart: textPart,
|
|
20
|
+
tool: tool,
|
|
21
|
+
user: user
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { message };
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xsai/utils-chat",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.30",
|
|
5
|
+
"description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
|
|
6
|
+
"author": "Moeru AI",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://xsai.js.org",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/moeru-ai/xsai.git",
|
|
12
|
+
"directory": "packages/utils-chat"
|
|
13
|
+
},
|
|
14
|
+
"bugs": "https://github.com/moeru-ai/xsai/issues",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"xsai",
|
|
17
|
+
"openai",
|
|
18
|
+
"ai"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@xsai/shared-chat": ""
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "pkgroll",
|
|
37
|
+
"build:watch": "pkgroll --watch"
|
|
38
|
+
}
|
|
39
|
+
}
|