Skip to content

Commit d0bcfe5

Browse files
authored
Feat/2.3.0 beta4 (#1861)
2 parents f69a87a + 8e1632a commit d0bcfe5

31 files changed

Lines changed: 475 additions & 90 deletions

File tree

docker/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ services:
4040

4141
backend:
4242
container_name: bisheng-backend
43-
image: dataelement/bisheng-backend:v2.3.0-beta3
43+
image: dataelement/bisheng-backend:v2.3.0-beta4
4444
ports:
4545
- "7860:7860"
4646
environment:
@@ -78,7 +78,7 @@ services:
7878

7979
backend_worker:
8080
container_name: bisheng-backend-worker
81-
image: dataelement/bisheng-backend:v2.3.0-beta3
81+
image: dataelement/bisheng-backend:v2.3.0-beta4
8282
environment:
8383
TZ: Asia/Shanghai
8484
BS_MILVUS_CONNECTION_ARGS: '{"host":"milvus","port":"19530","user":"","password":"","secure":false}'
@@ -109,7 +109,7 @@ services:
109109

110110
frontend:
111111
container_name: bisheng-frontend
112-
image: dataelement/bisheng-frontend:v2.3.0-beta3
112+
image: dataelement/bisheng-frontend:v2.3.0-beta4
113113
ports:
114114
- "3001:3001"
115115
environment:

src/backend/bisheng/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
try:
99
# 通过ci去自动修改
10-
__version__ = '2.3.0-beta3'
10+
__version__ = '2.3.0-beta4'
1111
except metadata.PackageNotFoundError:
1212
# Case where package metadata is not available.
1313
__version__ = ''

src/backend/bisheng/api/v1/linsight.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ async def linsight_file_download(
125125
raise UnAuthorizedError()
126126

127127
minio_client = await get_minio_storage()
128+
file_url = file_url.lstrip("/")
128129
if file_url.startswith(minio_client.bucket):
129130
file_url = file_url[len(minio_client.bucket) + 1:]
130131
file_share_url = await minio_client.get_share_link(file_url)

src/backend/bisheng/open_endpoints/api/endpoints/workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
@router.post('/invoke')
3232
async def invoke_workflow(request: Request,
3333
workflow_id: UUID = Body(..., description='工作流唯一ID'),
34+
override: Optional[dict] = Body(default=None, description='override node params'),
3435
stream: Optional[bool] = Body(default=True, description='是否流式调用'),
3536
user_input: Optional[dict] = Body(default=None, description='用户输入', alias='input'),
3637
message_id: Optional[int] = Body(default=None, description='消息ID'),
@@ -61,7 +62,7 @@ async def invoke_workflow(request: Request,
6162
status_info = workflow.get_workflow_status()
6263
if not status_info:
6364
# 初始化工作流
64-
workflow.set_workflow_data(workflow_info.data)
65+
workflow.set_workflow_data(workflow_info.data, override=override)
6566
workflow.set_workflow_status(WorkflowStatus.WAITING.value)
6667
# 发起异步任务
6768
execute_workflow.delay(unique_id, workflow_id, chat_id, str(login_user.user_id))

src/backend/bisheng/worker/workflow/redis_callback.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import time
55
import uuid
6-
from typing import AsyncIterator, Iterator
6+
from typing import AsyncIterator, Iterator, Dict, List
77

88
from langchain_core.documents import Document
99
from loguru import logger
@@ -48,9 +48,33 @@ def __init__(self, unique_id: str, workflow_id: str, chat_id: str, user_id: int)
4848
self.workflow_stop_key = f'workflow:{unique_id}:stop'
4949
self.workflow_expire_time = settings.get_workflow_conf().timeout * 60 + 60
5050

51-
def set_workflow_data(self, data: dict):
51+
def set_workflow_data(self, data: Dict, override: Dict = None):
52+
data = self.override_nodes_params(data, override)
5253
self.redis_client.set(self.workflow_data_key, data, expiration=self.workflow_expire_time)
5354

55+
@staticmethod
56+
def override_nodes_params(data: Dict, override: Dict = None) -> Dict:
57+
if not override:
58+
return data
59+
60+
def replace_param(one_params: List[Dict], one_node_id: str):
61+
for param in one_params:
62+
param_key = param.get('key')
63+
if param_key not in override[node_id]:
64+
continue
65+
param['value'] = override[one_node_id][param_key]
66+
67+
nodes = data.get('nodes', [])
68+
for node in nodes:
69+
node_data = node.get('data', {})
70+
node_id = node_data.get('id')
71+
if node_id not in override:
72+
continue
73+
group_params = node_data.get('group_params', [])
74+
for group_param in group_params:
75+
replace_param(group_param.get('params', []), node_id)
76+
return data
77+
5478
async def async_set_workflow_data(self, data: dict):
5579
await self.redis_client.aset(self.workflow_data_key, data, expiration=self.workflow_expire_time)
5680

src/backend/bisheng/workflow/graph/graph_state.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77

88
class GraphState(BaseModel):
9-
""" 所有节点的 全局状态管理 """
9+
""" nodes share state """
1010

11-
# 存储聊天历史
1211
history_memory: Optional[ConversationBufferWindowMemory] = None
1312

14-
# 全局变量池
15-
variables_pool: Dict[str, Dict[str, Any]] = Field(default_factory=dict, description='全局变量池: {node_id: {key: value}}')
13+
# global variable pool
14+
variables_pool: Dict[str, Dict[str, Any]] = Field(default_factory=dict,
15+
description='全局变量池: {node_id: {key: value}}')
1616

1717
def get_history_memory(self, count: int) -> str:
1818
""" 获取聊天历史记录
@@ -31,7 +31,6 @@ def get_history_memory(self, count: int) -> str:
3131
def get_history_list(self, count: int) -> List[BaseMessage]:
3232
return self.history_memory.buffer_as_messages[-count:]
3333

34-
3534
def save_context(self, content: str, msg_sender: str) -> None:
3635
""" 保存聊天记录
3736
workflow 特殊情况,过程会有多轮交互,所以不是一条对一条,重制消息结构"""
@@ -101,8 +100,8 @@ def get_all_variables(self) -> Dict[str, Any]:
101100
for node_id, node_variables in self.variables_pool.items():
102101
for key, value in node_variables.items():
103102
ret[f'{node_id}.{key}'] = self.get_variable(node_id, key)
104-
# 特殊处理下 preset_question key
105-
if key == 'preset_question':
103+
# get preset_question and custom_variables all keys
104+
if key in ['preset_question', 'custom_variables']:
106105
for k, v in value.items():
107106
ret[f'{node_id}.{key}#{k}'] = v
108107
return ret

src/backend/bisheng/workflow/nodes/start/start.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,21 @@ def _run(self, unique_id: str) -> Dict[str, Any]:
5757
if not self.node_data.v:
5858
raise IgnoreException(f'{self.name} -- workflow node is update')
5959

60-
# 预处理preset_question数据为dict
60+
# convert preset_question to dict
6161
new_preset_question = {}
6262
for one in self.node_params['preset_question']:
6363
new_preset_question[one['key']] = one['value']
6464

65+
# convert custom vars to dict
66+
custom_vars = {}
67+
for one in self.node_params.get('custom_variables', []):
68+
custom_vars[one['key']] = one['value']
6569
return {
6670
'current_time': self.node_params['current_time'],
6771
'chat_history': '',
6872
'preset_question': new_preset_question,
6973
'user_info': self._user_info,
74+
'custom_variables': custom_vars
7075
}
7176

7277
def parse_log(self, unique_id: str, result: dict) -> Any:

src/backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "backend"
3-
version = "2.3.0-beta3"
3+
version = "2.3.0-beta4"
44
description = "BISHENG backend service"
55
readme = "README.md"
66
license = "Apache 2.0"

src/frontend/client/src/hooks/Chat/useChatFunctions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export default function useChatFunctions({
114114
const search_enabled = searchType && searchType === 'netSearch' || false;
115115
const knowledge_enabled = searchType && searchType === 'knowledgeSearch' || false;
116116

117-
debugger
118117
const use_knowledge_base = {
119118
personal_knowledge_enabled: knowledge_enabled,
120119

src/frontend/client/src/locales/en/translation.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@
466466
"com_ui_agent_delete_error": "There was an error deleting the agent",
467467
"com_ui_agent_deleted": "Successfully deleted agent",
468468
"com_ui_agent_duplicate_error": "There was an error duplicating the agent",
469-
"com_ui_agent_duplicated": "Agent duplicated successfully",
469+
"com_ui_agent_duplicated": "Agent copied successfully",
470470
"com_ui_agent_editing_allowed": "Other users can already edit this agent",
471471
"com_ui_agent_shared_to_all": "something needs to go here. was empty",
472472
"com_ui_agents": "Agents",
@@ -608,10 +608,10 @@
608608
"com_ui_dropdown_variables": "Dropdown variables:",
609609
"com_ui_dropdown_variables_info": "Create custom dropdown menus for your prompts: `{{variable_name:option1|option2|option3}}`",
610610
"com_ui_duplicate": "Duplicate",
611-
"com_ui_duplicated": "Duplicated",
611+
"com_ui_duplicated": "Copied",
612612
"com_ui_duplication_error": "There was an error duplicating the conversation",
613613
"com_ui_duplication_processing": "Duplicating conversation...",
614-
"com_ui_duplication_success": "Successfully duplicated conversation",
614+
"com_ui_duplication_success": "Successfully copied conversation",
615615
"com_app_center_welcome": "Explore BISHENG's Intelligent Agents",
616616
"com_app_center_description": "You can choose the intelligent agents you need here for production and work~",
617617
"com_app_frequently_used": "Frequently Used Agents",

0 commit comments

Comments
 (0)