chat-nest-core 1.0.0
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.cjs +35 -0
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +8 -0
- package/package.json +31 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
MessageRole: () => MessageRole
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/types.ts
|
|
28
|
+
var MessageRole = {
|
|
29
|
+
User: "user",
|
|
30
|
+
Assistant: "assistant"
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
MessageRole
|
|
35
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare const MessageRole: {
|
|
2
|
+
readonly User: "user";
|
|
3
|
+
readonly Assistant: "assistant";
|
|
4
|
+
};
|
|
5
|
+
type MessageRole = (typeof MessageRole)[keyof typeof MessageRole];
|
|
6
|
+
type Message = {
|
|
7
|
+
id: string;
|
|
8
|
+
role: MessageRole;
|
|
9
|
+
content: string;
|
|
10
|
+
};
|
|
11
|
+
type UseAIChatOptions = {
|
|
12
|
+
endpoint: string;
|
|
13
|
+
initialMessages?: Message[];
|
|
14
|
+
maxMessages?: number;
|
|
15
|
+
};
|
|
16
|
+
type UseAIChatReturn = {
|
|
17
|
+
messages: Message[];
|
|
18
|
+
sendMessage(text: string): Promise<void>;
|
|
19
|
+
cancel(): void;
|
|
20
|
+
isStreaming: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
reset(): void;
|
|
23
|
+
};
|
|
24
|
+
type StreamCallbacks = {
|
|
25
|
+
onToken(token: string): void;
|
|
26
|
+
onComplete(): void;
|
|
27
|
+
onError(error: Error): void;
|
|
28
|
+
};
|
|
29
|
+
interface AIClient {
|
|
30
|
+
streamChat(messages: Message[], callbacks: StreamCallbacks): void;
|
|
31
|
+
cancel(): void;
|
|
32
|
+
}
|
|
33
|
+
type AiClientConfig = {
|
|
34
|
+
endpoint: string;
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
maxRetries?: number;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { type AIClient, type AiClientConfig, type Message, MessageRole, type StreamCallbacks, type UseAIChatOptions, type UseAIChatReturn };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare const MessageRole: {
|
|
2
|
+
readonly User: "user";
|
|
3
|
+
readonly Assistant: "assistant";
|
|
4
|
+
};
|
|
5
|
+
type MessageRole = (typeof MessageRole)[keyof typeof MessageRole];
|
|
6
|
+
type Message = {
|
|
7
|
+
id: string;
|
|
8
|
+
role: MessageRole;
|
|
9
|
+
content: string;
|
|
10
|
+
};
|
|
11
|
+
type UseAIChatOptions = {
|
|
12
|
+
endpoint: string;
|
|
13
|
+
initialMessages?: Message[];
|
|
14
|
+
maxMessages?: number;
|
|
15
|
+
};
|
|
16
|
+
type UseAIChatReturn = {
|
|
17
|
+
messages: Message[];
|
|
18
|
+
sendMessage(text: string): Promise<void>;
|
|
19
|
+
cancel(): void;
|
|
20
|
+
isStreaming: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
reset(): void;
|
|
23
|
+
};
|
|
24
|
+
type StreamCallbacks = {
|
|
25
|
+
onToken(token: string): void;
|
|
26
|
+
onComplete(): void;
|
|
27
|
+
onError(error: Error): void;
|
|
28
|
+
};
|
|
29
|
+
interface AIClient {
|
|
30
|
+
streamChat(messages: Message[], callbacks: StreamCallbacks): void;
|
|
31
|
+
cancel(): void;
|
|
32
|
+
}
|
|
33
|
+
type AiClientConfig = {
|
|
34
|
+
endpoint: string;
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
maxRetries?: number;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { type AIClient, type AiClientConfig, type Message, MessageRole, type StreamCallbacks, type UseAIChatOptions, type UseAIChatReturn };
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chat-nest-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"author": "Shivam Shukla",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/shivams10/chat-nest"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/shivams10/chat-nest",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/shivams10/chat-nest/issues"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": ["dist"],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup src/index.ts --dts --format esm"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"tsup": "^8.5.1"
|
|
30
|
+
}
|
|
31
|
+
}
|