@aituber-onair/core 0.16.0 → 0.17.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/README.md +13 -1
- package/dist/constants/index.d.ts +0 -5
- package/dist/constants/index.js +0 -5
- package/dist/constants/index.js.map +1 -1
- package/dist/core/AITuberOnAirCore.d.ts +3 -3
- package/dist/core/AITuberOnAirCore.js +8 -4
- package/dist/core/AITuberOnAirCore.js.map +1 -1
- package/dist/core/ChatProcessor.d.ts +1 -4
- package/dist/core/ChatProcessor.js +1 -3
- package/dist/core/ChatProcessor.js.map +1 -1
- package/dist/core/MemoryManager.d.ts +2 -1
- package/dist/core/MemoryManager.js.map +1 -1
- package/dist/core/ToolExecutor.d.ts +28 -2
- package/dist/core/ToolExecutor.js +88 -0
- package/dist/core/ToolExecutor.js.map +1 -1
- package/dist/index.d.ts +5 -12
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/services/chat/providers/claude/ClaudeSummarizer.d.ts +1 -1
- package/dist/services/chat/providers/claude/ClaudeSummarizer.js +1 -2
- package/dist/services/chat/providers/claude/ClaudeSummarizer.js.map +1 -1
- package/dist/services/chat/providers/gemini/GeminiSummarizer.d.ts +1 -1
- package/dist/services/chat/providers/gemini/GeminiSummarizer.js +1 -2
- package/dist/services/chat/providers/gemini/GeminiSummarizer.js.map +1 -1
- package/dist/services/chat/providers/openai/OpenAISummarizer.d.ts +1 -1
- package/dist/services/chat/providers/openai/OpenAISummarizer.js +1 -2
- package/dist/services/chat/providers/openai/OpenAISummarizer.js.map +1 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -4
- package/dist/utils/index.js +2 -4
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/constants/chat.d.ts +0 -17
- package/dist/constants/chat.js +0 -18
- package/dist/constants/chat.js.map +0 -1
- package/dist/constants/claude.d.ts +0 -8
- package/dist/constants/claude.js +0 -17
- package/dist/constants/claude.js.map +0 -1
- package/dist/constants/gemini.d.ts +0 -10
- package/dist/constants/gemini.js +0 -23
- package/dist/constants/gemini.js.map +0 -1
- package/dist/constants/openai.d.ts +0 -12
- package/dist/constants/openai.js +0 -25
- package/dist/constants/openai.js.map +0 -1
- package/dist/constants/prompts.d.ts +0 -2
- package/dist/constants/prompts.js +0 -13
- package/dist/constants/prompts.js.map +0 -1
- package/dist/services/chat/ChatService.d.ts +0 -50
- package/dist/services/chat/ChatService.js +0 -2
- package/dist/services/chat/ChatService.js.map +0 -1
- package/dist/services/chat/ChatServiceFactory.d.ts +0 -38
- package/dist/services/chat/ChatServiceFactory.js +0 -61
- package/dist/services/chat/ChatServiceFactory.js.map +0 -1
- package/dist/services/chat/providers/ChatServiceProvider.d.ts +0 -48
- package/dist/services/chat/providers/ChatServiceProvider.js +0 -2
- package/dist/services/chat/providers/ChatServiceProvider.js.map +0 -1
- package/dist/services/chat/providers/claude/ClaudeChatService.d.ts +0 -139
- package/dist/services/chat/providers/claude/ClaudeChatService.js +0 -493
- package/dist/services/chat/providers/claude/ClaudeChatService.js.map +0 -1
- package/dist/services/chat/providers/claude/ClaudeChatServiceProvider.d.ts +0 -39
- package/dist/services/chat/providers/claude/ClaudeChatServiceProvider.js +0 -62
- package/dist/services/chat/providers/claude/ClaudeChatServiceProvider.js.map +0 -1
- package/dist/services/chat/providers/gemini/GeminiChatService.d.ts +0 -71
- package/dist/services/chat/providers/gemini/GeminiChatService.js +0 -537
- package/dist/services/chat/providers/gemini/GeminiChatService.js.map +0 -1
- package/dist/services/chat/providers/gemini/GeminiChatServiceProvider.d.ts +0 -39
- package/dist/services/chat/providers/gemini/GeminiChatServiceProvider.js +0 -61
- package/dist/services/chat/providers/gemini/GeminiChatServiceProvider.js.map +0 -1
- package/dist/services/chat/providers/openai/OpenAIChatService.d.ts +0 -107
- package/dist/services/chat/providers/openai/OpenAIChatService.js +0 -530
- package/dist/services/chat/providers/openai/OpenAIChatService.js.map +0 -1
- package/dist/services/chat/providers/openai/OpenAIChatServiceProvider.d.ts +0 -39
- package/dist/services/chat/providers/openai/OpenAIChatServiceProvider.js +0 -66
- package/dist/services/chat/providers/openai/OpenAIChatServiceProvider.js.map +0 -1
- package/dist/types/chat.d.ts +0 -54
- package/dist/types/chat.js +0 -5
- package/dist/types/chat.js.map +0 -1
- package/dist/types/mcp.d.ts +0 -36
- package/dist/types/mcp.js +0 -5
- package/dist/types/mcp.js.map +0 -1
- package/dist/types/toolChat.d.ts +0 -41
- package/dist/types/toolChat.js +0 -2
- package/dist/types/toolChat.js.map +0 -1
- package/dist/utils/chatServiceHttpClient.d.ts +0 -46
- package/dist/utils/chatServiceHttpClient.js +0 -126
- package/dist/utils/chatServiceHttpClient.js.map +0 -1
- package/dist/utils/emotionParser.d.ts +0 -45
- package/dist/utils/emotionParser.js +0 -55
- package/dist/utils/emotionParser.js.map +0 -1
- package/dist/utils/screenplay.d.ts +0 -19
- package/dist/utils/screenplay.js +0 -36
- package/dist/utils/screenplay.js.map +0 -1
- package/dist/utils/streamTextAccumulator.d.ts +0 -24
- package/dist/utils/streamTextAccumulator.js +0 -43
- package/dist/utils/streamTextAccumulator.js.map +0 -1
package/dist/types/chat.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AITuber OnAir Core type definitions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Chat message basic type
|
|
6
|
-
*/
|
|
7
|
-
export interface Message {
|
|
8
|
-
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
9
|
-
content: string;
|
|
10
|
-
timestamp?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Vision block type for image content
|
|
14
|
-
*/
|
|
15
|
-
export type VisionBlock = {
|
|
16
|
-
type: 'text';
|
|
17
|
-
text: string;
|
|
18
|
-
} | {
|
|
19
|
-
type: 'image_url';
|
|
20
|
-
image_url: {
|
|
21
|
-
url: string;
|
|
22
|
-
detail?: 'low' | 'high' | 'auto';
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Message type corresponding to vision (image)
|
|
27
|
-
*/
|
|
28
|
-
export interface MessageWithVision {
|
|
29
|
-
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
30
|
-
content: string | VisionBlock[];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Chat type
|
|
34
|
-
* - chatForm: Chat from text input
|
|
35
|
-
* - youtube: Chat from YouTube comments
|
|
36
|
-
* - vision: Chat from vision (image)
|
|
37
|
-
*/
|
|
38
|
-
export type ChatType = 'chatForm' | 'youtube' | 'vision';
|
|
39
|
-
/**
|
|
40
|
-
* screenplay (text with emotion)
|
|
41
|
-
*/
|
|
42
|
-
export interface Screenplay {
|
|
43
|
-
text: string;
|
|
44
|
-
emotion?: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Speech synthesis options
|
|
48
|
-
*/
|
|
49
|
-
export interface SpeakOptions {
|
|
50
|
-
speed?: number;
|
|
51
|
-
pitch?: number;
|
|
52
|
-
intonation?: number;
|
|
53
|
-
volumeScale?: number;
|
|
54
|
-
}
|
package/dist/types/chat.js
DELETED
package/dist/types/chat.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/types/chat.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/types/mcp.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Context Protocol (MCP) related types
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* MCP server configuration for MCP connector
|
|
6
|
-
* This is a standard configuration format that may be used by multiple providers
|
|
7
|
-
*/
|
|
8
|
-
export interface MCPServerConfig {
|
|
9
|
-
type: 'url';
|
|
10
|
-
url: string;
|
|
11
|
-
name: string;
|
|
12
|
-
tool_configuration?: {
|
|
13
|
-
enabled?: boolean;
|
|
14
|
-
allowed_tools?: string[];
|
|
15
|
-
};
|
|
16
|
-
authorization_token?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Claude-specific MCP tool use block (internal type for Claude)
|
|
20
|
-
*/
|
|
21
|
-
export interface ClaudeMCPToolUseBlock {
|
|
22
|
-
type: 'mcp_tool_use';
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
server_name: string;
|
|
26
|
-
input: any;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Claude-specific MCP tool result block (internal type for Claude)
|
|
30
|
-
*/
|
|
31
|
-
export interface ClaudeMCPToolResultBlock {
|
|
32
|
-
type: 'mcp_tool_result';
|
|
33
|
-
tool_use_id: string;
|
|
34
|
-
is_error: boolean;
|
|
35
|
-
content: any[];
|
|
36
|
-
}
|
package/dist/types/mcp.js
DELETED
package/dist/types/mcp.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/types/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/types/toolChat.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export interface TextBlock {
|
|
2
|
-
type: 'text';
|
|
3
|
-
text: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ToolUseBlock<P = any> {
|
|
6
|
-
type: 'tool_use';
|
|
7
|
-
id: string;
|
|
8
|
-
name: string;
|
|
9
|
-
input: P;
|
|
10
|
-
}
|
|
11
|
-
export interface ToolResultBlock {
|
|
12
|
-
type: 'tool_result';
|
|
13
|
-
tool_use_id: string;
|
|
14
|
-
content: string;
|
|
15
|
-
}
|
|
16
|
-
export type CoreToolChatBlock = TextBlock | ToolUseBlock | ToolResultBlock;
|
|
17
|
-
export interface ToolChatCompletion<B = CoreToolChatBlock> {
|
|
18
|
-
blocks: B[];
|
|
19
|
-
stop_reason: 'tool_use' | 'end';
|
|
20
|
-
}
|
|
21
|
-
export type ToolChatBlock = CoreToolChatBlock;
|
|
22
|
-
export type ToolDefinition<P = any> = {
|
|
23
|
-
name: string;
|
|
24
|
-
description?: string;
|
|
25
|
-
parameters: {
|
|
26
|
-
type: 'object';
|
|
27
|
-
properties?: Record<string, {
|
|
28
|
-
type?: string;
|
|
29
|
-
description?: string;
|
|
30
|
-
enum?: any[];
|
|
31
|
-
items?: any;
|
|
32
|
-
required?: string[];
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
}>;
|
|
35
|
-
required?: string[];
|
|
36
|
-
[key: string]: any;
|
|
37
|
-
};
|
|
38
|
-
config?: {
|
|
39
|
-
timeoutMs?: number;
|
|
40
|
-
};
|
|
41
|
-
};
|
package/dist/types/toolChat.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toolChat.js","sourceRoot":"","sources":["../../src/types/toolChat.ts"],"names":[],"mappings":""}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP client options
|
|
3
|
-
*/
|
|
4
|
-
export interface HttpClientOptions {
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
timeout?: number;
|
|
7
|
-
retries?: number;
|
|
8
|
-
retryDelay?: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* HTTP error response
|
|
12
|
-
*/
|
|
13
|
-
export declare class HttpError extends Error {
|
|
14
|
-
status: number;
|
|
15
|
-
statusText: string;
|
|
16
|
-
body: string;
|
|
17
|
-
constructor(status: number, statusText: string, body: string);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Unified HTTP client for chat services
|
|
21
|
-
*/
|
|
22
|
-
export declare class ChatServiceHttpClient {
|
|
23
|
-
/**
|
|
24
|
-
* Make a POST request with common error handling
|
|
25
|
-
* @param url Request URL
|
|
26
|
-
* @param body Request body
|
|
27
|
-
* @param headers Request headers
|
|
28
|
-
* @param options Additional options
|
|
29
|
-
* @returns Response object
|
|
30
|
-
*/
|
|
31
|
-
static post(url: string, body: any, headers?: Record<string, string>, options?: HttpClientOptions): Promise<Response>;
|
|
32
|
-
/**
|
|
33
|
-
* Handle error response and throw appropriate error
|
|
34
|
-
* @param res Response object
|
|
35
|
-
* @returns Never (always throws)
|
|
36
|
-
*/
|
|
37
|
-
static handleErrorResponse(res: Response): Promise<never>;
|
|
38
|
-
/**
|
|
39
|
-
* Make a GET request (for fetching images, etc.)
|
|
40
|
-
* @param url Request URL
|
|
41
|
-
* @param headers Request headers
|
|
42
|
-
* @param options Additional options
|
|
43
|
-
* @returns Response object
|
|
44
|
-
*/
|
|
45
|
-
static get(url: string, headers?: Record<string, string>, options?: HttpClientOptions): Promise<Response>;
|
|
46
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP error response
|
|
3
|
-
*/
|
|
4
|
-
export class HttpError extends Error {
|
|
5
|
-
constructor(status, statusText, body) {
|
|
6
|
-
super(`HTTP ${status}: ${statusText}`);
|
|
7
|
-
this.status = status;
|
|
8
|
-
this.statusText = statusText;
|
|
9
|
-
this.body = body;
|
|
10
|
-
this.name = 'HttpError';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Unified HTTP client for chat services
|
|
15
|
-
*/
|
|
16
|
-
export class ChatServiceHttpClient {
|
|
17
|
-
/**
|
|
18
|
-
* Make a POST request with common error handling
|
|
19
|
-
* @param url Request URL
|
|
20
|
-
* @param body Request body
|
|
21
|
-
* @param headers Request headers
|
|
22
|
-
* @param options Additional options
|
|
23
|
-
* @returns Response object
|
|
24
|
-
*/
|
|
25
|
-
static async post(url, body, headers = {}, options = {}) {
|
|
26
|
-
const { timeout = 30000, retries = 0, retryDelay = 1000 } = options;
|
|
27
|
-
// Default headers
|
|
28
|
-
const defaultHeaders = {
|
|
29
|
-
'Content-Type': 'application/json',
|
|
30
|
-
};
|
|
31
|
-
const finalHeaders = { ...defaultHeaders, ...headers };
|
|
32
|
-
let lastError = null;
|
|
33
|
-
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
34
|
-
try {
|
|
35
|
-
const controller = new AbortController();
|
|
36
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
37
|
-
const response = await fetch(url, {
|
|
38
|
-
method: 'POST',
|
|
39
|
-
headers: finalHeaders,
|
|
40
|
-
body: typeof body === 'string' ? body : JSON.stringify(body),
|
|
41
|
-
signal: controller.signal,
|
|
42
|
-
});
|
|
43
|
-
clearTimeout(timeoutId);
|
|
44
|
-
if (!response.ok) {
|
|
45
|
-
const errorBody = await response.text();
|
|
46
|
-
throw new HttpError(response.status, response.statusText, errorBody);
|
|
47
|
-
}
|
|
48
|
-
return response;
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
lastError = error;
|
|
52
|
-
// Don't retry on client errors (4xx)
|
|
53
|
-
if (error instanceof HttpError &&
|
|
54
|
-
error.status >= 400 &&
|
|
55
|
-
error.status < 500) {
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
// Don't retry if aborted
|
|
59
|
-
if (error instanceof Error && error.name === 'AbortError') {
|
|
60
|
-
throw new Error(`Request timeout after ${timeout}ms`);
|
|
61
|
-
}
|
|
62
|
-
// Wait before retrying
|
|
63
|
-
if (attempt < retries) {
|
|
64
|
-
await new Promise((resolve) => setTimeout(resolve, retryDelay * (attempt + 1)));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
throw lastError || new Error('Request failed');
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Handle error response and throw appropriate error
|
|
72
|
-
* @param res Response object
|
|
73
|
-
* @returns Never (always throws)
|
|
74
|
-
*/
|
|
75
|
-
static async handleErrorResponse(res) {
|
|
76
|
-
const errorBody = await res.text();
|
|
77
|
-
throw new HttpError(res.status, res.statusText, errorBody);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Make a GET request (for fetching images, etc.)
|
|
81
|
-
* @param url Request URL
|
|
82
|
-
* @param headers Request headers
|
|
83
|
-
* @param options Additional options
|
|
84
|
-
* @returns Response object
|
|
85
|
-
*/
|
|
86
|
-
static async get(url, headers = {}, options = {}) {
|
|
87
|
-
const { timeout = 30000, retries = 0, retryDelay = 1000 } = options;
|
|
88
|
-
let lastError = null;
|
|
89
|
-
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
90
|
-
try {
|
|
91
|
-
const controller = new AbortController();
|
|
92
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
93
|
-
const response = await fetch(url, {
|
|
94
|
-
method: 'GET',
|
|
95
|
-
headers,
|
|
96
|
-
signal: controller.signal,
|
|
97
|
-
});
|
|
98
|
-
clearTimeout(timeoutId);
|
|
99
|
-
if (!response.ok) {
|
|
100
|
-
const errorBody = await response.text();
|
|
101
|
-
throw new HttpError(response.status, response.statusText, errorBody);
|
|
102
|
-
}
|
|
103
|
-
return response;
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
lastError = error;
|
|
107
|
-
// Don't retry on client errors (4xx)
|
|
108
|
-
if (error instanceof HttpError &&
|
|
109
|
-
error.status >= 400 &&
|
|
110
|
-
error.status < 500) {
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
// Don't retry if aborted
|
|
114
|
-
if (error instanceof Error && error.name === 'AbortError') {
|
|
115
|
-
throw new Error(`Request timeout after ${timeout}ms`);
|
|
116
|
-
}
|
|
117
|
-
// Wait before retrying
|
|
118
|
-
if (attempt < retries) {
|
|
119
|
-
await new Promise((resolve) => setTimeout(resolve, retryDelay * (attempt + 1)));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
throw lastError || new Error('Request failed');
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=chatServiceHttpClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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,YAAY,SAAS;oBAC1B,KAAK,CAAC,MAAM,IAAI,GAAG;oBACnB,KAAK,CAAC,MAAM,GAAG,GAAG,EAClB,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,yBAAyB;gBACzB,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,IAAI,CAAC,CAAC;gBACxD,CAAC;gBAED,uBAAuB;gBACvB,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC;oBACtB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAChD,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,SAAS,IAAI,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
declare const emotions: readonly ["happy", "sad", "angry", "surprised", "neutral"];
|
|
2
|
-
type EmotionType = (typeof emotions)[number];
|
|
3
|
-
/**
|
|
4
|
-
* Regular expressions for emotion tag parsing
|
|
5
|
-
*/
|
|
6
|
-
export declare const EMOTION_TAG_REGEX: RegExp;
|
|
7
|
-
export declare const EMOTION_TAG_CLEANUP_REGEX: RegExp;
|
|
8
|
-
/**
|
|
9
|
-
* Result of emotion extraction
|
|
10
|
-
*/
|
|
11
|
-
export interface EmotionExtractionResult {
|
|
12
|
-
emotion?: string;
|
|
13
|
-
cleanText: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Utility class for parsing and handling emotion tags in text
|
|
17
|
-
*/
|
|
18
|
-
export declare class EmotionParser {
|
|
19
|
-
/**
|
|
20
|
-
* Extract emotion from text and return clean text
|
|
21
|
-
* @param text Text that may contain emotion tags like [happy]
|
|
22
|
-
* @returns Object containing extracted emotion and clean text
|
|
23
|
-
*/
|
|
24
|
-
static extractEmotion(text: string): EmotionExtractionResult;
|
|
25
|
-
/**
|
|
26
|
-
* Check if an emotion is valid
|
|
27
|
-
* @param emotion Emotion string to validate
|
|
28
|
-
* @returns True if the emotion is valid
|
|
29
|
-
*/
|
|
30
|
-
static isValidEmotion(emotion: string): emotion is EmotionType;
|
|
31
|
-
/**
|
|
32
|
-
* Remove all emotion tags from text
|
|
33
|
-
* @param text Text containing emotion tags
|
|
34
|
-
* @returns Clean text without emotion tags
|
|
35
|
-
*/
|
|
36
|
-
static cleanEmotionTags(text: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Add emotion tag to text
|
|
39
|
-
* @param emotion Emotion to add
|
|
40
|
-
* @param text Text content
|
|
41
|
-
* @returns Text with emotion tag prepended
|
|
42
|
-
*/
|
|
43
|
-
static addEmotionTag(emotion: string, text: string): string;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Define emotion types and list locally to avoid dependency on voice package
|
|
2
|
-
const emotions = ['happy', 'sad', 'angry', 'surprised', 'neutral'];
|
|
3
|
-
/**
|
|
4
|
-
* Regular expressions for emotion tag parsing
|
|
5
|
-
*/
|
|
6
|
-
export const EMOTION_TAG_REGEX = /\[([a-z]+)\]/i;
|
|
7
|
-
export const EMOTION_TAG_CLEANUP_REGEX = /\[[a-z]+\]\s*/gi;
|
|
8
|
-
/**
|
|
9
|
-
* Utility class for parsing and handling emotion tags in text
|
|
10
|
-
*/
|
|
11
|
-
export class EmotionParser {
|
|
12
|
-
/**
|
|
13
|
-
* Extract emotion from text and return clean text
|
|
14
|
-
* @param text Text that may contain emotion tags like [happy]
|
|
15
|
-
* @returns Object containing extracted emotion and clean text
|
|
16
|
-
*/
|
|
17
|
-
static extractEmotion(text) {
|
|
18
|
-
const match = text.match(EMOTION_TAG_REGEX);
|
|
19
|
-
if (match) {
|
|
20
|
-
const emotion = match[1].toLowerCase();
|
|
21
|
-
const cleanText = text.replace(EMOTION_TAG_CLEANUP_REGEX, '').trim();
|
|
22
|
-
return {
|
|
23
|
-
emotion,
|
|
24
|
-
cleanText,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return { cleanText: text };
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Check if an emotion is valid
|
|
31
|
-
* @param emotion Emotion string to validate
|
|
32
|
-
* @returns True if the emotion is valid
|
|
33
|
-
*/
|
|
34
|
-
static isValidEmotion(emotion) {
|
|
35
|
-
return emotions.includes(emotion);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Remove all emotion tags from text
|
|
39
|
-
* @param text Text containing emotion tags
|
|
40
|
-
* @returns Clean text without emotion tags
|
|
41
|
-
*/
|
|
42
|
-
static cleanEmotionTags(text) {
|
|
43
|
-
return text.replace(EMOTION_TAG_CLEANUP_REGEX, '').trim();
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Add emotion tag to text
|
|
47
|
-
* @param emotion Emotion to add
|
|
48
|
-
* @param text Text content
|
|
49
|
-
* @returns Text with emotion tag prepended
|
|
50
|
-
*/
|
|
51
|
-
static addEmotionTag(emotion, text) {
|
|
52
|
-
return `[${emotion}] ${text}`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=emotionParser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emotionParser.js","sourceRoot":"","sources":["../../src/utils/emotionParser.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC;AAG5E;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AACjD,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AAU3D;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,IAAY;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAE5C,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACrE,OAAO;gBACL,OAAO;gBACP,SAAS;aACV,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,OAAe;QACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAc,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAY;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,IAAY;QAChD,OAAO,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ChatScreenplay } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Convert text to screenplay (text with emotion)
|
|
4
|
-
* @param text Original text (may contain emotion expressions like [happy])
|
|
5
|
-
* @returns Screenplay object with emotion and text separated
|
|
6
|
-
*/
|
|
7
|
-
export declare function textToScreenplay(text: string): ChatScreenplay;
|
|
8
|
-
/**
|
|
9
|
-
* Convert multiple texts to screenplay array
|
|
10
|
-
* @param texts Text array
|
|
11
|
-
* @returns Array of screenplay objects
|
|
12
|
-
*/
|
|
13
|
-
export declare function textsToScreenplay(texts: string[]): ChatScreenplay[];
|
|
14
|
-
/**
|
|
15
|
-
* Convert screenplay to text with emotion
|
|
16
|
-
* @param screenplay Screenplay object
|
|
17
|
-
* @returns Text with emotion (e.g. [happy] Hello)
|
|
18
|
-
*/
|
|
19
|
-
export declare function screenplayToText(screenplay: ChatScreenplay): string;
|
package/dist/utils/screenplay.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { EmotionParser } from './emotionParser';
|
|
2
|
-
/**
|
|
3
|
-
* Convert text to screenplay (text with emotion)
|
|
4
|
-
* @param text Original text (may contain emotion expressions like [happy])
|
|
5
|
-
* @returns Screenplay object with emotion and text separated
|
|
6
|
-
*/
|
|
7
|
-
export function textToScreenplay(text) {
|
|
8
|
-
const { emotion, cleanText } = EmotionParser.extractEmotion(text);
|
|
9
|
-
if (emotion) {
|
|
10
|
-
return {
|
|
11
|
-
emotion,
|
|
12
|
-
text: cleanText,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
return { text: cleanText };
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Convert multiple texts to screenplay array
|
|
19
|
-
* @param texts Text array
|
|
20
|
-
* @returns Array of screenplay objects
|
|
21
|
-
*/
|
|
22
|
-
export function textsToScreenplay(texts) {
|
|
23
|
-
return texts.map((text) => textToScreenplay(text));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Convert screenplay to text with emotion
|
|
27
|
-
* @param screenplay Screenplay object
|
|
28
|
-
* @returns Text with emotion (e.g. [happy] Hello)
|
|
29
|
-
*/
|
|
30
|
-
export function screenplayToText(screenplay) {
|
|
31
|
-
if (screenplay.emotion) {
|
|
32
|
-
return EmotionParser.addEmotionTag(screenplay.emotion, screenplay.text);
|
|
33
|
-
}
|
|
34
|
-
return screenplay.text;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=screenplay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screenplay.js","sourceRoot":"","sources":["../../src/utils/screenplay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO;YACL,OAAO;YACP,IAAI,EAAE,SAAS;SAChB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAA0B;IACzD,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ToolChatBlock } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Utility class for accumulating text in streaming chat responses
|
|
4
|
-
*/
|
|
5
|
-
export declare class StreamTextAccumulator {
|
|
6
|
-
/**
|
|
7
|
-
* Append text to the blocks array, merging with the last block if it's a text block
|
|
8
|
-
* @param blocks Array of chat blocks
|
|
9
|
-
* @param text Text to append
|
|
10
|
-
*/
|
|
11
|
-
static append(blocks: ToolChatBlock[], text: string): void;
|
|
12
|
-
/**
|
|
13
|
-
* Get the full concatenated text from all text blocks
|
|
14
|
-
* @param blocks Array of chat blocks
|
|
15
|
-
* @returns Concatenated text from all text blocks
|
|
16
|
-
*/
|
|
17
|
-
static getFullText(blocks: ToolChatBlock[]): string;
|
|
18
|
-
/**
|
|
19
|
-
* Add a text block without merging
|
|
20
|
-
* @param blocks Array of chat blocks
|
|
21
|
-
* @param text Text to add as a new block
|
|
22
|
-
*/
|
|
23
|
-
static addTextBlock(blocks: ToolChatBlock[], text: string): void;
|
|
24
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility class for accumulating text in streaming chat responses
|
|
3
|
-
*/
|
|
4
|
-
export class StreamTextAccumulator {
|
|
5
|
-
/**
|
|
6
|
-
* Append text to the blocks array, merging with the last block if it's a text block
|
|
7
|
-
* @param blocks Array of chat blocks
|
|
8
|
-
* @param text Text to append
|
|
9
|
-
*/
|
|
10
|
-
static append(blocks, text) {
|
|
11
|
-
if (!text)
|
|
12
|
-
return;
|
|
13
|
-
const lastBlock = blocks[blocks.length - 1];
|
|
14
|
-
if (lastBlock && lastBlock.type === 'text') {
|
|
15
|
-
lastBlock.text += text;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
blocks.push({ type: 'text', text });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get the full concatenated text from all text blocks
|
|
23
|
-
* @param blocks Array of chat blocks
|
|
24
|
-
* @returns Concatenated text from all text blocks
|
|
25
|
-
*/
|
|
26
|
-
static getFullText(blocks) {
|
|
27
|
-
return blocks
|
|
28
|
-
.filter((block) => block.type === 'text')
|
|
29
|
-
.map((block) => block.text)
|
|
30
|
-
.join('');
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Add a text block without merging
|
|
34
|
-
* @param blocks Array of chat blocks
|
|
35
|
-
* @param text Text to add as a new block
|
|
36
|
-
*/
|
|
37
|
-
static addTextBlock(blocks, text) {
|
|
38
|
-
if (!text)
|
|
39
|
-
return;
|
|
40
|
-
blocks.push({ type: 'text', text });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=streamTextAccumulator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"streamTextAccumulator.js","sourceRoot":"","sources":["../../src/utils/streamTextAccumulator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAChC;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,MAAuB,EAAE,IAAY;QACjD,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC5C,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3C,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,MAAuB;QACxC,OAAO,MAAM;aACV,MAAM,CACL,CAAC,KAAK,EAA2C,EAAE,CACjD,KAAK,CAAC,IAAI,KAAK,MAAM,CACxB;aACA,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;aAC1B,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,MAAuB,EAAE,IAAY;QACvD,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;CACF"}
|