Skip to content
Merged
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 @@ -19,8 +19,10 @@


class BaseDataSourceWebNodeForm(BaseForm):
source_url = forms.TextInputField(_('Web source url'), required=True)
selector = forms.TextInputField(_('Web knowledge selector'), required=False,attrs={'placeholder': _('The default is body, you can enter .classname/#idname/tagname')})
source_url = forms.TextInputField(_('Web source url'), required=True, attrs={
'placeholder': _('Please enter the Web root address')})
selector = forms.TextInputField(_('Web knowledge selector'), required=False, attrs={
'placeholder': _('The default is body, you can enter .classname/#idname/tagname')})


def get_collect_handler():
Expand All @@ -38,7 +40,7 @@ def handler(child_link: ChildLink, response: Fork.Response):
except Exception as e:
maxkb_logger.error(f'{str(e)}:{traceback.format_exc()}')

return handler,results
return handler, results


class BaseDataSourceWebNode(IDataSourceWebNode):
Expand All @@ -61,24 +63,22 @@ def execute(self, **kwargs) -> NodeResult:
collect_handler, document_list = get_collect_handler()

try:
ForkManage(source_url,selector.split(" ") if selector is not None else []).fork(3,set(),collect_handler)
ForkManage(source_url, selector.split(" ") if selector is not None else []).fork(3, set(), collect_handler)

return NodeResult({'document_list': document_list},
self.workflow_manage.params.get('knowledge_base') or {})
return NodeResult({'document_list': document_list},
self.workflow_manage.params.get('knowledge_base') or {})

except Exception as e:
maxkb_logger.error(_('data source web node:{node_id} error{error}{traceback}').format(
knowledge_id=node_id, error=str(e), traceback=traceback.format_exc()))



def get_details(self, index: int, **kwargs):
return {
'name': self.node.properties.get('stepName'),
"index": index,
'run_time': self.context.get('run_time'),
'type': self.node.type,
'input_params': {"source_url": self.context.get("source_url"),"selector": self.context.get('selector')},
'input_params': {"source_url": self.context.get("source_url"), "selector": self.context.get('selector')},
'output_params': self.context.get('document_list'),
'knowledge_base': self.workflow_params.get('knowledge_base'),
'status': self.status,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No immediate changes needed for this file. The code looks clean, well-indented, and follows Python style guidelines.

However, one minor suggestion is to avoid using single-character variable names like handler and result. Using meaningful names makes the code more readable and maintainable. For example:

def get_data_collect_handler():

And

ForkManage(source_url, selector.split(" ") if selector is not None else []).fork(3, set(), data_collect_handler)

This change will improve clarity in the code.

Expand Down
3 changes: 3 additions & 0 deletions apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8793,4 +8793,7 @@ msgid "Web knowledge selector"
msgstr ""

msgid "The default is body, you can enter .classname/#idname/tagname"
msgstr ""

msgid "Please enter the Web root address"
msgstr ""
5 changes: 4 additions & 1 deletion apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8919,4 +8919,7 @@ msgid "Web knowledge selector"
msgstr "选择器"

msgid "The default is body, you can enter .classname/#idname/tagname"
msgstr "默认为 body,可输入 .classname/#idname/tagname"
msgstr "默认为 body,可输入 .classname/#idname/tagname"

msgid "Please enter the Web root address"
msgstr "请输入Web根地址"
5 changes: 4 additions & 1 deletion apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8919,4 +8919,7 @@ msgid "Web knowledge selector"
msgstr "選擇器"

msgid "The default is body, you can enter .classname/#idname/tagname"
msgstr "默認為 body,可輸入 .classname/#idname/tagname"
msgstr "默認為 body,可輸入 .classname/#idname/tagname"

msgid "Please enter the Web root address"
msgstr "請輸入Web根地址"
Loading