Skip to content

Commit

Permalink
Hotfix/0.4.1.2 (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
zgqgit authored Jan 9, 2025
2 parents 5082846 + 1a106cb commit b9f3555
Show file tree
Hide file tree
Showing 29 changed files with 280 additions and 159 deletions.
2 changes: 1 addition & 1 deletion src/backend/bisheng/api/services/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def run_once(cls, login_user: UserPayload, node_input: Dict[str, any], node_data
continue
if node_data.type == NodeType.RAG.value and one['key'] != 'retrieved_result' and one['type'] != 'variable':
continue
if node_data.type == NodeType.LLM.value and not one['key'].startswith('output'):
if node_data.type == NodeType.LLM.value and one['type'] != 'variable':
continue
if node_data.type == NodeType.AGENT.value and one['type'] not in ['tool', 'variable']:
continue
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bisheng/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_app_chat_list(*,
res_obj = PageList(list=[
AppChatList(user_name=user_map.get(one['user_id'], one['user_id']),
flow_name=flow_map[one['flow_id']].name if flow_map.get(one['flow_id']) else one['flow_id'],
flow_type=FlowType.ASSISTANT.value if assistant_map.get(one['flow_id'], None) else FlowType.FLOW.value,
flow_type=FlowType.ASSISTANT.value if assistant_map.get(one['flow_id'], None) else flow_map[one['flow_id']].flow_type,
**one) for one in res if flow_map.get(one['flow_id'])
],
total=count)
Expand Down
3 changes: 3 additions & 0 deletions src/backend/bisheng/worker/workflow/redis_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import uuid

from cachetools import TTLCache
from langchain_core.documents import Document
from loguru import logger

from bisheng.api.v1.schemas import ChatResponse
Expand Down Expand Up @@ -114,6 +115,8 @@ def save_chat_message(self, chat_response: ChatResponse, source_documents=None)
if source_documents:
result = {}
extra = {}
if isinstance(source_documents, Document):
result = source_documents
source, result = sync_judge_source(result, source_documents, self.chat_id, extra)
chat_response.source = source
chat_response.extra = json.dumps(extra, ensure_ascii=False)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bisheng/workflow/graph/graph_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def parse_fan_in_node(self, node_id: str):
no_wait_nodes = []
for one in source_ids:
# output节点有特殊处理逻辑
if one.startswith('output_'):
if one.startswith(('output_', 'condition_')):
continue
if one in all_next_nodes:
no_wait_nodes.append(one)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bisheng/workflow/nodes/input/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _run(self, unique_id: str):

def parse_log(self, unique_id: str, result: dict) -> Any:
return [
{"key": k, "value": v, "type": "variable"} for k, v in result.items()
{"key": f'{self.id}.{k}', "value": v, "type": "variable"} for k, v in result.items()
]

def parse_upload_file(self, key: str, value: str) -> dict | None:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bisheng/workflow/nodes/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def parse_log(self, unique_id: str, result: dict) -> Any:
if self._batch_variable_list:
ret.insert(0, {"key": "batch_variable", "value": self._batch_variable_list, "type": "params"})
for k, v in result.items():
ret.append({"key": k, "value": v, "type": "variable"})
ret.append({"key": f'{self.id}.{k}', "value": v, "type": "variable"})
return ret

def _run_once(self,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bisheng/workflow/nodes/output/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def parse_template_msg(self, msg: str):
node_id = one.split('.')[0]
# 引用qa知识库节点时,展示溯源情况
if node_id.startswith('qa_retriever'):
self._source_documents = self.graph_state.get_variable(node_id, 'retrieved_result')
self._source_documents = self.graph_state.get_variable(node_id, '$retrieved_result$')
var_map[one] = self.graph_state.get_variable_by_str(one)
msg = msg_template.format(var_map)
return msg
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 b9f3555

Please sign in to comment.