Skip to content

Commit

Permalink
fix: some bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
dolphin0618 committed Jan 9, 2025
1 parent 4a28dc1 commit 1a106cb
Show file tree
Hide file tree
Showing 22 changed files with 271 additions and 153 deletions.
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bisheng",
"version": "0.4.1",
"version": "0.4.1.2",
"private": true,
"dependencies": {
"@headlessui/react": "^2.0.4",
Expand Down
10 changes: 9 additions & 1 deletion src/frontend/public/locales/en/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,15 @@
"manageAppTemplates": "Manage Application Templates",
"provideSceneTemplates": "We provide scene templates for you to use and reference",
"noPermissionToPublish": "You do not have permission to publish this {{type}}, please contact the administrator to publish.",
"manageYourApplications": "Manage your applications on this page, including publishing, editing, etc."
"manageYourApplications": "Manage your applications on this page, including publishing, editing, etc.",
"workFlow": "Workflow",
"skillName": "Skill Name",
"pleaseFillIn": "Please fill in the {{labelName}} name",
"nameTooLong": "{{labelName}} name is too long, do not exceed 50 characters",
"addDescription": "Add some description to quickly let others understand your {{labelName}}",
"descriptionTooLong": "{{labelName}} description cannot exceed 200 characters",
"templateCreatedSuccessfully": "Template created successfully",
"workFlowName": "Workflow Name"
},
"tools": {
"addTool": "Add Tool",
Expand Down
11 changes: 10 additions & 1 deletion src/frontend/public/locales/en/flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"textInput": "Text Input",
"dropdown": "Dropdown",
"file": "File",
"text": "Text",
"displayName": "Display Name",
"variableName": "Variable Name",
"options": "Options",
Expand Down Expand Up @@ -153,5 +154,13 @@
"onlineVersionMessage": "The current version is online and cannot be modified. You can save the changes as a new version.",
"unsavedChangesMessage": "You have unsaved changes. Are you sure you want to leave?",
"runNode": "Run this node",
"copy": "Copy"
"copy": "Copy",
"cannotBeEmpty": "{{label}} cannot be empty",
"editReportTemplate": "Edit Report Template",
"nodeErrorMessage": "{{nodeName}} node error: {{varNameCn}} is invalid, possibly because the related node has been deleted or replaced. Please reassign the variable.",
"required": "Required",
"isRequired": "Is Required",
"documentKnowledgeBase": "Document Knowledge",
"temporarySessionFiles": "Temporary Files",
"storeFilesSentInCurrentSession": "Store files sent in the current session"
}
10 changes: 9 additions & 1 deletion src/frontend/public/locales/zh/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,15 @@
"manageAppTemplates": "管理应用模板",
"provideSceneTemplates": "我们提供场景模板供您使用和参考",
"noPermissionToPublish": "您没有权限上线此{{type}},请联系管理员上线。",
"manageYourApplications": "在此页面管理您的应用,对应用上下线、编辑等等"
"manageYourApplications": "在此页面管理您的应用,对应用上下线、编辑等等",
"workFlow": "工作流",
"skillName": "技能名称",
"pleaseFillIn": "请填写{{labelName}}名称",
"nameTooLong": "{{labelName}}名称过长,不要超过50字",
"addDescription": "加些描述能够快速让别人理解您创造的{{labelName}}",
"descriptionTooLong": "{{labelName}}描述不可超过 200 字",
"templateCreatedSuccessfully": "模板创建成功",
"workFlowName": "工作流名称"
},
"tools": {
"addTool": "添加工具",
Expand Down
11 changes: 10 additions & 1 deletion src/frontend/public/locales/zh/flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"textInput": "文本输入",
"dropdown": "下拉选项",
"file": "文件",
"text": "文本",
"displayName": "展示名称",
"variableName": "变量名称",
"options": "选项",
Expand Down Expand Up @@ -153,5 +154,13 @@
"onlineVersionMessage": "当前版本已上线不可修改,可另存为新版本保存修改内容",
"unsavedChangesMessage": "您有未保存的更改,确定要离开吗?",
"runNode": "运行此节点",
"copy": "复制"
"copy": "复制",
"cannotBeEmpty": "{{label}}不可为空",
"editReportTemplate": "编辑报告模板",
"nodeErrorMessage": "{{nodeName}}节点错误:{{varNameCn}}已失效,可能是相关节点已被删除或替换,请重新引用变量。",
"required": "不可为空",
"isRequired": "是否必填",
"documentKnowledgeBase": "文档知识库",
"temporarySessionFiles": "临时会话文件",
"storeFilesSentInCurrentSession": "存储当前会话中发送的文件"
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const useMessageStore = create<State & Actions>((set, get) => ({
}))
},
insetNodeRun(data) {
if (['input', 'output', 'condition'].includes(data.messages?.node_id.split('_'))) return
if (['input', 'output', 'condition'].includes(data.message?.node_id.split('_')[0])) return
set((state) => {
let newChat = cloneDeep(state.messages);
const { category, flow_id, chat_id, files, is_bot, liked, message, receiver, type, source, user_id } = data
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/src/pages/BuildPage/flow/FlowNode/RunLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,20 @@ export default function RunLog({ node, children }) {
node.group_params.forEach(group => {
group.params.forEach(param => {
if (Array.isArray(param.value) && param.value.some(el => newData[el.key])) {
// 尝试去value中匹配
// 尝试去value中匹配 (input-form; preset-quesitons)
param.value.forEach(value => {
if (!newData[value.key]) return
result[value.label] = newData[value.key];
result[value.label || value.key] = newData[value.key].value;
hasKeys.push(value.key)
})
} else if (newData[param.key] !== undefined) {
result[param.label || param.key] = newData[param.key];
result[param.label || param.key] = newData[param.key].value;
hasKeys.push(param.key)
} else if (param.key === 'tool_list') {
// tool
param.value.some(p => {
if (newData[p.tool_key] !== undefined) {
result[p.label] = newData[p.tool_key];
result[p.label] = newData[p.tool_key].value;
hasKeys.push(p.tool_key)
return true
}
Expand All @@ -120,7 +120,7 @@ export default function RunLog({ node, children }) {

for (let key in newData) {
if (!hasKeys.includes(key)) {
result[key] = newData[key];
result[key] = newData[key].value;
}
}
setData(result)
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/pages/BuildPage/flow/FlowNode/RunTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const RunTest = forwardRef((props, ref) => {
if (input.required && !input.value) {
message({
variant: "warning",
description: `${input.label} 不可为空`
description: `${input.label} ${t('required')}`
})
return true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Button } from '@/components/bs-ui/button';
import { Input } from '@/components/bs-ui/input';
import { generateUUID } from '@/components/bs-ui/utils';
import { Handle, Position } from '@xyflow/react';
import i18next from "i18next";
import { Edit, GripVertical, Trash2 } from 'lucide-react'; // 图标
import { useEffect, useRef, useState } from 'react';
import { useEffect, useState } from 'react';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import { Handle, Position } from '@xyflow/react';
import { useTranslation } from 'react-i18next';

interface Iprops {
Expand All @@ -21,9 +22,9 @@ interface Iprops {

// TODO 移动到业务组件
const itemNames = {
'select': "下拉选项",
'file': "文件",
'text': "文本"
'select': i18next.t('dropdown', { ns: 'flow' }),
'file': i18next.t('file', { ns: 'flow' }),
'text': i18next.t('dropdown', { ns: 'flow' })
}

export default function DragOptions({ edges = false, scroll = false, options, onEditClick, onChange }: Iprops) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function Form({ initialData, onSubmit, onCancel, existingOptions }) {
)} */}

<div className="flex items-center space-x-2">
<Label className="bisheng-label">是否必填</Label>
<Label className="bisheng-label">{t('isRequired')}</Label>
<Switch
checked={formData.isRequired}
onCheckedChange={(checked) => setFormData({ ...formData, isRequired: checked })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export default function KnowledgeQaSelectItem({ data, onChange, onValidate }) {
data.required && onValidate(() => {
if (!data.value.length) {
setError(true)
return data.label + '不可为空'
return data.label + ' ' + t('required')
}
setError(false)
return false
})
return () => onValidate(() => {})

return () => onValidate(() => { })
}, [data.value])

return <div className='node-item mb-4'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@ import { useTranslation } from "react-i18next";
import useFlowStore from "../../flowStore";
import { isVarInFlow } from "@/util/flowUtils";


const TabsHead = memo(({ tab, onChange }) => {
const { t } = useTranslation('flow');

return (
<Tabs defaultValue={tab} className="mb-2" onValueChange={onChange}>
<TabsList className="grid w-full grid-cols-2 py-1 max-w-80">
<TabsTrigger value="knowledge" className="text-xs">
{t('documentKnowledgeBase')}
</TabsTrigger>
<TabsTrigger value="tmp" className="text-xs">
{t('temporarySessionFiles')}
<QuestionTooltip content={t('storeFilesSentInCurrentSession')} />
</TabsTrigger>
</TabsList>
</Tabs>
);
});

return <Tabs defaultValue={tab} className="mb-2" onValueChange={onChange}>
<TabsList className="grid w-full grid-cols-2 py-1 max-w-80">
<TabsTrigger value="knowledge" className="text-xs">文档知识库</TabsTrigger>
<TabsTrigger value="tmp" className="text-xs">临时会话文件<QuestionTooltip content={'存储用户在当前会话中发送的文件,需要与输入节点(表单输入模式)搭配使用。'} /></TabsTrigger>
</TabsList>
</Tabs>
})

const enum KnowledgeType {
Knowledge = 'knowledge',
Expand Down Expand Up @@ -112,7 +122,7 @@ export default function KnowledgeSelectItem({ data, nodeId, onChange, onVarEvent
data.required && onValidate(() => {
if (!data.value.value.length) {
setError(true)
return data.label + '不可为空'
return data.label + ' ' + t('required')
}
setError(false)
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Label } from "@/components/bs-ui/label";
import Cascader from "@/components/bs-ui/select/cascader";
import { getAssistantModelList, getLlmDefaultModel, getModelListApi } from "@/controllers/API/finetune";
import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";

export default function ModelItem({ agent = false, data, onChange, onValidate }) {
const [options, setOptions] = useState<any[]>([])
const { t } = useTranslation()

useEffect(() => {
(agent ? getAssistantModelList() : getModelListApi()).then(res => {
Expand Down Expand Up @@ -61,7 +63,7 @@ export default function ModelItem({ agent = false, data, onChange, onValidate })
data.required && onValidate(() => {
if (!data.value) {
setError(true)
return data.label + '不可为空'
return data.label + ' ' + t('required')
}
setError(false)
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ const OutputItem = ({ nodeId, node, data, onChange, onValidate }) => {
}
};

const handleChangeType = (val) => {
setInteractionType(val);
if (interactionType === "choose" || val === "choose") {
const addNodeEvent = new CustomEvent("outputDelEdge", {
detail: { nodeId }
});
window.dispatchEvent(addNodeEvent);
}
}

const [error, setError] = useState(false);
useEffect(() => {
data.required &&
Expand All @@ -91,7 +101,7 @@ const OutputItem = ({ nodeId, node, data, onChange, onValidate }) => {
<RadioGroup
value={interactionType}
onValueChange={(val) => {
setInteractionType(val);
handleChangeType(val)
onChange({ type: val, value: "" });
setError(false);
}}
Expand Down
Loading

0 comments on commit 1a106cb

Please sign in to comment.