Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

def get_embedding_id(dataset_id_list):
dataset_list = QuerySet(Knowledge).filter(id__in=dataset_id_list)
if not dataset_list:
raise Exception("知识库设置错误,请重新设置知识库")
if len(set([dataset.embedding_model_id for dataset in dataset_list])) > 1:
raise Exception("关联知识库的向量模型不一致,无法召回分段。")
if len(dataset_list) == 0:
raise Exception("知识库设置错误,请重新设置知识库")
return dataset_list[0].embedding_model_id


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def valid_reference_value(_type, value, name):


def convert_value(name: str, value, _type, is_required, source, node):
if not is_required and (value is None or ((isinstance(value, str) or isinstance(value, list)) and len(value) == 0)):
if not is_required and (value is None or (isinstance(value, (str, list)) and len(value) == 0)):
return None
if source == 'reference':
value = node.workflow_manage.get_reference_field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def valid_reference_value(_type, value, name):


def convert_value(name: str, value, _type, is_required, source, node):
if not is_required and (value is None or ((isinstance(value, str) or isinstance(value, list)) and len(value) == 0)):
if not is_required and (value is None or (isinstance(value, (str, list)) and len(value) == 0)):
return None
if source == 'reference':
value = node.workflow_manage.get_reference_field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ def generate_history_ai_message(self, chat_record):
def generate_history_human_message_for_details(self, chat_record):
for data in chat_record.details.values():
if self.node.id == data['node_id'] and 'video_list' in data:
video_list = data['video_list'] or []
# 增加对 None 和空列表的检查
if not video_list or len(video_list) == 0 or data['dialogue_type'] == 'WORKFLOW':
video_list = data['video_list'] or []
if not video_list or data['dialogue_type'] == 'WORKFLOW':
return HumanMessage(content=chat_record.problem_text)
file_id_list = []
url_list = []
Expand Down Expand Up @@ -242,8 +241,8 @@ def generate_history_human_message(self, chat_record, video_model):

for data in chat_record.details.values():
if self.node.id == data['node_id'] and 'video_list' in data:
video_list = data['video_list'] or []
if video_list is None or len(video_list) == 0 or data['dialogue_type'] == 'WORKFLOW':
video_list = data['video_list'] or []
if not video_list or data['dialogue_type'] == 'WORKFLOW':
return HumanMessage(content=chat_record.problem_text)
file_id_list = []
url_list = []
Expand Down
2 changes: 1 addition & 1 deletion apps/application/serializers/application_chat_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def reset_chat_record(chat_record, show_source, show_exec):
'padding_problem_text': chat_record.details.get('problem_padding').get(
'padding_problem_text') if 'problem_padding' in chat_record.details else None,
**(show_source_dict if show_source else {}),
**(show_exec_dict if show_exec else show_exec_dict)
**show_exec_dict
}

def page(self, current_page: int, page_size: int, with_valid=True, show_source=None, show_exec=None):
Expand Down
2 changes: 0 additions & 2 deletions apps/chat/mcp/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ def _get_chat_id(self):
}).open()

def call_tool(self, params):
name = params["name"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name 没在用

args = params.get("arguments", {})
# print(params)

payload = {
'message': args.get('message'),
Expand Down
1 change: 0 additions & 1 deletion apps/chat/serializers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ def get_chat_record(chat_info, chat_record_id):
chat_record = QuerySet(ChatRecord).filter(id=chat_record_id, chat_id=chat_info.chat_id).first()
if chat_record is None:
raise ChatException(500, _("Conversation record does not exist"))

return chat_record
chat_record = QuerySet(ChatRecord).filter(id=chat_record_id).first()
return chat_record
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

from models_provider.base_model_provider import MaxKBBaseModel

RESTfulClient = None
try:
from xinference.client import RESTfulClient
except ImportError:
try:
from xinference_client import RESTfulClient
except ImportError as e:
pass


class XInferenceReranker(MaxKBBaseModel, BaseDocumentCompressor):
server_url: Optional[str]
Expand All @@ -31,21 +40,14 @@ def new_instance(model_type, model_name, model_credential: Dict[str, object], **

def compress_documents(self, documents: Sequence[Document], query: str, callbacks: Optional[Callbacks] = None) -> \
Sequence[Document]:
if documents is None or len(documents) == 0:
return []
client: Any
if documents is None or len(documents) == 0:
if not documents:
return []

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除冗余代码

try:
from xinference.client import RESTfulClient
except ImportError:
try:
from xinference_client import RESTfulClient
except ImportError as e:
raise ImportError(
"Could not import RESTfulClient from xinference. Please install it"
" with `pip install xinference` or `pip install xinference_client`."
) from e

if RESTfulClient is None:
raise ImportError(
"Could not import RESTfulClient from xinference. Please install it"
" with `pip install xinference` or `pip install xinference_client`."
) from e

client = RESTfulClient(self.server_url, self.api_key)
model: RESTfulRerankModelHandle = client.get_model(self.model_uid)
Expand Down
16 changes: 8 additions & 8 deletions ui/src/locales/lang/en-US/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ export default {
systemDefault: `#Role
You are a master of problem optimization, adept at accurately inferring user intentions based on context and optimizing the questions raised by users.

##Skills
###Skill 1: Optimizing Problems
2. Receive user input questions.
3. Carefully analyze the meaning of the problem based on the context.
4. Output optimized problems.
## Skills
### Skill 1: Optimizing Problems
1. Receive user input questions.
2. Carefully analyze the meaning of the problem based on the context.
3. Output optimized problems.

##Limitations:
-Only return the optimized problem without any additional explanation or clarification.
-Ensure that the optimized problem accurately reflects the original problem intent and does not alter the original intention.`,
## Limitations:
- Only return the optimized problem without any additional explanation or clarification.
- Ensure that the optimized problem accurately reflects the original problem intent and does not alter the original intention.`,
},
conditionNode: {
label: 'Conditional Branch',
Expand Down
6 changes: 3 additions & 3 deletions ui/src/locales/lang/zh-CN/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ export default {
## 技能
### 技能 1: 优化问题
2. 接收用户输入的问题。
3. 依据上下文仔细分析问题含义。
4. 输出优化后的问题。
1. 接收用户输入的问题。
2. 依据上下文仔细分析问题含义。
3. 输出优化后的问题。
## 限制:
- 仅返回优化后的问题,不进行额外解释或说明。
Expand Down
6 changes: 3 additions & 3 deletions ui/src/locales/lang/zh-Hant/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ export default {
## 技能
### 技能 1: 優化問題
2. 接收用戶輸入的問題。
3. 依據上下文仔細分析問題含義。
4. 輸出優化後的問題。
1. 接收用戶輸入的問題。
2. 依據上下文仔細分析問題含義。
3. 輸出優化後的問題。
## 限制:
- 僅返回優化後的問題,不進行額外解釋或說明。
Expand Down
Loading