This commit is contained in:
zhangkai
2024-06-25 14:55:48 +08:00
parent 68c9acc85b
commit 8b8f4111e2
42 changed files with 159 additions and 103 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -8,12 +8,12 @@
<link rel="icon" href="/favicon.ico" />
<script src="/node_modules/ace-builds/src-min-noconflict/ace.js" type="text/javascript"></script>
<title>NPCs</title>
<script type="module" crossorigin src="/assets/index-a1de8ebc.js"></script>
<script type="module" crossorigin src="/assets/index-92a8c43f.js"></script>
<link rel="modulepreload" crossorigin href="/assets/acebuilds-fbc0ccc6.js">
<link rel="modulepreload" crossorigin href="/assets/reactflow-f4a25674.js">
<link rel="modulepreload" crossorigin href="/assets/reactdrop-c213a6b9.js">
<link rel="modulepreload" crossorigin href="/assets/reactflow-c250d835.js">
<link rel="modulepreload" crossorigin href="/assets/reactdrop-be699031.js">
<link rel="modulepreload" crossorigin href="/assets/pdfjs-36654f0a.js">
<link rel="stylesheet" href="/assets/index-e4f67020.css">
<link rel="stylesheet" href="/assets/index-29c2092e.css">
</head>
<body id='body' style="width: 100%; height:100%">

View File

@@ -14,8 +14,8 @@
"pleaseEnterAccount": "请填写账号",
"pleaseEnterPassword": "请填写密码",
"accountTooShort": "账号过短",
"passwordTooShort": "请填写密码,至少8位",
"passwordError": "密码必须包含大小写字母、数字和字符",
"passwordTooShort": "请填写密码,至少6位",
"passwordError": "密码必须包含字母、数字!",
"passwordMismatch": "两次密码不一致",
"registrationSuccess": "注册成功,请输入密码进行登录"
},

View File

@@ -14,8 +14,8 @@
"pleaseEnterAccount": "请填写账号",
"pleaseEnterPassword": "请填写密码",
"accountTooShort": "账号过短",
"passwordTooShort": "请填写密码,至少8位",
"passwordError": "密码必须包含大小写字母、数字和字符",
"passwordTooShort": "请填写密码,至少6位",
"passwordError": "密码必须包含字母、数字!",
"passwordMismatch": "两次密码不一致",
"registrationSuccess": "注册成功,请输入密码进行登录"
},
@@ -55,40 +55,40 @@
"language": "语言"
},
"skills": {
"manageTemplate": "管理能模板",
"createNew": "新建能",
"customSkills": "自定义能",
"manageTemplate": "管理能模板",
"createNew": "新建能",
"customSkills": "自定义能",
"chooseOnline": "选择上线版本",
"executionSteps": "能通过可视化的流程编排,明确任务执行步骤",
"executionSteps": "能通过可视化的流程编排,明确任务执行步骤",
"sceneTemplates": "我们提供场景模板供您使用和参考",
"manageProjects": "在此页面管理您的技能,对技能上下线、编辑等等",
"skillSearch": "搜索您需要的能",
"confirmDeleteSkill": "确认删除该能?",
"backToSkillList": "返回能列表",
"skillTemplateManagement": "能模板管理,模板对所有用户可见,支持拖拽排序、删除操作",
"manageProjects": "在此页面管理您的能力,对能力上下线、编辑等等",
"skillSearch": "搜索您需要的能",
"confirmDeleteSkill": "确认删除该能",
"backToSkillList": "返回能列表",
"skillTemplateManagement": "能模板管理,模板对所有用户可见,支持拖拽排序、删除操作",
"templateName": "模板名称",
"templateDescription": "模板描述",
"confirmText": "是否确认删除该能模板?",
"skillSettings": "能设置",
"confirmText": "是否确认删除该能模板?",
"skillSettings": "能设置",
"basicInfo": "基础信息",
"skillName": "能名称",
"skillName": "能名称",
"description": "描述",
"parameterInfo": "参数信息",
"advancedConfiguration": "高级配置",
"nextStep": "下一步,高级配置",
"skillNameRequired": "请填写能名称",
"skillNameTooLong": "能名称过长不要超过30字",
"skillNameRequired": "请填写能名称",
"skillNameTooLong": "能名称过长不要超过30字",
"skillNameExists": "该名称已存在",
"skillDescRequired": "请填写能描述",
"skillDescTooLong": "能描述过长不要超过200字",
"skillDescRequired": "请填写能描述",
"skillDescTooLong": "能描述过长不要超过200字",
"errorTitle": "关键信息有误",
"onlineFailure": "上线失败",
"onlineSuccessful": "上线成功",
"custom": "自定义",
"skillTemplate": "能模板",
"skillTemplate": "能模板",
"skillTemplateChoose": "您可以从这里挑选一个模板开始,或者自定义高级模板",
"createTemplate": "创建模板",
"createSuccessTitle": "能创建成功",
"createSuccessTitle": "能创建成功",
"createFailureTitle": "创建失败",
"createdBy": "创建用户",
"offline": "下线",
@@ -442,7 +442,7 @@
"build": {
"create": "创建",
"assistant": "NPC",
"skill": "能",
"skill": "能",
"tools": "工具",
"save": "保存",
"online": "上线",
@@ -455,7 +455,7 @@
"portraitOptimization": "NPC画像优化",
"automaticOptimization": "自动优化",
"createDescription": "通过描述角色和任务来创建你的NPC",
"nextDescription": "NPC可以调用多个能和工具",
"nextDescription": "NPC可以调用多个能和工具",
"searchAssistant": "搜索您需要的NPC",
"manageAssistant": "在此页面管理您的NPC对NPC上下线、编辑等等",
"establishAssistant": "创建NPC",
@@ -473,7 +473,7 @@
"guideReplaced": "引导词已替换",
"openingReplaced": "开场白已替换",
"toolsReplaced": "工具已替换",
"skillsReplaced": "能已替换",
"skillsReplaced": "能已替换",
"allReplaced": "已全部替换",
"basicConfiguration": "基础配置",
"modelConfiguration": "AI模型配置",
@@ -503,13 +503,13 @@
"addTool": "添加工具",
"search": "搜索",
"empty": "空空如也",
"onlineSA": "上线能&NPC",
"onlineSA": "上线能&NPC",
"params": "参数",
"added": "已添加",
"add": "添加",
"configurationUpdated": "配置已更新",
"addSkill": "添加能",
"createSkill": "创建能",
"addSkill": "添加能",
"createSkill": "创建能",
"nameRequired": "名称不可为空",
"nameMaxLength": "名称最多50个字符",
"descMaxLength": "最多1000个字符",

BIN
src/.DS_Store vendored

Binary file not shown.

BIN
src/assets/.DS_Store vendored

Binary file not shown.

BIN
src/assets/toolbar/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -9,6 +9,8 @@ import { useMessageStore } from "./messageStore";
import GuideQuestions from "./GuideQuestions";
import { ClearIcon } from "@/components/bs-icons/clear";
import duihua_send from "../../../assets/chat/duihua-send.png";
import { Button } from "@/components/bs-ui/button";
import { StopCircle } from "lucide-react";
export default function ChatInput({ clear, form, questions, inputForm, wsUrl, onBeforSend }) {
const { toast } = useToast()
@@ -22,7 +24,8 @@ export default function ChatInput({ clear, form, questions, inputForm, wsUrl, on
const { messages, chatId, createSendMsg, createWsMsg, updateCurrentMessage, destory, setShowGuideQuestion } = useMessageStore()
const currentChatIdRef = useRef(null)
const inputRef = useRef(null)
// 停止状态
const [isStop, setIsStop] = useState(true)
/**
* 记录会话切换状态,等待消息加载完成时,控制表单在新会话自动展开
*/
@@ -88,6 +91,7 @@ export default function ChatInput({ clear, form, questions, inputForm, wsUrl, on
// 锁定 input
setInputLock({ locked: true, reason: '' })
await createWebSocket(chatId)
console.log(wsMsg,inputKey);
sendWsMsg(wsMsg)
// 滚动聊天到底
@@ -96,7 +100,13 @@ export default function ChatInput({ clear, form, questions, inputForm, wsUrl, on
messageDom.scrollTop = messageDom.scrollHeight;
}
}
const stop = async () => {
const [wsMsg] = onBeforSend('', '')
wsMsg.action = "stop"
sendWsMsg(wsMsg)
// console.log(wsMsg);
// sendWsMsg(wsMsg)
}
const sendWsMsg = async (msg) => {
try {
wsRef.current.send(JSON.stringify(msg))
@@ -158,6 +168,7 @@ export default function ChatInput({ clear, form, questions, inputForm, wsUrl, on
ws.onerror = (ev) => {
wsRef.current = null
console.error('链接异常error', ev);
setIsStop(true)
toast({
title: `${t('chat.networkError')}:`,
variant: 'error',
@@ -178,8 +189,11 @@ export default function ChatInput({ clear, form, questions, inputForm, wsUrl, on
// 接受 ws 消息
const handleWsMessage = (data) => {
console.log(data)
if (Array.isArray(data) && data.length) return
if (data.type === 'start') {
if (data.type === "begin") {
setIsStop(false)
}else if (data.type === 'start') {
createWsMsg(data)
} else if (data.type === 'stream') {
updateCurrentMessage({
@@ -197,6 +211,7 @@ export default function ChatInput({ clear, form, questions, inputForm, wsUrl, on
liked: 0
}, data.type === 'end_cover')
} else if (data.type === "close") {
setIsStop(true)
setInputLock({ locked: false, reason: '' })
}
@@ -296,6 +311,9 @@ export default function ChatInput({ clear, form, questions, inputForm, wsUrl, on
}
}}
></textarea>
<div className=" absolute w-full flex justify-center bottom-32 pointer-events-none">
<Button className="rounded-full pointer-events-auto" variant="outline" disabled={isStop} onClick={() => { setIsStop(true); stop(); }}><StopCircle className="mr-2" />Stop</Button>
</div>
{/* <p className="w-[100%] text-center text-[#666666]">内容由AI生成仅供参考</p> */}
</div>
<p className="text-center text-sm pt-2 pb-4 text-gray-400">{appConfig.dialogTips}</p>

View File

@@ -3,6 +3,9 @@ import { WordIcon } from "@/components/bs-icons/office";
import { checkSassUrl } from "@/pages/ChatAppPage/components/FileView";
import { downloadFile } from "@/util/utils";
import { useTranslation } from "react-i18next";
import npcIcon from "../../../assets/npc/npcIcon.png";
import nengliIcon from "../../../assets/npc/nengliIcon.png";
import { TitleIconBg } from "../cardComponent";
// 颜色列表
const colorList = [
@@ -19,7 +22,7 @@ const colorList = [
"#95A5A6"
]
export default function FileBs({ data }) {
export default function FileBs({ data,flow_type }) {
const { t } = useTranslation()
const avatarColor = colorList[(data.sender?.split('').reduce((num, s) => num + s.charCodeAt(), 0) || 0) % colorList.length]
@@ -33,15 +36,16 @@ export default function FileBs({ data }) {
<div className="w-fit min-h-8 rounded-2xl px-6 py-4 max-w-[90%]">
{data.sender && <p className="text-primary text-xs mb-2" style={{ background: avatarColor }}>{data.sender}</p>}
<div className="flex gap-2 ">
<div className="w-6 h-6 min-w-6 flex justify-center items-center rounded-full" style={{ background: avatarColor }} ><AvatarIcon /></div>
{data.flow_id && <TitleIconBg className="w-[40px] h-[40px]" img={data.avatar_img} id={data.avatar_color ? data.avatar_color : data.flow_id} ><img src={data.avatar_img ? data.avatar_img : (flow_type == "assistant" ? npcIcon : nengliIcon)} alt="" /></TitleIconBg>}
{/* <div className="w-6 h-6 min-w-6 flex justify-center items-center rounded-full" style={{ background: avatarColor }} ><AvatarIcon /></div> */}
<div
className="flex gap-2 w-52 border border-gray-200 shadow-sm bg-gray-50 px-4 py-2 rounded-sm cursor-pointer"
className="flex gap-2 w-52 shadow-sm bg-[#1a1a1a] px-4 py-2 rounded-sm cursor-pointer"
onClick={() => handleDownloadFile(data.files[0])}
>
<div className="flex items-center"><WordIcon /></div>
<div className="flex items-center text-[#43AFD2]"><WordIcon /></div>
<div>
<h1 className="text-sm font-bold">{data.files[0]?.file_name}</h1>
<p className="text-xs text-gray-400 mt-1"></p>
<h1 className="text-sm font-bold text-[#43AFD2]">{data.files[0]?.file_name}</h1>
<p className="text-xs text-[#666] mt-1"></p>
</div>
</div>
</div>

View File

@@ -38,7 +38,7 @@ const colorList = [
"#95A5A6"
]
export default function MessageBs({ data, onUnlike = () => { }, onSource }: { data: ChatMessageType, onUnlike?: any, onSource?: any }) {
export default function MessageBs({ data, onUnlike = () => { }, flow_type, onSource }: { data: ChatMessageType, flow_type: string, onUnlike?: any, onSource?: any }) {
const avatarColor = colorList[
(data.sender?.split('').reduce((num, s) => num + s.charCodeAt(), 0) || 0) % colorList.length
]
@@ -87,7 +87,6 @@ export default function MessageBs({ data, onUnlike = () => { }, onSource }: { da
}
const chatId = useMessageStore(state => state.chatId)
console.log(data)
return <div className="flex w-full py-1">
<div className="w-fit max-w-[90%]">
{data.sender && <p className="text-gray-600 text-xs mb-2">{data.sender}</p>}
@@ -95,15 +94,15 @@ export default function MessageBs({ data, onUnlike = () => { }, onSource }: { da
{/* {(data.flow_id == "06b1d374-ba97-46e6-8782-c56dec8dcc17" || data.flow_id == "ed8e21f6-9757-43d0-b076-8c6e81bb0580") && <img src={robot2} className="w-[50px]" alt=""/>}
{data.flow_id == "ca214b41-2b73-4585-b172-bf1e546cf6ec" && <img src={robot3} className="w-[50px]" alt=""/>}
{(data.flow_id != "06b1d374-ba97-46e6-8782-c56dec8dcc17" && data.flow_id != "ed8e21f6-9757-43d0-b076-8c6e81bb0580" && data.flow_id != "ca214b41-2b73-4585-b172-bf1e546cf6ec") && <img src={robot} className="w-[50px]" alt=""/>} */}
{data.flow_id && <TitleIconBg className="w-[40px] h-[40px]" img={data.avatar_img} id={data.avatar_color ? data.avatar_color : data.flow_id} ><img src={data.avatar_img ? data.avatar_img : (data.flow_type == "assistant" ? npcIcon : nengliIcon)} alt="" /></TitleIconBg>}
{data.flow_id && <TitleIconBg className="w-[40px] h-[40px]" img={data.avatar_img} id={data.avatar_color ? data.avatar_color : data.flow_id} ><img src={data.avatar_img ? data.avatar_img : (flow_type == "assistant" ? npcIcon : nengliIcon)} alt="" /></TitleIconBg>}
<div ref={messageRef} className={`min-h-8 min-w-[110px] max-w-[50vw] ml-[10px] ${data.id && data.end && 'pb-8'}`}>
<div ref={messageRef} className={`min-h-8 min-w-[110px] max-w-[90%] ml-[10px] ${data.id && data.end && 'pb-8'}`}>
<div className="chat-start-zk relative">
{data.message.toString() ? mkdown : <span className="loading loading-ring loading-md"></span>}
{/* @user */}
{data.receiver && <p className="text-blue-500 text-sm">@ {data.receiver.user_name}</p>}
{/* 光标 */}
{data.message.toString() && !data.end && <div className="animate-cursor absolute w-2 h-5 ml-1 bg-gray-600" style={{ left: cursor.x, top: cursor.y }}></div>}
{/* {data.message.toString() && !data.end && <div className="animate-cursor absolute w-2 h-5 ml-1 bg-gray-600" style={{ left: cursor.x, top: cursor.y }}></div>} */}
</div>
{/* 赞 踩 */}

View File

@@ -10,7 +10,7 @@ import RunLog from "./RunLog";
import Separator from "./Separator";
import { useMessageStore } from "./messageStore";
export default function MessagePanne({ useName, guideWord, loadMore }) {
export default function MessagePanne({ useName, guideWord, loadMore, flow_type }) {
const { t } = useTranslation()
const { chatId, messages } = useMessageStore()
@@ -83,6 +83,7 @@ export default function MessagePanne({ useName, guideWord, loadMore }) {
return <MessageBs
key={msg.id}
data={msg}
flow_type={flow_type}
onUnlike={(chatId) => { thumbRef.current?.openModal(chatId) }}
onSource={(data) => { sourceRef.current?.openModal(data) }}
/>;
@@ -91,7 +92,7 @@ export default function MessagePanne({ useName, guideWord, loadMore }) {
case 'separator':
return <Separator key={msg.id} text={msg.message || t('chat.roundOver')} />;
case 'file':
return <FileBs key={msg.id} data={msg} />;
return <FileBs key={msg.id} data={msg} flow_type={flow_type}/>;
case 'runLog':
return <RunLog key={msg.id} data={msg} />;
default:

View File

@@ -34,13 +34,12 @@ export default function MessageUser({ useName, data }: { data: ChatMessageType }
{/* {chat.category === 'loading' && <span className="loading loading-spinner loading-xs mr-4 align-middle"></span>} */}
{msg}
</div>
<div className='chat-end-btn'>
{!Array.isArray(data.message.data) && <div className='chat-end-btn'>
{!running && <img src={btnEdit} onClick={() => handleResend(false)} className="w-[28px] cursor-pointer" alt=""/>}
{!running && <img src={btnReSend} onClick={() => handleResend(true)} className="w-[28px] cursor-pointer" alt=""/>}
{/* <img src={btnDel} className="w-[28px] cursor-pointer" alt=""/> */}
{/* {!showSearch && <Search size={18} className="cursor-pointer hover:text-blue-600 text-blue-400" onClick={() => onSearch(chat.message[chat.chatKey])}></Search>} */}
</div>
</div>}
</div>
{/* <p className="mr-[20px] text-[14px]">{userName}</p> */}
<img src={robotU} className="w-[50px]" alt=""/>

View File

@@ -1,10 +1,9 @@
import ChatInput from "./ChatInput";
import MessagePanne from "./MessagePanne";
export default function ChatComponent({ clear = false, questions = [], form = false, useName, inputForm = null, guideWord, wsUrl, onBeforSend, loadMore = () => { } }) {
export default function ChatComponent({ clear = false, questions = [], form = false, useName, inputForm = null, guideWord, wsUrl, onBeforSend, type, loadMore = () => { } }) {
return <div className="relative h-full">
<MessagePanne useName={useName} guideWord={guideWord} loadMore={loadMore}></MessagePanne>
<MessagePanne useName={useName} guideWord={guideWord} loadMore={loadMore} flow_type={type}></MessagePanne>
<ChatInput clear={clear} questions={questions} form={form} wsUrl={wsUrl} inputForm={inputForm} onBeforSend={onBeforSend} ></ChatInput>
</div>
};

View File

@@ -82,7 +82,6 @@ export const useMessageStore = create<State & Actions>((set, get) => ({
set({ showGuideQuestion: bln })
},
async loadHistoryMsg(flowid, chatId, flow_type) {
console.log(111)
const res = await getChatHistory(flowid, chatId, 30, 0, flow_type)
const msgs = handleHistoryMsg(res)
currentChatId = chatId
@@ -155,6 +154,7 @@ export const useMessageStore = create<State & Actions>((set, get) => ({
console.log('change updateCurrentMessage');
const messages = get().messages
const isRunLog = runLogsTypes.includes(wsdata.category);
console.log(wsdata,isRunLog,messages)
// run log类型存在嵌套情况使用 extra 匹配 currentMessage; 否则取最近
const currentMessageIndex = isRunLog ?
messages.findLastIndex((msg) => msg.extra === wsdata.extra)
@@ -173,11 +173,13 @@ export const useMessageStore = create<State & Actions>((set, get) => ({
}
messages[currentMessageIndex] = newCurrentMessage
console.log(newCurrentMessage)
// 会话特殊处理,兼容后端的缺陷
if (!isRunLog) {
// start - end 之间没有内容删除load
if (newCurrentMessage.end && !(newCurrentMessage.files.length || newCurrentMessage.thought || newCurrentMessage.message)) {
messages.pop()
// messages.pop()
console.log("删了")
}
// 无 messageid 删除
// if (newCurrentMessage.end && !newCurrentMessage.id) {

View File

@@ -62,10 +62,7 @@ export default function SkillChatSheet({ children, onSelect }) {
<span>
<span>
<div>
{/* <img src={robot} className="w-[160px]" alt=""/> */}
{(item.id == "06b1d374-ba97-46e6-8782-c56dec8dcc17" || item.id == "ed8e21f6-9757-43d0-b076-8c6e81bb0580") && <img src={robot2} className="w-[160px]" alt=""/>}
{item.id == "ca214b41-2b73-4585-b172-bf1e546cf6ec" && <img src={robot3} className="w-[160px]" alt=""/>}
{(item.id != "06b1d374-ba97-46e6-8782-c56dec8dcc17" && item.id != "ed8e21f6-9757-43d0-b076-8c6e81bb0580" && item.id != "ca214b41-2b73-4585-b172-bf1e546cf6ec") && <img src={robot} className="w-[160px]" alt=""/>}
<TitleIconBg className="w-[160px] h-[160px] min-w-[160px]" img={item.avatar_img} id={item.avatar_color ? item.avatar_color : item.id} ><img src={item.avatar_img ? item.avatar_img : (item.flow_type == "assistant" ? npcIcon : nengliIcon)} alt="" /></TitleIconBg>
</div>
</span>
</span>
@@ -100,12 +97,12 @@ export default function SkillChatSheet({ children, onSelect }) {
<div className="xinDuiHua-boxR">
{/* <img src={borderR} className="w-[30px] h-[100%]" alt="" /> */}
</div>
<div className="w-fit p-6">
<div className="w-[280px] p-6">
<SheetTitle></SheetTitle>
<SheetDescription className="text-[#999999]">使线NPC或能力</SheetDescription>
<SearchInput value={keyword} placeholder="搜索" className="my-6" onChange={(e) => setKeyword(e.target.value)} />
</div>
<div className="min-w-[696px] overflow-y-auto bg-[#000000] scrollbar-hide skillSheet">
<div className="w-[690px] overflow-y-auto bg-[#000000] scrollbar-hide skillSheet">
{/* {
options.length ? options.map((flow, i) => (
<CardComponent key={i}

View File

@@ -113,7 +113,7 @@ export default function SkillSheet({ select, children, onSelect }) {
<div className="xinDuiHua-boxR">
{/* <img src={borderR} className="w-[30px] h-[100%]" alt="" /> */}
</div>
<div className="p-6">
<div className="w-[280px] p-6">
<SheetTitle>{t("build.addSkill")}</SheetTitle>
<SearchInput
value={keyword}
@@ -126,7 +126,7 @@ export default function SkillSheet({ select, children, onSelect }) {
</Button> */}
<div className="w-[244px] h-[34px] flex items-center justify-center bg-[#FFD025] text-[#000] cursor-pointer" style={{borderRadius:"34px"}} onClick={toCreateFlow}>{t("build.createSkill")}</div>
</div>
<div className="min-w-[696px] overflow-y-auto bg-[#000000] scrollbar-hide skillSheet">
<div className="w-[690px] overflow-y-auto bg-[#000000] scrollbar-hide skillSheet">
{onlineFlows[0] ? (
// onlineFlows.map((flow, i) => (
// <CardComponent

View File

@@ -44,7 +44,7 @@ export default function ToolsSheet({ select, onSelect, children }) {
<div className="xinDuiHua-boxR">
{/* <img src={borderR} className="w-[30px] h-[100%]" alt="" /> */}
</div>
<div className="w-fit p-6">
<div className="w-[280px] p-6">
<SheetTitle>{t('build.addTool')}</SheetTitle>
<div className="relative mt-[14px]">
<img src={sousuo} className="absolute w-[14px] left-[14px] top-[10px]" alt="" />
@@ -83,7 +83,7 @@ export default function ToolsSheet({ select, onSelect, children }) {
</div>
</div>
</div>
<div className="flex-1 bg-[#121212] p-5 pt-12 h-full overflow-auto scrollbar-hide">
<div className="w-[690px] flex-1 bg-[#121212] p-5 pt-12 h-full overflow-auto scrollbar-hide">
<Accordion type="single" collapsible className="w-full">
{
options.length ? options.map(el => (

View File

@@ -5,6 +5,6 @@ export const WordIcon = forwardRef<
SVGSVGElement & { className: any },
React.PropsWithChildren<{ className?: string }>
>(({ className, ...props }, ref) => {
const _className = 'transition text-gray-950 ' + (className || '')
const _className = 'transition text-[#43AFD2] ' + (className || '')
return <Word ref={ref} {...props} className={_className} />;
});

View File

@@ -36,7 +36,7 @@ const DialogContent = React.forwardRef<
<DialogPrimitive.Content
ref={ref}
className={cname(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-5 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-[#262626] p-5 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
@@ -86,7 +86,7 @@ const DialogTitle = React.forwardRef<
<DialogPrimitive.Title
ref={ref}
className={cname(
"text-base font-semibold leading-none tracking-tight",
"text-base font-semibold leading-none tracking-tight text-[#FFFFFF]",
className
)}
{...props}
@@ -100,7 +100,7 @@ const DialogDescription = React.forwardRef<
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
className={cname("text-sm text-muted-foreground", className)}
className={cname("text-sm text-[#999]", className)}
{...props}
/>
))

View File

@@ -79,7 +79,7 @@ const SelectContent = React.forwardRef<
<SelectPrimitive.Content
ref={ref}
className={cname(
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-[#DEE3EF] bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md box-shadow border-[#DEE3EF] bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
className

View File

@@ -87,7 +87,8 @@ const TableCell = React.forwardRef<
<td
ref={ref}
className={cname(
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] bg-[#1a1a1a] first:rounded-l-md last:rounded-r-md group-odd:bg-[#1a1a1a] group-hover:bg-[#1a1a1a]",
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] bg-[#2B2B2B] first:rounded-l-md last:rounded-r-md group-odd:bg-[#1a1a1a]",
// group-hover:bg-[#1a1a1a]
className
)}
{...props}

View File

@@ -18,7 +18,7 @@ const TooltipContent = React.forwardRef<
ref={ref}
sideOffset={sideOffset}
className={cname(
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"z-50 overflow-hidden rounded-md bg-[#1a1a1a] px-3 py-1.5 text-xs text-[#ccc] animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}

View File

@@ -327,10 +327,9 @@ export interface MessageDB {
type: string;
update_time: string;
user_id: number;
flow_type: string;
}
export async function getChatHistory(flowId: string, chatId: string, pageSize: number, id?: number, flow_type: string): Promise<MessageDB[]> {
export async function getChatHistory(flowId: string, chatId: string, pageSize: number, id: number, flow_type: string): Promise<MessageDB[]> {
return await axios.get(`/api/v1/chat/history?flow_id=${flowId}&chat_id=${chatId}&page_size=${pageSize}&id=${id || ''}&flow_type=${flow_type}`);
}

BIN
src/pages/.DS_Store vendored

Binary file not shown.

View File

@@ -58,7 +58,6 @@ export default function ChatPanne({ customWsHost = '', data }) {
useEffect(() => {
return destroy
}, [])
console.log(type)
const init = async () => {
if (type === 'flow') {
setAssistant(null)
@@ -93,6 +92,7 @@ export default function ChatPanne({ customWsHost = '', data }) {
const getWsParamData = (action, msg) => {
if (type === 'flow') {
const _flow = flowRef.current
console.log(_flow)
let inputs = tabsState[_flow.id].formKeysData.input_keys;
const input = inputs.find((el: any) => !el.type)
const inputKey = input ? Object.keys(input)[0] : '';
@@ -386,7 +386,8 @@ export default function ChatPanne({ customWsHost = '', data }) {
guideWord={flow.guide_word}
wsUrl={wsUrl}
onBeforSend={getWsParamData}
loadMore={() => loadMoreHistoryMsg(flow.id)}
loadMore={() => loadMoreHistoryMsg(flow.id,"flow")}
type={type}
inputForm={flowSate.isForm ? <ChatReportForm flow={flow} onStart={sendReport} /> : null}
/>
{/* <div ref={messagesRef} className={`chat-panne h-full overflow-y-scroll no-scrollbar px-[35px] ${isRoom || isReport ? 'pb-0' : 'pb-0'}`}>
@@ -424,7 +425,8 @@ export default function ChatPanne({ customWsHost = '', data }) {
guideWord={assistantState.guide_word}
wsUrl={wsUrl}
onBeforSend={getWsParamData}
loadMore={() => loadMoreHistoryMsg(assistant.id)}
loadMore={() => loadMoreHistoryMsg(assistant.id,"assistant")}
type={type}
inputForm={null}
/>
</div>

View File

@@ -67,7 +67,7 @@ const ChatReportForm = forwardRef(({ type = 'chat', vid = 0, flow, onStart }, re
return <div className="flex flex-col gap-6 rounded-xl p-4 ">
<div className="max-h-[520px] overflow-y-auto">
{items.map((item, i) => <div key={item.id} className="w-full text-sm">
{items.map((item, i) => <div key={item.id} className="w-full text-sm text-[#fff]">
{item.name}
<span className="text-status-red">{item.required ? " *" : ""}</span>
<div className="mt-2">

View File

@@ -57,7 +57,7 @@ export default function ChatPanne({ customWsHost = '', data }) {
setAssistant(null)
const _flow = await getFlowApi(id)
await build(_flow, chatId)
loadHistoryMsg(_flow.id, chatId)
loadHistoryMsg(_flow.id, chatId, type)
flowRef.current = _flow
setFlow(_flow)
changeChatId(chatId) // ws
@@ -65,7 +65,7 @@ export default function ChatPanne({ customWsHost = '', data }) {
flowRef.current = null
setFlow(null)
const _assistant = await loadAssistantState(id)
loadHistoryMsg(_assistant.id, chatId)
loadHistoryMsg(_assistant.id, chatId, type)
setAssistant(_assistant)
changeChatId(chatId) // ws
}
@@ -370,7 +370,7 @@ export default function ChatPanne({ customWsHost = '', data }) {
guideWord={flow.guide_word}
wsUrl={wsUrl}
onBeforSend={getWsParamData}
loadMore={() => loadMoreHistoryMsg(flow.id)}
loadMore={() => loadMoreHistoryMsg(flow.id, type)}
inputForm={flowSate.isForm ? <ChatReportForm flow={flow} onStart={sendReport} /> : null}
/>
{/* <div ref={messagesRef} className={`chat-panne h-full overflow-y-scroll no-scrollbar px-[35px] ${isRoom || isReport ? 'pb-0' : 'pb-0'}`}>

View File

@@ -42,7 +42,7 @@ const Cell = forwardRef((props, ref) => {
remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[rehypeMathjax]}
linkTarget="_blank"
className="bs-mkdown inline-block break-all max-w-full text-sm text-[#111]"
className="bs-mkdown inline-block break-all max-w-full text-sm text-[#fff]"
components={{
code: ({ node, inline, className, children, ...props }) => {
if (children.length) {

View File

@@ -39,7 +39,7 @@ export default function Component({ compId, options, disables, version, classNam
<SelectItem key={vs.id} value={vs.id} textValue={'vs.name'} disabled={disables.includes(vs.id)}>
<div className="flex justify-between w-64">
<span className="w-36 overflow-hidden text-ellipsis whitespace-nowrap">{vs.name}</span>
<span className="text-xs text-muted-foreground">{vs.update_time.replace('T', ' ').substring(0, 16)}</span>
<span className="text-xs text-[#999999]">{vs.update_time.replace('T', ' ').substring(0, 16)}</span>
</div>
</SelectItem>
))
@@ -68,7 +68,7 @@ export default function Component({ compId, options, disables, version, classNam
<SelectItem key={vs.id} value={vs.id} textValue={'vs.name'} disabled={disables.includes(vs.id)}>
<div className="flex justify-between w-64">
<span className="w-36 overflow-hidden text-ellipsis whitespace-nowrap text-left">{vs.name}</span>
<span className="text-xs text-muted-foreground">{vs.update_time.replace('T', ' ').substring(0, 16)}</span>
<span className="text-xs text-[#999999]">{vs.update_time.replace('T', ' ').substring(0, 16)}</span>
</div>
</SelectItem>
))

View File

@@ -20,9 +20,9 @@ export default function RunForm({ show, flow, onChangeShow, onSubmit }) {
}
<DialogFooter>
<DialogClose>
<Button variant="outline" className="px-11" type="button" onClick={onChangeShow}></Button>
<Button variant="outline" className="px-11 baogao-btn baogao-btn1" type="button" onClick={onChangeShow}></Button>
</DialogClose>
<Button type="submit" className="px-11" onClick={handleSubmit}></Button>
<Button type="submit" className="px-11 baogao-btn baogao-btn2" onClick={handleSubmit}></Button>
</DialogFooter>
</DialogContent>
};

View File

@@ -186,7 +186,7 @@ export default function RunTest({ nodeId }) {
<TableCell>
<div className="flex items-center gap-2 font-medium">
<Input
className="npcInput1"
className="npcInput4"
disabled={['all', 'row'].includes(runningType)}
placeholder={t('test.testCases')}
value={question.q}
@@ -226,7 +226,7 @@ export default function RunTest({ nodeId }) {
{questions.length < 20 && <TableCell>
<div className="flex items-center gap-2 font-medium min-w-52">
<Input
className="npcInput1"
className="npcInput4"
placeholder={t('test.testCases')}
onKeyDown={(e) => {
if (e.key === 'Enter') {

View File

@@ -33,7 +33,7 @@ export default function index(params) {
addEmptyVersionFlow()
}
console.log('mulitVersionFlow', mulitVersionFlow);
// console.log('mulitVersionFlow', mulitVersionFlow);
return <div className="bg-[#1A1A1A] h-full relative">

View File

@@ -46,7 +46,7 @@ export default function Header({ flow }) {
const { reactFlowInstance } = useContext(typesContext);
const isPending = tabsState[flow.id]?.isPending;
console.log(isPending)
// console.log(isPending)
const { openPopUp } = useContext(PopUpContext);
// 记录快照
const { takeSnapshot } = useContext(undoRedoContext);
@@ -167,17 +167,17 @@ export default function Header({ flow }) {
handleChangeVersion(vid)
}} className="gap-0">
{versions.map((vers, index) => (
<div key={vers.id} className="group flex items-center gap-4 px-4 py-2 cursor-pointer hover:bg-gray-100 border-b">
<div key={vers.id} className="group flex items-center gap-4 px-4 py-2 cursor-pointer hover:bg-[#2b2b2b] border-b border-[#333]">
<RadioGroupItem value={vers.id + ''} />
<div className="w-[198px]">
<TextInput
className="h-[30px]"
className="h-[30px] npcInput1"
type="hover"
value={vers.name}
maxLength={30}
onSave={val => changeName(vers.id, val)}
></TextInput>
<p className="text-sm text-muted-foreground mt-2">{vers.update_time.replace('T', ' ').substring(0, 16)}</p>
<p className="text-sm text-[#999] mt-2">{vers.update_time.replace('T', ' ').substring(0, 16)}</p>
</div>
{
// 最后一个 V0 版本和当前选中版本不允许删除

View File

@@ -13,7 +13,7 @@ const SelectComp = ({ value, onChange = (id) => { }, data, disabled = false }) =
}
return <Select value={value} onValueChange={handleChange} disabled={disabled}>
<SelectTrigger className="w-[61px] h-[27px] SelectTrigger">
<SelectTrigger className="w-[75px] h-[27px] SelectTrigger">
<SelectValue />
</SelectTrigger>
<SelectContent>

View File

@@ -318,7 +318,7 @@ const EditTool = forwardRef((props: any, ref) => {
<div className="xinDuiHua-boxR">
{/* <img src={borderR} className="w-[30px] h-[100%]" alt="" /> */}
</div>
<div className="w-[800px] pt-[10px]">
<div className="w-[770px] pt-[10px]">
<SheetHeader>
<SheetTitle>{delShow ? t('edit') : t('create')}</SheetTitle>
</SheetHeader>

View File

@@ -52,6 +52,7 @@ export default function TestChat({ assisId, guideQuestion }) {
guideWord=''
wsUrl={wsUrl}
onBeforSend={getWsParamData}
type="assistant"
></ChatComponent>
</div>
};

View File

@@ -188,7 +188,7 @@ export default function l2Edit() {
uploadNpcHeaderLibFileWithProgress(file, (progress) => { }).then(res => {
// isSSO ? uploadFileWithProgress(file, (progress) => { }).then(res => {
setLoading(false);
// console.log(res)
console.log(res,flow)
// if (typeof res === 'string') return setErrorData({ title: "Error", list: [res] })
// const { file_path } = res;
setAvatar_img(res);
@@ -257,7 +257,7 @@ export default function l2Edit() {
<div className="flex items-center ml-[7px] mt-[10px]">
{/* {flow && avatar_img ? <img src={flow.avatar_img} className="w-[41px] h-[41px] cursor-pointer" style={{borderRadius:"7px"}} onClick={handleButtonClick} alt="" /> : <TitleIconBg className="w-[41px] h-[41px] min-w-[41px]" img={avatar_img} id={avatar_color} ><img onClick={handleButtonClick} src={nengliIcon} alt="" /></TitleIconBg>} */}
{/* {flow && !flow.avatar_img && flow.avatar_color ? <TitleIconBg className="w-[41px] h-[41px] min-w-[41px]" id={randomNum} ><img onClick={handleButtonClick} src={nengliIcon} alt="" /></TitleIconBg> : <img src={logo} className="w-[41px] h-[41px]" onClick={handleButtonClick} alt="" />} */}
<TitleIconBg className="w-[41px] h-[41px] min-w-[41px]" img={avatar_img} id={avatar_color} ><img onClick={handleButtonClick} src={flow && avatar_img ? avatar_img : nengliIcon} alt="" /></TitleIconBg>
<TitleIconBg className="w-[41px] h-[41px] min-w-[41px]" img={avatar_img} id={avatar_color} ><img onClick={handleButtonClick} src={avatar_img ? avatar_img : nengliIcon} alt="" /></TitleIconBg>
<div className="flex items-center justify-center ml-[20px] w-[95px] h-[27px] bg-[#333333] cursor-pointer" style={{borderRadius:"14px"}} onClick={() => setAvatar_img("")}>
<img src={huifumoren} className="w-[12px] h-[11px]" alt="" />

View File

@@ -72,8 +72,8 @@ export const LoginPage = () => {
const [mail, pwd, apwd] = [mailRef.current.value, pwdRef.current.value, agenPwdRef.current.value]
if (!mail) error.push(t('login.pleaseEnterAccount'))
if (mail.length < 3) error.push(t('login.accountTooShort'))
if (!/.{8,}/.test(pwd)) error.push(t('login.passwordTooShort'))
if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/.test(pwd)) error.push(t('login.passwordError'))
if (!/.{6,}/.test(pwd)) error.push(t('login.passwordTooShort'))
if (!/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,}$/.test(pwd)) error.push(t('login.passwordError'))
if (pwd !== apwd) error.push(t('login.passwordMismatch'))
if (captchaData.user_capthca && !captchaRef.current.value) error.push(t('login.pleaseEnterCaptcha'))
if (error.length) return setErrorData({

View File

@@ -337,6 +337,10 @@
background: url("../assets/toolbar/copy.png") no-repeat center/contain!important;
}
&.version-icon {
background: url("../assets/toolbar/version.png") no-repeat center/contain!important;
}
&.config-icon {
background: url("../assets/toolbar/config.png") no-repeat center/contain!important;
}

View File

@@ -648,6 +648,7 @@
border: 1px solid #FFD025;
}
.selectNpcFlexbox{
height: 100%;
display: block;
padding-bottom: 14px;
>div:nth-of-type(2){
@@ -3960,6 +3961,24 @@
outline: 1px solid #997e1f!important;
}
}
.npcInput4{
background: #000000!important;
border-radius: 7px!important;
outline: none!important;
--tw-ring-color:none!important;
border: none!important;
--tw-ring-offset-color:none!important;
color: #fff!important;
&::-webkit-input-placeholder{
color: #666!important;
}
// outline: #997e1f;
&:focus{
// border: none!important;
outline: 1px solid #997e1f!important;
}
}
.questionTextarea{
width: 95%!important;
margin-left: 2.5%;
@@ -4147,7 +4166,7 @@
}
}
.yichu{
width: calc(100% - 110px); /* 定义容器宽度 */
width: calc(100% - 130px); /* 定义容器宽度 */
white-space: nowrap; /* 确保文本在一行内显示 */
overflow: hidden; /* 隐藏溢出的内容 */
text-overflow: ellipsis; /* 使用省略号表示文本溢出 */
@@ -4155,3 +4174,6 @@
.box-shadow{
box-shadow: 0px 0px 4px 0px rgba(255,255,255,0.5)!important;
}
.input-dialog{
color: #999999;
}

View File

@@ -16,4 +16,10 @@ export type ChatMessageType = {
noAccess?: boolean;
user_name: string;
at?: string;
/** 用户名 */
sender?: string;
/** @某人 */
receiver?: any;
liked?: boolean;
extra?: string;
};

View File

@@ -724,7 +724,8 @@ export function validateSelection(
(n) => !selection.edges.some((e) => e.source === n.id)
).length > 1
) {
errorsArray.push("Please select only one node with free outputs");
errorsArray.push("请仅选择一个具有自由输出的节点");
// errorsArray.push("Please select only one node with free outputs");
}
// check if there is any node that does not have any connection
@@ -735,7 +736,8 @@ export function validateSelection(
!selection.edges.some((edge) => edge.source === node.id)
)
) {
errorsArray.push("Please select only nodes that are connected");
errorsArray.push("请仅选择已连接的节点");
// errorsArray.push("Please select only nodes that are connected");
}
return errorsArray;
}