@amaster.ai/components-templates 1.4.0 → 1.4.2

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.
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from "react";
2
- import { IDisplayMode } from "../components/chat-display-mode-switcher";
2
+ import type { IDisplayMode } from "../types";
3
3
 
4
4
  const getStorageKey = () => `${location.hostname}-ai-assistant-display-mode`;
5
5
 
@@ -11,10 +11,11 @@ const i18nText = {
11
11
  zh: {
12
12
  greeting: "你好!我是你的AI助手,有什么可以帮你的吗?",
13
13
  processing: "正在处理中...",
14
+ assistantName: "AI助手",
14
15
  online: "在线",
15
16
  thinking: "思考中",
16
17
  thought: "思考过程",
17
- resetConversation: "开始新对话",
18
+ newConversation: "开始新对话",
18
19
  fullscreen: "全屏显示",
19
20
  exitFullscreen: "退出全屏",
20
21
  typePlaceholder: "输入消息...",
@@ -32,6 +33,7 @@ const i18nText = {
32
33
  },
33
34
  voiceInput: "语音输入",
34
35
  stopVoiceInput: "停止录音",
36
+ stopGenerating: "停止生成",
35
37
  voiceInputStatus: {
36
38
  idle: "点击开始语音输入",
37
39
  starting: "启动中",
@@ -50,6 +52,10 @@ const i18nText = {
50
52
  permissionDenied: "权限被拒绝,请检查浏览器权限设置",
51
53
  unknownError: "发生未知错误,请稍后再试",
52
54
  },
55
+ loadingHistory: "正在加载历史消息...",
56
+ loadMore: "下拉加载更多",
57
+ noMoreHistory: "没有更多历史消息了",
58
+ conversationDivider: "开始新对话",
53
59
  defaultRecommendedQuestions: [
54
60
  "你都有哪些技能?",
55
61
  "今天北京天气如何?",
@@ -59,10 +65,11 @@ const i18nText = {
59
65
  en: {
60
66
  greeting: "Hello! I'm your AI assistant. How can I help you today?",
61
67
  processing: "Processing...",
68
+ assistantName: "AI Assistant",
62
69
  online: "Online",
63
70
  thinking: "Thinking",
64
71
  thought: "Thought process",
65
- resetConversation: "Start a new chat",
72
+ newConversation: "Start a new chat",
66
73
  fullscreen: "Fullscreen",
67
74
  exitFullscreen: "Exit fullscreen",
68
75
  typePlaceholder: "Type a message...",
@@ -81,6 +88,7 @@ const i18nText = {
81
88
  },
82
89
  voiceInput: "Voice input",
83
90
  stopVoiceInput: "Stop recording",
91
+ stopGenerating: "Stop generating",
84
92
  voiceInputStatus: {
85
93
  idle: "Click to start voice input",
86
94
  starting: "Starting",
@@ -102,6 +110,10 @@ const i18nText = {
102
110
  "Permission denied, please check your browser permission settings",
103
111
  unknownError: "An unknown error occurred, please try again later",
104
112
  },
113
+ loadingHistory: "Loading history messages...",
114
+ loadMore: "Pull down to load more",
115
+ noMoreHistory: "No more history messages",
116
+ conversationDivider: "new conversation",
105
117
  defaultRecommendedQuestions: [
106
118
  "What can you do?",
107
119
  "What's the weather like in Beijing today?",
@@ -1,5 +1,4 @@
1
1
  import type React from "react";
2
- import { getText } from "./i18n";
3
2
  import type { InlineAIAssistantProps } from "./types";
4
3
  import ChatMessages from "./components/chat-messages";
5
4
  import ChatInput from "./components/chat-input";
@@ -15,25 +14,33 @@ const InlineAIAssistant: React.FC<InlineAIAssistantProps> = ({
15
14
  className,
16
15
  style,
17
16
  greeting,
17
+ recommends,
18
+ displayMode = "inline",
18
19
  }) => {
19
20
  const {
21
+ starting,
20
22
  conversations,
21
23
  isLoading,
24
+ isLoadingHistory,
25
+ historyState,
22
26
  inputValue,
23
27
  setInputValue,
24
28
  scrollAreaRef,
25
29
  messagesEndRef,
26
30
  sendMessage,
27
31
  reset,
32
+ startNewConversation,
33
+ cancelChat,
34
+ loadMoreHistory,
28
35
  } = useAssistantStore();
29
36
 
30
37
  const handleReset = () => {
31
- reset(greeting);
38
+ startNewConversation();
32
39
  };
33
40
 
34
41
  useEffect(() => {
35
- conversations.length === 0 && reset(greeting);
36
- }, [conversations.length, greeting]);
42
+ !starting && conversations.length === 0 && reset(greeting);
43
+ }, [starting, conversations.length, greeting, reset]);
37
44
 
38
45
  return (
39
46
  <div
@@ -44,31 +51,36 @@ const InlineAIAssistant: React.FC<InlineAIAssistantProps> = ({
44
51
  style={style}
45
52
  >
46
53
  {showBanner && (
47
- <ChatBanner
48
- text={bannerText}
49
- hidden={conversations.length > 0}
50
- />
54
+ <ChatBanner text={bannerText} hidden={conversations.length > 0} />
51
55
  )}
52
56
  <ChatMessages
53
57
  conversations={conversations}
54
58
  isLoading={isLoading}
59
+ isLoadingHistory={isLoadingHistory}
60
+ hasMoreHistory={historyState.hasMore}
55
61
  scrollAreaRef={scrollAreaRef}
56
62
  messagesEndRef={messagesEndRef}
63
+ onLoadMore={loadMoreHistory}
57
64
  className={showBanner ? "" : "flex-1"}
58
65
  />
59
66
 
60
67
  <ChatRecommends
61
68
  hidden={!conversations.length || isLoading}
62
69
  onSend={sendMessage}
70
+ data={recommends}
71
+ disabled={isLoading || starting}
63
72
  />
64
73
 
65
74
  <ChatInput
66
75
  conversations={conversations}
67
76
  isLoading={isLoading}
77
+ starting={starting}
68
78
  inputValue={inputValue}
69
79
  onInputChange={setInputValue}
70
80
  onSendMessage={sendMessage}
71
- onReset={handleReset}
81
+ onNew={handleReset}
82
+ onCancel={cancelChat}
83
+ displayMode={displayMode}
72
84
  />
73
85
  </div>
74
86
  );
@@ -44,6 +44,7 @@ export interface UIRenderMessage extends BaseMessage {
44
44
  };
45
45
  }
46
46
 
47
+
47
48
  export type MessagesItem =
48
49
  | TextMessage
49
50
  | ThoughtMessage
@@ -56,6 +57,11 @@ export interface Conversation {
56
57
  status: "submitted" | "working" | "completed" | "error";
57
58
  messages: MessagesItem[];
58
59
  lastUpdated: string;
60
+ historyId?: string;
61
+ system?: {
62
+ level: "newConversation";
63
+ content?: string;
64
+ }
59
65
  }
60
66
 
61
67
  export interface Position {
@@ -63,10 +69,20 @@ export interface Position {
63
69
  y: number;
64
70
  }
65
71
 
72
+
73
+ export type IDisplayMode =
74
+ | "fullscreen"
75
+ | "floating"
76
+ | "side-left"
77
+ | "side-right"
78
+ | "inline";
79
+
66
80
  export interface InlineAIAssistantProps {
67
81
  showBanner?: boolean;
68
82
  bannerText?: string;
69
83
  className?: string;
70
84
  style?: React.CSSProperties;
71
85
  greeting?: string;
86
+ recommends?: string[];
87
+ displayMode?: IDisplayMode;
72
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/components-templates",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Amaster component templates collection",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -9,8 +9,7 @@
9
9
  "./cli": "./packages/cli/dist/index.js"
10
10
  },
11
11
  "bin": {
12
- "@amaster.ai/components-templates": "./bin/amaster.js",
13
- "amaster-cli": "./packages/cli/dist/index.js"
12
+ "@amaster.ai/components-templates": "./bin/amaster.js"
14
13
  },
15
14
  "files": [
16
15
  "index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/cli",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Amaster CLI tool for component templates",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",