@shytv/ai-chart 0.0.11 → 0.0.13
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/ai-chart.css +1 -1
- package/dist/ai-chart.es.index.js +4121 -3798
- package/dist/ai-chart.umd.index.mjs +26 -26
- package/dist/chat/ChatRuntimeProvider.d.ts +3 -2
- package/dist/components/tool-fallback.aui.d.ts +4 -4
- package/dist/constants/index.d.ts +2 -0
- package/dist/lib/composables/prism.d.ts +1 -2
- package/dist/services/chat-adapter.d.ts +62 -1
- package/dist/utils/index.d.ts +3 -0
- package/package.json +5 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { streamChat } from '../services/chat-adapter';
|
|
1
|
+
import { streamChat, IChartInfo } from '../services/chat-adapter';
|
|
2
2
|
type CustomEventHandler = NonNullable<Parameters<typeof streamChat>[0]["onCustomEvent"]>;
|
|
3
3
|
export interface ChatRuntimeProviderProps {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
token: string;
|
|
6
|
+
getChartInfo: () => IChartInfo;
|
|
6
7
|
onCustomEvent?: CustomEventHandler;
|
|
7
8
|
}
|
|
8
|
-
export declare function ChatRuntimeProvider({ children, token, onCustomEvent, }: ChatRuntimeProviderProps): import('react').JSX.Element;
|
|
9
|
+
export declare function ChatRuntimeProvider({ children, token, getChartInfo, onCustomEvent, }: ChatRuntimeProviderProps): import('react').JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -6,14 +6,14 @@ export type ToolFallbackRootProps = Omit<React.ComponentProps<typeof Collapsible
|
|
|
6
6
|
defaultOpen?: boolean;
|
|
7
7
|
};
|
|
8
8
|
declare function ToolFallbackRoot({ className, open: controlledOpen, onOpenChange: controlledOnOpenChange, defaultOpen, children, ...props }: ToolFallbackRootProps): import('react').JSX.Element;
|
|
9
|
-
declare function ToolFallbackTrigger({ toolName, status,
|
|
9
|
+
declare function ToolFallbackTrigger({ toolName, status, className, ...props }: React.ComponentProps<typeof CollapsibleTrigger> & {
|
|
10
10
|
toolName: string;
|
|
11
11
|
status?: ToolCallMessagePartStatus;
|
|
12
|
-
responseDeliveryStatus?: ToolCallMessagePart["responseDeliveryStatus"];
|
|
13
12
|
}): import('react').JSX.Element;
|
|
14
13
|
declare function ToolFallbackContent({ className, children, ...props }: React.ComponentProps<typeof CollapsibleContent>): import('react').JSX.Element;
|
|
15
|
-
declare function ToolFallbackArgs({
|
|
16
|
-
|
|
14
|
+
declare function ToolFallbackArgs({ toolName, args, className, ...props }: React.ComponentProps<"div"> & {
|
|
15
|
+
toolName: string;
|
|
16
|
+
args?: unknown;
|
|
17
17
|
}): import('react').JSX.Element;
|
|
18
18
|
declare const formatUnknownValue: (value: unknown, space?: number) => string;
|
|
19
19
|
declare function ToolFallbackResult({ result, className, ...props }: React.ComponentProps<"div"> & {
|
|
@@ -29,11 +29,72 @@ interface StreamChatOptions extends ChatAdapterOptions {
|
|
|
29
29
|
userMessage: ChatInputMessage;
|
|
30
30
|
abortSignal: AbortSignal;
|
|
31
31
|
token: string;
|
|
32
|
+
getChartInfo: () => IChartInfo;
|
|
33
|
+
onSuggestions?: (suggestions: {
|
|
34
|
+
title?: string;
|
|
35
|
+
prompt: string;
|
|
36
|
+
label?: string;
|
|
37
|
+
}[]) => void;
|
|
38
|
+
}
|
|
39
|
+
interface IChatMessage {
|
|
40
|
+
id: string;
|
|
41
|
+
role: "user";
|
|
42
|
+
parts: IChatMessagePart[];
|
|
43
|
+
metadata?: IChatMessageMetadata;
|
|
44
|
+
}
|
|
45
|
+
interface IChatMessagePart {
|
|
46
|
+
type: string;
|
|
47
|
+
text?: string;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
interface IChatMessageMetadata {
|
|
51
|
+
files?: unknown[];
|
|
52
|
+
typed?: boolean;
|
|
53
|
+
sentAt?: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface IEditorContext {
|
|
57
|
+
scriptId?: string;
|
|
58
|
+
script?: string;
|
|
59
|
+
valid?: boolean;
|
|
60
|
+
errors: unknown[];
|
|
61
|
+
warnings: unknown[];
|
|
62
|
+
}
|
|
63
|
+
export interface IChartIndicator {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
type: "indicator" | "strategy" | "library";
|
|
67
|
+
code?: string;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
export interface IChart {
|
|
71
|
+
index: number;
|
|
72
|
+
symbol: string;
|
|
73
|
+
timeframe: string;
|
|
74
|
+
chartType?: string;
|
|
75
|
+
indicators: IChartIndicator[];
|
|
76
|
+
timeZone: string;
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
export interface IChartContext {
|
|
80
|
+
layoutCount: string;
|
|
81
|
+
activeWindow: number;
|
|
82
|
+
charts: IChart[];
|
|
83
|
+
}
|
|
84
|
+
export interface IChartInfo {
|
|
85
|
+
editor: IEditorContext;
|
|
86
|
+
chartContext: IChartContext;
|
|
87
|
+
}
|
|
88
|
+
export interface IChatRequest extends IChartInfo {
|
|
89
|
+
message: IChatMessage;
|
|
90
|
+
conversationId: string;
|
|
91
|
+
runReports?: boolean;
|
|
92
|
+
trigger?: "submit-message" | "edit-message" | "regenerate";
|
|
32
93
|
}
|
|
33
94
|
/**
|
|
34
95
|
* 执行 SSE 请求。
|
|
35
96
|
*
|
|
36
97
|
* 每次 yield 返回当前完整的 assistant 消息 parts。
|
|
37
98
|
*/
|
|
38
|
-
export declare function streamChat({ userMessage, abortSignal, token, getConversationId, onConversationCreated, onCustomEvent, onEvent, }: StreamChatOptions): AsyncGenerator<ThreadAssistantMessagePart[]>;
|
|
99
|
+
export declare function streamChat({ userMessage, abortSignal, token, getChartInfo, getConversationId, onConversationCreated, onCustomEvent, onEvent, onSuggestions, }: StreamChatOptions): AsyncGenerator<ThreadAssistantMessagePart[]>;
|
|
39
100
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shytv/ai-chart",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/ai-chart.umd.index.mjs",
|
|
6
6
|
"module": "./dist/ai-chart.es.index.js",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"dev": "vite",
|
|
23
23
|
"build": "tsc -b && vite build",
|
|
24
24
|
"lint": "eslint .",
|
|
25
|
-
"preview": "vite preview"
|
|
25
|
+
"preview": "vite preview",
|
|
26
|
+
"push": "vite build && yalc push"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@ai-sdk/openai": "^4.0.109",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"typescript": "~5.9.3",
|
|
62
63
|
"typescript-eslint": "^8.72.0",
|
|
63
64
|
"vite": "^8.3.6",
|
|
64
|
-
"vite-plugin-dts": "^5.1.2"
|
|
65
|
+
"vite-plugin-dts": "^5.1.2",
|
|
66
|
+
"yalc": "^1.0.0-pre.53"
|
|
65
67
|
}
|
|
66
68
|
}
|