├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug.yml │ ├── config.yml │ └── feature.yml ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── build-and-push-python-pg.yml │ ├── build-and-push-vector-model.yml │ ├── build-and-push.yml │ ├── create-pr-from-push.yml │ ├── issue-translator.yml │ ├── llm-code-review.yml │ ├── sync2gitee.yml │ └── typos_check.yml ├── .gitignore ├── .idea └── icon.png ├── .typos.toml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── README_CN.md ├── SECURITY.md ├── USE-CASES.md ├── apps ├── __init__.py ├── application │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── chat_pipeline │ │ ├── I_base_chat_pipeline.py │ │ ├── __init__.py │ │ ├── pipeline_manage.py │ │ └── step │ │ │ ├── __init__.py │ │ │ ├── chat_step │ │ │ ├── __init__.py │ │ │ ├── i_chat_step.py │ │ │ └── impl │ │ │ │ └── base_chat_step.py │ │ │ ├── generate_human_message_step │ │ │ ├── __init__.py │ │ │ ├── i_generate_human_message_step.py │ │ │ └── impl │ │ │ │ └── base_generate_human_message_step.py │ │ │ ├── reset_problem_step │ │ │ ├── __init__.py │ │ │ ├── i_reset_problem_step.py │ │ │ └── impl │ │ │ │ └── base_reset_problem_step.py │ │ │ └── search_dataset_step │ │ │ ├── __init__.py │ │ │ ├── i_search_dataset_step.py │ │ │ └── impl │ │ │ └── base_search_dataset_step.py │ ├── flow │ │ ├── __init__.py │ │ ├── common.py │ │ ├── default_workflow.json │ │ ├── default_workflow_en.json │ │ ├── default_workflow_zh.json │ │ ├── default_workflow_zh_Hant.json │ │ ├── i_step_node.py │ │ ├── step_node │ │ │ ├── __init__.py │ │ │ ├── ai_chat_step_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_chat_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_chat_node.py │ │ │ ├── application_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_application_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_application_node.py │ │ │ ├── condition_node │ │ │ │ ├── __init__.py │ │ │ │ ├── compare │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── compare.py │ │ │ │ │ ├── contain_compare.py │ │ │ │ │ ├── equal_compare.py │ │ │ │ │ ├── ge_compare.py │ │ │ │ │ ├── gt_compare.py │ │ │ │ │ ├── is_not_null_compare.py │ │ │ │ │ ├── is_not_true.py │ │ │ │ │ ├── is_null_compare.py │ │ │ │ │ ├── is_true.py │ │ │ │ │ ├── le_compare.py │ │ │ │ │ ├── len_equal_compare.py │ │ │ │ │ ├── len_ge_compare.py │ │ │ │ │ ├── len_gt_compare.py │ │ │ │ │ ├── len_le_compare.py │ │ │ │ │ ├── len_lt_compare.py │ │ │ │ │ ├── lt_compare.py │ │ │ │ │ └── not_contain_compare.py │ │ │ │ ├── i_condition_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_condition_node.py │ │ │ ├── direct_reply_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_reply_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_reply_node.py │ │ │ ├── document_extract_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_document_extract_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_document_extract_node.py │ │ │ ├── form_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_form_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_form_node.py │ │ │ ├── function_lib_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_function_lib_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_function_lib_node.py │ │ │ ├── function_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_function_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_function_node.py │ │ │ ├── image_generate_step_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_image_generate_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_image_generate_node.py │ │ │ ├── image_understand_step_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_image_understand_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_image_understand_node.py │ │ │ ├── mcp_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_mcp_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_mcp_node.py │ │ │ ├── question_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_question_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_question_node.py │ │ │ ├── reranker_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_reranker_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_reranker_node.py │ │ │ ├── search_dataset_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_search_dataset_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_search_dataset_node.py │ │ │ ├── speech_to_text_step_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_speech_to_text_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_speech_to_text_node.py │ │ │ ├── start_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_start_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_start_node.py │ │ │ ├── text_to_speech_step_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_text_to_speech_node.py │ │ │ │ └── impl │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── base_text_to_speech_node.py │ │ │ └── variable_assign_node │ │ │ │ ├── __init__.py │ │ │ │ ├── i_variable_assign_node.py │ │ │ │ └── impl │ │ │ │ ├── __init__.py │ │ │ │ └── base_variable_assign_node.py │ │ ├── tools.py │ │ └── workflow_manage.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_chat_client_id.py │ │ ├── 0003_application_icon.py │ │ ├── 0004_applicationaccesstoken_show_source.py │ │ ├── 0005_alter_chat_abstract_alter_chatrecord_answer_text.py │ │ ├── 0006_applicationapikey_allow_cross_domain_and_more.py │ │ ├── 0007_alter_application_prologue.py │ │ ├── 0008_chat_is_deleted.py │ │ ├── 0009_application_type_application_work_flow_and_more.py │ │ ├── 0010_alter_chatrecord_details.py │ │ ├── 0011_application_model_params_setting.py │ │ ├── 0012_application_stt_model_application_stt_model_enable_and_more.py │ │ ├── 0013_application_tts_type.py │ │ ├── 0014_application_problem_optimization_prompt.py │ │ ├── 0015_re_database_index.py │ │ ├── 0016_alter_chatrecord_problem_text.py │ │ ├── 0017_application_tts_model_params_setting.py │ │ ├── 0018_workflowversion_name.py │ │ ├── 0019_application_file_upload_enable_and_more.py │ │ ├── 0020_application_record_update_time.py │ │ ├── 0021_applicationpublicaccessclient_client_id_and_more.py │ │ ├── 0022_application_tts_autoplay.py │ │ ├── 0023_application_stt_autosend.py │ │ ├── 0024_applicationaccesstoken_language.py │ │ ├── 0025_alter_application_prologue.py │ │ ├── 0026_chat_asker.py │ │ └── __init__.py │ ├── models │ │ ├── __init__.py │ │ ├── api_key_model.py │ │ └── application.py │ ├── serializers │ │ ├── application_serializers.py │ │ ├── application_statistics_serializers.py │ │ ├── application_version_serializers.py │ │ ├── chat_message_serializers.py │ │ └── chat_serializers.py │ ├── sql │ │ ├── chat_record_count.sql │ │ ├── chat_record_count_trend.sql │ │ ├── customer_count.sql │ │ ├── customer_count_trend.sql │ │ ├── export_application_chat.sql │ │ ├── list_application.sql │ │ ├── list_application_chat.sql │ │ ├── list_application_dataset.sql │ │ └── list_dataset_paragraph_by_paragraph_id.sql │ ├── swagger_api │ │ ├── application_api.py │ │ ├── application_statistics_api.py │ │ ├── application_version_api.py │ │ └── chat_api.py │ ├── task │ │ └── __init__.py │ ├── template │ │ └── embed.js │ ├── tests.py │ ├── urls.py │ └── views │ │ ├── __init__.py │ │ ├── application_version_views.py │ │ ├── application_views.py │ │ ├── chat_views.py │ │ └── common.py ├── common │ ├── __init__.py │ ├── auth │ │ ├── __init__.py │ │ ├── authenticate.py │ │ ├── authentication.py │ │ └── handle │ │ │ ├── auth_base_handle.py │ │ │ └── impl │ │ │ ├── application_key.py │ │ │ ├── public_access_token.py │ │ │ └── user_token.py │ ├── cache │ │ ├── file_cache.py │ │ └── mem_cache.py │ ├── cache_data │ │ ├── application_access_token_cache.py │ │ ├── application_api_key_cache.py │ │ └── static_resource_cache.py │ ├── chunk │ │ ├── __init__.py │ │ ├── i_chunk_handle.py │ │ └── impl │ │ │ └── mark_chunk_handle.py │ ├── config │ │ ├── embedding_config.py │ │ ├── swagger_conf.py │ │ └── tokenizer_manage_config.py │ ├── constants │ │ ├── authentication_type.py │ │ ├── cache_code_constants.py │ │ ├── exception_code_constants.py │ │ └── permission_constants.py │ ├── db │ │ ├── compiler.py │ │ ├── search.py │ │ └── sql_execute.py │ ├── encoder │ │ └── encoder.py │ ├── event │ │ ├── __init__.py │ │ ├── common.py │ │ └── listener_manage.py │ ├── exception │ │ └── app_exception.py │ ├── field │ │ ├── __init__.py │ │ ├── common.py │ │ └── vector_field.py │ ├── forms │ │ ├── __init__.py │ │ ├── array_object_card.py │ │ ├── base_field.py │ │ ├── base_form.py │ │ ├── label │ │ │ ├── __init__.py │ │ │ ├── base_label.py │ │ │ └── tooltip_label.py │ │ ├── multi_select.py │ │ ├── object_card.py │ │ ├── password_input.py │ │ ├── radio_button_field.py │ │ ├── radio_card_field.py │ │ ├── radio_field.py │ │ ├── single_select_field.py │ │ ├── slider_field.py │ │ ├── switch_field.py │ │ ├── tab_card.py │ │ ├── table_checkbox.py │ │ ├── table_radio.py │ │ └── text_input_field.py │ ├── handle │ │ ├── __init__.py │ │ ├── base_parse_qa_handle.py │ │ ├── base_parse_table_handle.py │ │ ├── base_split_handle.py │ │ ├── base_to_response.py │ │ ├── handle_exception.py │ │ └── impl │ │ │ ├── csv_split_handle.py │ │ │ ├── doc_split_handle.py │ │ │ ├── html_split_handle.py │ │ │ ├── pdf_split_handle.py │ │ │ ├── qa │ │ │ ├── csv_parse_qa_handle.py │ │ │ ├── xls_parse_qa_handle.py │ │ │ ├── xlsx_parse_qa_handle.py │ │ │ └── zip_parse_qa_handle.py │ │ │ ├── response │ │ │ ├── openai_to_response.py │ │ │ └── system_to_response.py │ │ │ ├── table │ │ │ ├── csv_parse_table_handle.py │ │ │ ├── xls_parse_table_handle.py │ │ │ └── xlsx_parse_table_handle.py │ │ │ ├── text_split_handle.py │ │ │ ├── tools.py │ │ │ ├── xls_split_handle.py │ │ │ ├── xlsx_split_handle.py │ │ │ └── zip_split_handle.py │ ├── init │ │ └── init_doc.py │ ├── job │ │ ├── __init__.py │ │ ├── clean_chat_job.py │ │ ├── clean_debug_file_job.py │ │ └── client_access_num_job.py │ ├── lock │ │ ├── base_lock.py │ │ └── impl │ │ │ └── file_lock.py │ ├── log │ │ └── log.py │ ├── management │ │ ├── __init__.py │ │ └── commands │ │ │ ├── __init__.py │ │ │ ├── celery.py │ │ │ ├── restart.py │ │ │ ├── services │ │ │ ├── __init__.py │ │ │ ├── command.py │ │ │ ├── hands.py │ │ │ ├── services │ │ │ │ ├── __init__.py │ │ │ │ ├── base.py │ │ │ │ ├── celery_base.py │ │ │ │ ├── celery_default.py │ │ │ │ ├── gunicorn.py │ │ │ │ └── local_model.py │ │ │ └── utils.py │ │ │ ├── start.py │ │ │ ├── status.py │ │ │ └── stop.py │ ├── middleware │ │ ├── cross_domain_middleware.py │ │ ├── doc_headers_middleware.py │ │ ├── gzip.py │ │ └── static_headers_middleware.py │ ├── mixins │ │ ├── api_mixin.py │ │ └── app_model_mixin.py │ ├── models │ │ ├── db_model_manage.py │ │ └── handle │ │ │ ├── base_handle.py │ │ │ └── impl │ │ │ └── default_base_model_handle.py │ ├── response │ │ └── result.py │ ├── sql │ │ └── list_embedding_text.sql │ ├── swagger_api │ │ └── common_api.py │ ├── task │ │ └── __init__.py │ ├── template │ │ ├── email_template_en.html │ │ ├── email_template_zh.html │ │ └── email_template_zh_Hant.html │ └── util │ │ ├── cache_util.py │ │ ├── common.py │ │ ├── field_message.py │ │ ├── file_util.py │ │ ├── fork.py │ │ ├── function_code.py │ │ ├── lock.py │ │ ├── page_utils.py │ │ ├── rsa_util.py │ │ ├── split_model.py │ │ ├── test.py │ │ └── ts_vecto_util.py ├── dataset │ ├── __init__.py │ ├── apps.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_image.py │ │ ├── 0003_document_hit_handling_method.py │ │ ├── 0004_document_directly_return_similarity.py │ │ ├── 0005_file.py │ │ ├── 0006_dataset_embedding_mode.py │ │ ├── 0007_alter_paragraph_content.py │ │ ├── 0008_alter_document_status_alter_paragraph_status.py │ │ ├── 0009_alter_document_status_alter_paragraph_status.py │ │ ├── 0010_file_meta.py │ │ ├── 0011_document_status_meta_paragraph_status_meta_and_more.py │ │ └── __init__.py │ ├── models │ │ ├── __init__.py │ │ └── data_set.py │ ├── serializers │ │ ├── common_serializers.py │ │ ├── dataset_serializers.py │ │ ├── document_serializers.py │ │ ├── file_serializers.py │ │ ├── image_serializers.py │ │ ├── paragraph_serializers.py │ │ └── problem_serializers.py │ ├── sql │ │ ├── list_dataset.sql │ │ ├── list_dataset_application.sql │ │ ├── list_document.sql │ │ ├── list_paragraph.sql │ │ ├── list_paragraph_document_name.sql │ │ ├── list_problem.sql │ │ ├── list_problem_mapping.sql │ │ ├── update_document_char_length.sql │ │ ├── update_document_status_meta.sql │ │ └── update_paragraph_status.sql │ ├── swagger_api │ │ ├── document_api.py │ │ ├── image_api.py │ │ └── problem_api.py │ ├── task │ │ ├── __init__.py │ │ ├── generate.py │ │ ├── sync.py │ │ └── tools.py │ ├── template │ │ ├── csv_template_en.csv │ │ ├── csv_template_zh.csv │ │ ├── csv_template_zh_Hant.csv │ │ ├── excel_template_en.xlsx │ │ ├── excel_template_zh.xlsx │ │ ├── excel_template_zh_Hant.xlsx │ │ ├── table_template_en.csv │ │ ├── table_template_en.xlsx │ │ ├── table_template_zh.csv │ │ ├── table_template_zh.xlsx │ │ ├── table_template_zh_Hant.csv │ │ └── table_template_zh_Hant.xlsx │ ├── tests.py │ ├── urls.py │ └── views │ │ ├── __init__.py │ │ ├── common.py │ │ ├── dataset.py │ │ ├── document.py │ │ ├── file.py │ │ ├── image.py │ │ ├── paragraph.py │ │ └── problem.py ├── embedding │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_embedding_search_vector.py │ │ ├── 0003_alter_embedding_unique_together.py │ │ └── __init__.py │ ├── models │ │ ├── __init__.py │ │ └── embedding.py │ ├── sql │ │ ├── blend_search.sql │ │ ├── embedding_search.sql │ │ ├── hit_test.sql │ │ └── keywords_search.sql │ ├── task │ │ ├── __init__.py │ │ └── embedding.py │ ├── tests.py │ ├── vector │ │ ├── base_vector.py │ │ └── pg_vector.py │ └── views.py ├── function_lib │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_functionlib_is_active_functionlib_permission_type.py │ │ ├── 0003_functionlib_function_type_functionlib_icon_and_more.py │ │ └── __init__.py │ ├── models │ │ ├── __init__.py │ │ └── function.py │ ├── serializers │ │ ├── __init__.py │ │ ├── function_lib_serializer.py │ │ └── py_lint_serializer.py │ ├── swagger_api │ │ ├── __init__.py │ │ ├── function_lib_api.py │ │ └── py_lint_api.py │ ├── task │ │ └── __init__.py │ ├── tests.py │ ├── urls.py │ └── views │ │ ├── __init__.py │ │ ├── common.py │ │ ├── function_lib_views.py │ │ └── py_lint.py ├── locales │ ├── en_US │ │ └── LC_MESSAGES │ │ │ └── django.po │ ├── zh_CN │ │ └── LC_MESSAGES │ │ │ └── django.po │ └── zh_Hant │ │ └── LC_MESSAGES │ │ └── django.po ├── manage.py ├── ops │ ├── __init__.py │ └── celery │ │ ├── __init__.py │ │ ├── const.py │ │ ├── decorator.py │ │ ├── heartbeat.py │ │ ├── logger.py │ │ ├── signal_handler.py │ │ └── utils.py ├── setting │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_systemsetting.py │ │ ├── 0003_model_meta_model_status.py │ │ ├── 0004_alter_model_credential.py │ │ ├── 0005_model_permission_type.py │ │ ├── 0006_alter_model_status.py │ │ ├── 0007_model_model_params_form.py │ │ ├── 0008_modelparam.py │ │ ├── 0009_set_default_model_params_form.py │ │ ├── 0010_log.py │ │ └── __init__.py │ ├── models │ │ ├── __init__.py │ │ ├── log_management.py │ │ ├── model_management.py │ │ ├── system_management.py │ │ └── team_management.py │ ├── models_provider │ │ ├── __init__.py │ │ ├── base_model_provider.py │ │ ├── constants │ │ │ └── model_provider_constants.py │ │ ├── impl │ │ │ ├── aliyun_bai_lian_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── aliyun_bai_lian_model_provider.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── reranker.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ ├── icon │ │ │ │ │ └── aliyun_bai_lian_icon_svg │ │ │ │ └── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── iat_mp3_16k.mp3 │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── reranker.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ ├── anthropic_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── anthropic_model_provider.py │ │ │ │ ├── credential │ │ │ │ │ ├── image.py │ │ │ │ │ └── llm.py │ │ │ │ ├── icon │ │ │ │ │ └── anthropic_icon_svg │ │ │ │ └── model │ │ │ │ │ ├── image.py │ │ │ │ │ └── llm.py │ │ │ ├── aws_bedrock_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── aws_bedrock_model_provider.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ └── llm.py │ │ │ │ ├── icon │ │ │ │ │ └── bedrock_icon_svg │ │ │ │ └── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ └── llm.py │ │ │ ├── azure_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── azure_model_provider.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ ├── icon │ │ │ │ │ └── azure_icon_svg │ │ │ │ └── model │ │ │ │ │ ├── azure_chat_model.py │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ ├── base_chat_open_ai.py │ │ │ ├── base_stt.py │ │ │ ├── base_tti.py │ │ │ ├── base_tts.py │ │ │ ├── deepseek_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ └── llm.py │ │ │ │ ├── deepseek_model_provider.py │ │ │ │ ├── icon │ │ │ │ │ └── deepseek_icon_svg │ │ │ │ └── model │ │ │ │ │ └── llm.py │ │ │ ├── gemini_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── stt.py │ │ │ │ ├── gemini_model_provider.py │ │ │ │ ├── icon │ │ │ │ │ └── gemini_icon_svg │ │ │ │ └── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── stt.py │ │ │ ├── kimi_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ └── llm.py │ │ │ │ ├── icon │ │ │ │ │ └── kimi_icon_svg │ │ │ │ ├── kimi_model_provider.py │ │ │ │ └── model │ │ │ │ │ └── llm.py │ │ │ ├── local_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ └── reranker.py │ │ │ │ ├── icon │ │ │ │ │ └── local_icon_svg │ │ │ │ ├── local_model_provider.py │ │ │ │ └── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ └── reranker.py │ │ │ ├── ollama_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── reranker.py │ │ │ │ ├── icon │ │ │ │ │ └── ollama_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── reranker.py │ │ │ │ └── ollama_model_provider.py │ │ │ ├── openai_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ ├── icon │ │ │ │ │ └── openai_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ └── openai_model_provider.py │ │ │ ├── qwen_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── tti.py │ │ │ │ ├── icon │ │ │ │ │ └── qwen_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── tti.py │ │ │ │ └── qwen_model_provider.py │ │ │ ├── regolo_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── tti.py │ │ │ │ ├── icon │ │ │ │ │ └── regolo_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── tti.py │ │ │ │ └── regolo_model_provider.py │ │ │ ├── siliconCloud_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── reranker.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ ├── icon │ │ │ │ │ └── siliconCloud_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── reranker.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ └── siliconCloud_model_provider.py │ │ │ ├── tencent_cloud_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ └── llm.py │ │ │ │ ├── icon │ │ │ │ │ └── tencent_cloud_icon_svg │ │ │ │ ├── model │ │ │ │ │ └── llm.py │ │ │ │ └── tencent_cloud_model_provider.py │ │ │ ├── tencent_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── tti.py │ │ │ │ ├── icon │ │ │ │ │ └── tencent_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── hunyuan.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ └── tti.py │ │ │ │ └── tencent_model_provider.py │ │ │ ├── vllm_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ └── llm.py │ │ │ │ ├── icon │ │ │ │ │ └── vllm_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ └── llm.py │ │ │ │ └── vllm_model_provider.py │ │ │ ├── volcanic_engine_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ ├── icon │ │ │ │ │ └── volcanic_engine_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── iat_mp3_16k.mp3 │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ └── volcanic_engine_model_provider.py │ │ │ ├── wenxin_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ └── llm.py │ │ │ │ ├── icon │ │ │ │ │ └── azure_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ └── llm.py │ │ │ │ └── wenxin_model_provider.py │ │ │ ├── xf_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── img_1.png │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── stt.py │ │ │ │ │ └── tts.py │ │ │ │ ├── icon │ │ │ │ │ └── xf_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── iat_mp3_16k.mp3 │ │ │ │ │ ├── image.py │ │ │ │ │ ├── img_1.png │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── stt.py │ │ │ │ │ └── tts.py │ │ │ │ └── xf_model_provider.py │ │ │ ├── xinference_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── reranker.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ ├── icon │ │ │ │ │ └── xinference_icon_svg │ │ │ │ ├── model │ │ │ │ │ ├── embedding.py │ │ │ │ │ ├── image.py │ │ │ │ │ ├── llm.py │ │ │ │ │ ├── reranker.py │ │ │ │ │ ├── stt.py │ │ │ │ │ ├── tti.py │ │ │ │ │ └── tts.py │ │ │ │ └── xinference_model_provider.py │ │ │ └── zhipu_model_provider │ │ │ │ ├── __init__.py │ │ │ │ ├── credential │ │ │ │ ├── image.py │ │ │ │ ├── llm.py │ │ │ │ └── tti.py │ │ │ │ ├── icon │ │ │ │ └── zhipuai_icon_svg │ │ │ │ ├── model │ │ │ │ ├── image.py │ │ │ │ ├── llm.py │ │ │ │ └── tti.py │ │ │ │ └── zhipu_model_provider.py │ │ └── tools.py │ ├── serializers │ │ ├── model_apply_serializers.py │ │ ├── provider_serializers.py │ │ ├── system_setting.py │ │ ├── team_serializers.py │ │ └── valid_serializers.py │ ├── sql │ │ ├── check_member_permission_target_exists.sql │ │ ├── get_member_permission.sql │ │ └── get_user_permission.sql │ ├── swagger_api │ │ ├── provide_api.py │ │ ├── system_setting.py │ │ └── valid_api.py │ ├── tests.py │ ├── urls.py │ └── views │ │ ├── Team.py │ │ ├── __init__.py │ │ ├── common.py │ │ ├── model.py │ │ ├── model_apply.py │ │ ├── system_setting.py │ │ └── valid.py ├── smartdoc │ ├── __init__.py │ ├── asgi.py │ ├── conf.py │ ├── const.py │ ├── settings │ │ ├── __init__.py │ │ ├── auth.py │ │ ├── base.py │ │ ├── lib.py │ │ └── logging.py │ ├── urls.py │ └── wsgi.py └── users │ ├── __init__.py │ ├── apps.py │ ├── migrations │ ├── 0001_initial.py │ ├── 0002_user_create_time_user_update_time.py │ ├── 0003_user_source.py │ ├── 0004_alter_user_email.py │ ├── 0005_user_language.py │ └── __init__.py │ ├── models │ ├── __init__.py │ └── user.py │ ├── serializers │ └── user_serializers.py │ ├── task │ └── __init__.py │ ├── urls.py │ └── views │ ├── __init__.py │ ├── common.py │ └── user.py ├── config_example.yml ├── installer ├── Dockerfile ├── Dockerfile-python-pg ├── Dockerfile-vector-model ├── config.yaml ├── init.sql ├── install_model.py ├── run-maxkb.sh └── start-maxkb.sh ├── main.py ├── package-lock.json ├── pyproject.toml └── ui ├── .eslintrc.cjs ├── .gitignore ├── .prettierrc.json ├── .vscode └── extensions.json ├── README.md ├── env.d.ts ├── env └── .env ├── index.html ├── package.json ├── public ├── MaxKB.gif ├── favicon.ico └── fx │ ├── bochaai │ ├── detail.md │ └── icon.png │ ├── google_search │ ├── detail.md │ └── icon.png │ ├── img │ ├── MySQL_app_used.jpg │ ├── MySQL_setting.jpg │ ├── PostgreSQL_app_used.jpg │ ├── PostgreSQL_setting.jpg │ ├── bocha_APIKey.jpg │ ├── bocha_app_used.jpg │ ├── bocha_setting.jpg │ ├── google_APIKey.jpg │ ├── google_AddSearchEngine.jpg │ ├── google_app_used.jpg │ ├── google_cx.jpg │ ├── google_setting.jpg │ ├── langsearch_APIKey.jpg │ ├── langsearch_app_used.jpg │ └── langsearch_setting.jpg │ ├── langsearch │ ├── detail.md │ └── icon.png │ ├── mysql │ ├── detail.md │ └── icon.png │ └── postgresql │ ├── detail.md │ └── icon.png ├── src ├── App.vue ├── api │ ├── application-overview.ts │ ├── application-xpack.ts │ ├── application.ts │ ├── auth-setting.ts │ ├── dataset.ts │ ├── document.ts │ ├── email-setting.ts │ ├── function-lib.ts │ ├── image.ts │ ├── license.ts │ ├── log.ts │ ├── model.ts │ ├── operate-log.ts │ ├── paragraph.ts │ ├── platform-source.ts │ ├── problem.ts │ ├── provider.ts │ ├── system-api-key.ts │ ├── team.ts │ ├── theme.ts │ ├── type │ │ ├── application.ts │ │ ├── common.ts │ │ ├── dataset.ts │ │ ├── function-lib.ts │ │ ├── model.ts │ │ ├── team.ts │ │ └── user.ts │ ├── user-manage.ts │ └── user.ts ├── assets │ ├── 404.png │ ├── acoustic-color.svg │ ├── acoustic.svg │ ├── display-bg1.png │ ├── display-bg2.png │ ├── display-bg3.png │ ├── fileType │ │ ├── csv-icon.svg │ │ ├── doc-icon.svg │ │ ├── docx-icon.svg │ │ ├── file-icon.svg │ │ ├── html-icon.svg │ │ ├── md-icon.svg │ │ ├── pdf-icon.svg │ │ ├── txt-icon.svg │ │ ├── unknown-icon.svg │ │ ├── xls-icon.svg │ │ ├── xlsx-icon.svg │ │ └── zip-icon.svg │ ├── hit-test-empty.png │ ├── icon_and.svg │ ├── icon_assigner.svg │ ├── icon_condition.svg │ ├── icon_docs.svg │ ├── icon_document.svg │ ├── icon_file-audio.svg │ ├── icon_file-doc.svg │ ├── icon_file-folder_colorful.svg │ ├── icon_file-image.svg │ ├── icon_form.svg │ ├── icon_function_outlined.svg │ ├── icon_globe_color.svg │ ├── icon_hi.svg │ ├── icon_image.svg │ ├── icon_mcp.svg │ ├── icon_or.svg │ ├── icon_qr_outlined.svg │ ├── icon_reply.svg │ ├── icon_reranker.svg │ ├── icon_robot.svg │ ├── icon_send.svg │ ├── icon_send_colorful.svg │ ├── icon_setting.svg │ ├── icon_speech_to_text.svg │ ├── icon_start.svg │ ├── icon_text-image.svg │ ├── icon_text_to_speech.svg │ ├── icon_web.svg │ ├── load_error.png │ ├── logo │ │ ├── MaxKB-logo-currentColor.svg │ │ ├── MaxKB-logo.svg │ │ ├── logo-currentColor.svg │ │ └── logo.svg │ ├── logo_dingtalk.svg │ ├── logo_lark.svg │ ├── logo_slack.svg │ ├── logo_wechat-work.svg │ ├── logo_wechat.svg │ ├── sort.svg │ ├── theme │ │ ├── default.jpg │ │ ├── green.jpg │ │ ├── orange.jpg │ │ ├── purple.jpg │ │ └── red.jpg │ ├── tipIMG.jpg │ ├── upload-icon.svg │ ├── user-icon.svg │ ├── window1.png │ ├── window2.png │ └── window3.png ├── bus │ └── index.ts ├── components │ ├── ai-chat │ │ ├── ExecutionDetailDialog.vue │ │ ├── KnowledgeSource.vue │ │ ├── ParagraphSourceDialog.vue │ │ ├── component │ │ │ ├── ParagraphCard.vue │ │ │ ├── answer-content │ │ │ │ └── index.vue │ │ │ ├── chat-input-operate │ │ │ │ ├── TouchChat.vue │ │ │ │ └── index.vue │ │ │ ├── control │ │ │ │ └── index.vue │ │ │ ├── operation-button │ │ │ │ ├── ChatOperationButton.vue │ │ │ │ ├── LogOperationButton.vue │ │ │ │ └── index.vue │ │ │ ├── prologue-content │ │ │ │ └── index.vue │ │ │ ├── question-content │ │ │ │ └── index.vue │ │ │ ├── transition-content │ │ │ │ └── index.vue │ │ │ └── user-form │ │ │ │ └── index.vue │ │ ├── index.scss │ │ └── index.vue │ ├── app-avatar │ │ └── index.vue │ ├── app-charts │ │ ├── components │ │ │ └── LineCharts.vue │ │ └── index.vue │ ├── app-table │ │ └── index.vue │ ├── auto-tooltip │ │ └── index.vue │ ├── back-button │ │ └── index.vue │ ├── card-add │ │ └── index.vue │ ├── card-box │ │ └── index.vue │ ├── card-checkbox │ │ └── index.vue │ ├── codemirror-editor │ │ └── index.vue │ ├── common-list │ │ └── index.vue │ ├── dynamics-form │ │ ├── Demo.vue │ │ ├── DemoConstructor.vue │ │ ├── FormItem.vue │ │ ├── FormItemLabel.vue │ │ ├── constructor │ │ ├── index.ts │ │ ├── index.vue │ │ ├── items │ │ │ ├── DatePicker.vue │ │ │ ├── JsonInput.vue │ │ │ ├── PasswordInput.vue │ │ │ ├── TextInput.vue │ │ │ ├── complex │ │ │ │ ├── ArrayObjectCard.vue │ │ │ │ ├── ObjectCard.vue │ │ │ │ └── TabCard.vue │ │ │ ├── label │ │ │ │ └── TooltipLabel.vue │ │ │ ├── radio │ │ │ │ ├── Radio.vue │ │ │ │ ├── RadioButton.vue │ │ │ │ ├── RadioCard.vue │ │ │ │ └── RadioRow.vue │ │ │ ├── select │ │ │ │ ├── MultiSelect.vue │ │ │ │ └── SingleSelect.vue │ │ │ ├── slider │ │ │ │ └── Slider.vue │ │ │ ├── switch │ │ │ │ └── SwitchInput.vue │ │ │ └── table │ │ │ │ ├── ProgressTableItem.vue │ │ │ │ ├── TableCheckbox.vue │ │ │ │ ├── TableColumn.vue │ │ │ │ └── TableRadio.vue │ │ └── type.ts │ ├── generate-related-dialog │ │ └── index.vue │ ├── icons │ │ ├── AppIcon.vue │ │ └── index.ts │ ├── index.ts │ ├── infinite-scroll │ │ └── index.vue │ ├── layout-container │ │ └── index.vue │ ├── loading │ │ └── DownloadLoading.vue │ ├── login-container │ │ └── index.vue │ ├── login-layout │ │ └── index.vue │ ├── logo │ │ ├── LogoFull.vue │ │ ├── LogoIcon.vue │ │ └── SendIcon.vue │ ├── markdown │ │ ├── EchartsRander.vue │ │ ├── FormRander.vue │ │ ├── HtmlRander.vue │ │ ├── MdEditor.vue │ │ ├── MdEditorMagnify.vue │ │ ├── MdPreview.vue │ │ ├── MdRenderer.vue │ │ ├── ReasoningRander.vue │ │ └── assets │ │ │ └── markdown-iconfont.js │ ├── model-select │ │ └── index.vue │ ├── read-write │ │ └── index.vue │ ├── tag-ellipsis │ │ └── index.vue │ └── tags-input │ │ └── index.vue ├── directives │ ├── clickoutside.ts │ ├── hasPermission.ts │ ├── index.ts │ ├── infiniteScrollUp.ts │ └── resize.ts ├── enums │ ├── application.ts │ ├── common.ts │ ├── document.ts │ ├── model.ts │ ├── team.ts │ └── workflow.ts ├── layout │ ├── components │ │ ├── app-header │ │ │ └── index.vue │ │ ├── app-main │ │ │ └── index.vue │ │ ├── breadcrumb │ │ │ └── index.vue │ │ ├── index.ts │ │ ├── sidebar │ │ │ ├── SidebarItem.vue │ │ │ └── index.vue │ │ └── top-bar │ │ │ ├── avatar │ │ │ ├── APIKeyDialog.vue │ │ │ ├── AboutDialog.vue │ │ │ ├── ResetPassword.vue │ │ │ └── index.vue │ │ │ ├── index.vue │ │ │ └── top-menu │ │ │ ├── MenuItem.vue │ │ │ └── index.vue │ ├── hooks │ │ └── useResize.ts │ └── layout-template │ │ ├── AppLayout.vue │ │ ├── DetailLayout.vue │ │ ├── SystemLayout.vue │ │ └── index.scss ├── locales │ ├── index.ts │ ├── lang │ │ ├── en-US │ │ │ ├── ai-chat.ts │ │ │ ├── common.ts │ │ │ ├── components.ts │ │ │ ├── dynamics-form.ts │ │ │ ├── index.ts │ │ │ ├── layout.ts │ │ │ └── views │ │ │ │ ├── 404.ts │ │ │ │ ├── application-overview.ts │ │ │ │ ├── application-workflow.ts │ │ │ │ ├── application.ts │ │ │ │ ├── dataset.ts │ │ │ │ ├── document.ts │ │ │ │ ├── function-lib.ts │ │ │ │ ├── index.ts │ │ │ │ ├── log.ts │ │ │ │ ├── login.ts │ │ │ │ ├── operate-log.ts │ │ │ │ ├── paragraph.ts │ │ │ │ ├── problem.ts │ │ │ │ ├── system.ts │ │ │ │ ├── team.ts │ │ │ │ ├── template.ts │ │ │ │ └── user.ts │ │ ├── zh-CN │ │ │ ├── ai-chat.ts │ │ │ ├── common.ts │ │ │ ├── components.ts │ │ │ ├── dynamics-form.ts │ │ │ ├── index.ts │ │ │ ├── layout.ts │ │ │ └── views │ │ │ │ ├── 404.ts │ │ │ │ ├── application-overview.ts │ │ │ │ ├── application-workflow.ts │ │ │ │ ├── application.ts │ │ │ │ ├── dataset.ts │ │ │ │ ├── document.ts │ │ │ │ ├── function-lib.ts │ │ │ │ ├── index.ts │ │ │ │ ├── log.ts │ │ │ │ ├── login.ts │ │ │ │ ├── operate-log.ts │ │ │ │ ├── paragraph.ts │ │ │ │ ├── problem.ts │ │ │ │ ├── system.ts │ │ │ │ ├── team.ts │ │ │ │ ├── template.ts │ │ │ │ └── user.ts │ │ └── zh-Hant │ │ │ ├── ai-chat.ts │ │ │ ├── common.ts │ │ │ ├── components.ts │ │ │ ├── dynamics-form.ts │ │ │ ├── index.ts │ │ │ ├── layout.ts │ │ │ └── views │ │ │ ├── 404.ts │ │ │ ├── application-overview.ts │ │ │ ├── application-workflow.ts │ │ │ ├── application.ts │ │ │ ├── dataset.ts │ │ │ ├── document.ts │ │ │ ├── function-lib.ts │ │ │ ├── index.ts │ │ │ ├── log.ts │ │ │ ├── login.ts │ │ │ ├── operate-log.ts │ │ │ ├── paragraph.ts │ │ │ ├── problem.ts │ │ │ ├── system.ts │ │ │ ├── team.ts │ │ │ ├── template.ts │ │ │ └── user.ts │ └── useLocale.ts ├── main.ts ├── request │ ├── Result.ts │ └── index.ts ├── router │ ├── index.ts │ ├── modules │ │ ├── application.ts │ │ ├── dataset.ts │ │ ├── function-lib.ts │ │ └── setting.ts │ └── routes.ts ├── stores │ ├── index.ts │ └── modules │ │ ├── application.ts │ │ ├── common.ts │ │ ├── dataset.ts │ │ ├── document.ts │ │ ├── log.ts │ │ ├── model.ts │ │ ├── paragraph.ts │ │ ├── problem.ts │ │ ├── prompt.ts │ │ └── user.ts ├── styles │ ├── app.scss │ ├── element-plus.scss │ ├── font │ │ ├── AlibabaPuHuiTi-3-55-Regular.eot │ │ ├── AlibabaPuHuiTi-3-55-Regular.otf │ │ ├── AlibabaPuHuiTi-3-55-Regular.ttf │ │ ├── AlibabaPuHuiTi-3-55-Regular.woff │ │ └── AlibabaPuHuiTi-3-55-Regular.woff2 │ ├── index.scss │ ├── md-editor.scss │ └── variables.scss ├── utils │ ├── application.ts │ ├── clipboard.ts │ ├── common.ts │ ├── decimalFormat.ts │ ├── message.ts │ ├── permission │ │ ├── index.ts │ │ └── type.ts │ ├── status.ts │ ├── theme.ts │ ├── time.ts │ └── utils.ts ├── views │ ├── 404 │ │ └── index.vue │ ├── application-overview │ │ ├── component │ │ │ ├── APIKeyDialog.vue │ │ │ ├── DisplaySettingDialog.vue │ │ │ ├── EditAvatarDialog.vue │ │ │ ├── EmbedDialog.vue │ │ │ ├── LimitDialog.vue │ │ │ ├── SettingAPIKeyDialog.vue │ │ │ ├── StatisticsCharts.vue │ │ │ └── XPackDisplaySettingDialog.vue │ │ └── index.vue │ ├── application-workflow │ │ ├── component │ │ │ ├── DropdownMenu.vue │ │ │ └── PublishHistory.vue │ │ └── index.vue │ ├── application │ │ ├── ApplicationAccess.vue │ │ ├── ApplicationSetting.vue │ │ ├── component │ │ │ ├── AIModeParamSettingDialog.vue │ │ │ ├── AccessSettingDrawer.vue │ │ │ ├── AddDatasetDialog.vue │ │ │ ├── CopyApplicationDialog.vue │ │ │ ├── CreateApplicationDialog.vue │ │ │ ├── McpServersDialog.vue │ │ │ ├── ParamSettingDialog.vue │ │ │ ├── ReasoningParamSettingDialog.vue │ │ │ └── TTSModeParamSettingDialog.vue │ │ └── index.vue │ ├── authentication │ │ ├── component │ │ │ ├── CAS.vue │ │ │ ├── EditModal.vue │ │ │ ├── LDAP.vue │ │ │ ├── OAuth2.vue │ │ │ ├── OIDC.vue │ │ │ └── SCAN.vue │ │ └── index.vue │ ├── chat │ │ ├── auth │ │ │ ├── component │ │ │ │ └── password.vue │ │ │ └── index.vue │ │ ├── base │ │ │ └── index.vue │ │ ├── embed │ │ │ └── index.vue │ │ ├── index.vue │ │ ├── mobile │ │ │ └── index.vue │ │ └── pc │ │ │ ├── EditTitleDialog.vue │ │ │ └── index.vue │ ├── dataset │ │ ├── DatasetSetting.vue │ │ ├── ImportDocumentDataset.vue │ │ ├── UploadDocumentDataset.vue │ │ ├── component │ │ │ ├── BaseForm.vue │ │ │ ├── CreateDatasetDialog.vue │ │ │ ├── EditParagraphDialog.vue │ │ │ ├── ParagraphList.vue │ │ │ ├── ParagraphPreview.vue │ │ │ ├── ResultSuccess.vue │ │ │ ├── SetRules.vue │ │ │ ├── SyncWebDialog.vue │ │ │ └── UploadComponent.vue │ │ └── index.vue │ ├── document │ │ ├── component │ │ │ ├── EmbeddingContentDialog.vue │ │ │ ├── ImportDocumentDialog.vue │ │ │ ├── SelectDatasetDialog.vue │ │ │ ├── Status.vue │ │ │ └── StatusTable.vue │ │ └── index.vue │ ├── email │ │ └── index.vue │ ├── first │ │ └── index.vue │ ├── function-lib │ │ ├── component │ │ │ ├── AddInternalFunctionDialog.vue │ │ │ ├── EditAvatarDialog.vue │ │ │ ├── FieldFormDialog.vue │ │ │ ├── FunctionDebugDrawer.vue │ │ │ ├── FunctionFormDrawer.vue │ │ │ ├── InitParamDrawer.vue │ │ │ ├── InternalDescDrawer.vue │ │ │ └── PermissionDialog.vue │ │ └── index.vue │ ├── hit-test │ │ └── index.vue │ ├── log │ │ ├── component │ │ │ ├── ChatRecordDrawer.vue │ │ │ ├── EditContentDialog.vue │ │ │ └── EditMarkDialog.vue │ │ └── index.vue │ ├── login │ │ ├── components │ │ │ ├── QrCodeTab.vue │ │ │ ├── dingtalkQrCode.vue │ │ │ ├── larkQrCode.vue │ │ │ └── wecomQrCode.vue │ │ ├── forgot-password │ │ │ └── index.vue │ │ ├── index.vue │ │ ├── register │ │ │ └── index.vue │ │ └── reset-password │ │ │ └── index.vue │ ├── operate-log │ │ ├── component │ │ │ └── DetailDialog.vue │ │ └── index.vue │ ├── paragraph │ │ ├── component │ │ │ ├── ParagraphDialog.vue │ │ │ ├── ParagraphForm.vue │ │ │ ├── ProblemComponent.vue │ │ │ └── SelectDocumentDialog.vue │ │ └── index.vue │ ├── problem │ │ ├── component │ │ │ ├── CreateProblemDialog.vue │ │ │ ├── DetailProblemDrawer.vue │ │ │ └── RelateProblemDialog.vue │ │ └── index.vue │ ├── team │ │ ├── component │ │ │ ├── CreateMemberDialog.vue │ │ │ └── PermissionSetting.vue │ │ └── index.vue │ ├── template │ │ ├── component │ │ │ ├── AddParamDrawer.vue │ │ │ ├── CreateModelDialog.vue │ │ │ ├── EditModel.vue │ │ │ ├── ModelCard.vue │ │ │ ├── ParamSettingDialog.vue │ │ │ ├── SelectProviderDialog.vue │ │ │ └── data.ts │ │ └── index.vue │ ├── theme │ │ ├── LoginPreview.vue │ │ └── index.vue │ └── user-manage │ │ ├── component │ │ ├── UserDialog.vue │ │ └── UserPwdDialog.vue │ │ └── index.vue └── workflow │ ├── common │ ├── AddFormCollect.vue │ ├── CustomLine.vue │ ├── EditFormCollect.vue │ ├── NodeCascader.vue │ ├── NodeContainer.vue │ ├── NodeControl.vue │ ├── app-node.ts │ ├── data.ts │ ├── edge.ts │ ├── shortcut.ts │ ├── teleport.ts │ └── validate.ts │ ├── icons │ ├── ai-chat-node-icon.vue │ ├── application-node-icon.vue │ ├── base-node-icon.vue │ ├── condition-node-icon.vue │ ├── document-extract-node-icon.vue │ ├── form-node-icon.vue │ ├── function-lib-node-icon.vue │ ├── function-node-icon.vue │ ├── global-icon.vue │ ├── image-generate-node-icon.vue │ ├── image-understand-node-icon.vue │ ├── mcp-node-icon.vue │ ├── question-node-icon.vue │ ├── reply-node-icon.vue │ ├── reranker-node-icon.vue │ ├── search-dataset-node-icon.vue │ ├── speech-to-text-node-icon.vue │ ├── start-node-icon.vue │ ├── text-to-speech-node-icon.vue │ ├── utils.ts │ └── variable-assign-node-icon.vue │ ├── index.vue │ ├── nodes │ ├── ai-chat-node │ │ ├── index.ts │ │ └── index.vue │ ├── application-node │ │ ├── index.ts │ │ └── index.vue │ ├── base-node │ │ ├── component │ │ │ ├── ApiFieldFormDialog.vue │ │ │ ├── ApiInputFieldTable.vue │ │ │ ├── FileUploadSettingDialog.vue │ │ │ ├── UserFieldFormDialog.vue │ │ │ ├── UserInputFieldTable.vue │ │ │ └── UserInputTitleDialog.vue │ │ ├── index.ts │ │ └── index.vue │ ├── condition-node │ │ ├── index.ts │ │ └── index.vue │ ├── document-extract-node │ │ ├── index.ts │ │ └── index.vue │ ├── form-node │ │ ├── index.ts │ │ └── index.vue │ ├── function-lib-node │ │ ├── index.ts │ │ └── index.vue │ ├── function-node │ │ ├── index.ts │ │ └── index.vue │ ├── image-generate │ │ ├── index.ts │ │ └── index.vue │ ├── image-understand │ │ ├── index.ts │ │ └── index.vue │ ├── mcp-node │ │ ├── index.ts │ │ └── index.vue │ ├── question-node │ │ ├── index.ts │ │ └── index.vue │ ├── reply-node │ │ ├── index.ts │ │ └── index.vue │ ├── reranker-node │ │ ├── ParamSettingDialog.vue │ │ ├── index.ts │ │ └── index.vue │ ├── search-dataset-node │ │ ├── index.ts │ │ └── index.vue │ ├── speech-to-text-node │ │ ├── index.ts │ │ └── index.vue │ ├── start-node │ │ ├── index.ts │ │ └── index.vue │ ├── text-to-speech-node │ │ ├── index.ts │ │ └── index.vue │ └── variable-assign-node │ │ ├── index.ts │ │ └── index.vue │ └── plugins │ └── dagre.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.node.json ├── tsconfig.vitest.json ├── vite.config.ts └── vitest.config.ts /.dockerignore: -------------------------------------------------------------------------------- 1 | .git* 2 | .idea* 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Questions & Discussions 4 | url: https://github.com/1Panel-dev/MaxKB/discussions 5 | about: Raise questions about the installation, deployment, use and other aspects of the project. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### What this PR does / why we need it? 2 | 3 | #### Summary of your change 4 | 5 | #### Please indicate you've done the following: 6 | 7 | - [ ] Made sure tests are passing and test coverage is added if needed. 8 | - [ ] Made sure commit message follow the rule of [Conventional Commits specification](https://www.conventionalcommits.org/). 9 | - [ ] Considered the docs impact and opened a new docs issue or PR with docs changes if needed. -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "pip" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | timezone: "Asia/Shanghai" 8 | day: "friday" 9 | target-branch: "v2" 10 | groups: 11 | python-dependencies: 12 | patterns: 13 | - "*" 14 | 15 | -------------------------------------------------------------------------------- /.github/workflows/create-pr-from-push.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - 'pr@**' 5 | - 'repr@**' 6 | 7 | name: 针对特定分支名自动创建 PR 8 | 9 | jobs: 10 | generic_handler: 11 | name: 自动创建 PR 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Create pull request 15 | uses: jumpserver/action-generic-handler@master 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 18 | -------------------------------------------------------------------------------- /.github/workflows/issue-translator.yml: -------------------------------------------------------------------------------- 1 | name: Issue Translator 2 | on: 3 | issue_comment: 4 | types: [created] 5 | issues: 6 | types: [opened] 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: usthe/issues-translate-action@v2.7 12 | with: 13 | IS_MODIFY_TITLE: true 14 | BOT_GITHUB_TOKEN: ${{ secrets.FIT2CLOUDRD_LLM_CODE_REVIEW_TOKEN }} 15 | -------------------------------------------------------------------------------- /.github/workflows/sync2gitee.yml: -------------------------------------------------------------------------------- 1 | name: sync2gitee 2 | on: [push] 3 | 4 | jobs: 5 | repo-sync: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Mirror the Github organization repos to Gitee. 9 | uses: Yikun/hub-mirror-action@master 10 | with: 11 | src: 'github/1Panel-dev' 12 | dst: 'gitee/fit2cloud-feizhiyun' 13 | dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} 14 | dst_token: ${{ secrets.GITEE_TOKEN }} 15 | static_list: "MaxKB" 16 | force_update: true -------------------------------------------------------------------------------- /.github/workflows/typos_check.yml: -------------------------------------------------------------------------------- 1 | name: Typos Check 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | types: [opened, synchronize, reopened] 8 | 9 | jobs: 10 | run: 11 | name: Spell Check with Typos 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout Actions Repository 15 | uses: actions/checkout@v2 16 | 17 | - name: Check spelling 18 | uses: crate-ci/typos@master 19 | -------------------------------------------------------------------------------- /.idea/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/.idea/icon.png -------------------------------------------------------------------------------- /.typos.toml: -------------------------------------------------------------------------------- 1 | [files] 2 | extend-exclude = [ 3 | 'apps/setting/models_provider/impl/*/icon/*' 4 | ] 5 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # 安全说明 2 | 3 | 如果您发现安全问题,请直接联系我们: 4 | 5 | - support@fit2cloud.com 6 | - 400-052-0755 7 | 8 | 感谢您的支持! 9 | 10 | # Security Policy 11 | 12 | All security bugs should be reported to the contact as below: 13 | 14 | - support@fit2cloud.com 15 | - 400-052-0755 16 | 17 | Thanks for your support! -------------------------------------------------------------------------------- /apps/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/__init__.py -------------------------------------------------------------------------------- /apps/application/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/application/__init__.py -------------------------------------------------------------------------------- /apps/application/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apps/application/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ApplicationConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'application' 7 | -------------------------------------------------------------------------------- /apps/application/chat_pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/1/9 17:23 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/application/chat_pipeline/step/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/1/9 18:23 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/application/chat_pipeline/step/chat_step/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/1/9 18:23 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/application/chat_pipeline/step/generate_human_message_step/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/1/9 18:23 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/application/chat_pipeline/step/reset_problem_step/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/1/9 18:23 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/application/chat_pipeline/step/search_dataset_step/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/1/9 18:24 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/application/flow/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/6/7 14:43 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/ai_chat_step_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:29 7 | @desc: 8 | """ 9 | from .impl import * 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/ai_chat_step_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:34 7 | @desc: 8 | """ 9 | from .base_chat_node import BaseChatNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/application_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | from .impl import * 3 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/application_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | from .base_application_node import BaseApplicationNode 3 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/6/7 14:43 7 | @desc: 8 | """ 9 | from .impl import * 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: compare.py 6 | @date:2024/6/7 14:37 7 | @desc: 8 | """ 9 | from abc import abstractmethod 10 | from typing import List 11 | 12 | 13 | class Compare: 14 | @abstractmethod 15 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 16 | pass 17 | 18 | @abstractmethod 19 | def compare(self, source_value, compare, target_value): 20 | pass 21 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/contain_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: contain_compare.py 6 | @date:2024/6/11 10:02 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class ContainCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'contain': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | if isinstance(source_value, str): 22 | return str(target_value) in source_value 23 | return any([str(item) == str(target_value) for item in source_value]) 24 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/equal_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: equal_compare.py 6 | @date:2024/6/7 14:44 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class EqualCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'eq': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | return str(source_value) == str(target_value) 22 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/ge_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 大于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class GECompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'ge': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return float(source_value) >= float(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/gt_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 大于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class GTCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'gt': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return float(source_value) > float(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/is_not_null_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: is_not_null_compare.py 6 | @date:2024/6/28 10:45 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare import Compare 12 | 13 | 14 | class IsNotNullCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'is_not_null': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | return source_value is not None and len(source_value) > 0 22 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/is_not_true.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: is_not_true.py 6 | @date:2025/4/7 13:44 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare import Compare 12 | 13 | 14 | class IsNotTrueCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'is_not_true': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return source_value is False 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/is_null_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: is_null_compare.py 6 | @date:2024/6/28 10:45 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare import Compare 12 | 13 | 14 | class IsNullCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'is_null': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | return source_value is None or len(source_value) == 0 22 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/is_true.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: IsTrue.py 6 | @date:2025/4/7 13:38 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare import Compare 12 | 13 | 14 | class IsTrueCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'is_true': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return source_value is True 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/le_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 小于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class LECompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'le': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return float(source_value) <= float(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/len_equal_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: equal_compare.py 6 | @date:2024/6/7 14:44 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class LenEqualCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'len_eq': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return len(source_value) == int(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/len_ge_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 大于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class LenGECompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'len_ge': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return len(source_value) >= int(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/len_gt_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 大于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class LenGTCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'len_gt': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return len(source_value) > int(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/len_le_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 小于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class LenLECompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'len_le': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return len(source_value) <= int(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/len_lt_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 小于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class LenLTCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'len_lt': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return len(source_value) < int(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/lt_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: lt_compare.py 6 | @date:2024/6/11 9:52 7 | @desc: 小于比较器 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class LTCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'lt': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | try: 22 | return float(source_value) < float(target_value) 23 | except Exception as e: 24 | return False 25 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/compare/not_contain_compare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: contain_compare.py 6 | @date:2024/6/11 10:02 7 | @desc: 8 | """ 9 | from typing import List 10 | 11 | from application.flow.step_node.condition_node.compare.compare import Compare 12 | 13 | 14 | class NotContainCompare(Compare): 15 | 16 | def support(self, node_id, fields: List[str], source_value, compare, target_value): 17 | if compare == 'not_contain': 18 | return True 19 | 20 | def compare(self, source_value, compare, target_value): 21 | if isinstance(source_value, str): 22 | return str(target_value) not in source_value 23 | return not any([str(item) == str(target_value) for item in source_value]) 24 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/condition_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:35 7 | @desc: 8 | """ 9 | from .base_condition_node import BaseConditionNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/direct_reply_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 17:50 7 | @desc: 8 | """ 9 | from .impl import * -------------------------------------------------------------------------------- /apps/application/flow/step_node/direct_reply_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 17:49 7 | @desc: 8 | """ 9 | from .base_reply_node import * -------------------------------------------------------------------------------- /apps/application/flow/step_node/document_extract_node/__init__.py: -------------------------------------------------------------------------------- 1 | from .impl import * -------------------------------------------------------------------------------- /apps/application/flow/step_node/document_extract_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_document_extract_node import BaseDocumentExtractNode 2 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/form_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/11/4 14:48 7 | @desc: 8 | """ 9 | from .impl import * -------------------------------------------------------------------------------- /apps/application/flow/step_node/form_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/11/4 14:49 7 | @desc: 8 | """ 9 | from .base_form_node import BaseFormNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/function_lib_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/8/8 17:45 7 | @desc: 8 | """ 9 | from .impl import * -------------------------------------------------------------------------------- /apps/application/flow/step_node/function_lib_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/8/8 17:48 7 | @desc: 8 | """ 9 | from .base_function_lib_node import BaseFunctionLibNodeNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/function_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/8/13 10:43 7 | @desc: 8 | """ 9 | from .impl import * -------------------------------------------------------------------------------- /apps/application/flow/step_node/function_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/8/13 11:19 7 | @desc: 8 | """ 9 | from .base_function_node import BaseFunctionNodeNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/image_generate_step_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .impl import * 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/image_generate_step_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .base_image_generate_node import BaseImageGenerateNode 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/image_understand_step_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .impl import * 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/image_understand_step_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .base_image_understand_node import BaseImageUnderstandNode 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/mcp_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .impl import * 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/mcp_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .base_mcp_node import BaseMcpNode 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/question_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:30 7 | @desc: 8 | """ 9 | from .impl import * 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/question_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:35 7 | @desc: 8 | """ 9 | from .base_question_node import BaseQuestionNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/reranker_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/9/4 11:37 7 | @desc: 8 | """ 9 | from .impl import * 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/reranker_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/9/4 11:39 7 | @desc: 8 | """ 9 | from .base_reranker_node import * 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/search_dataset_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:30 7 | @desc: 8 | """ 9 | from .impl import * 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/search_dataset_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:35 7 | @desc: 8 | """ 9 | from .base_search_dataset_node import BaseSearchDatasetNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/speech_to_text_step_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .impl import * 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/speech_to_text_step_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .base_speech_to_text_node import BaseSpeechToTextNode 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/start_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:30 7 | @desc: 8 | """ 9 | from .impl import * 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/start_node/i_start_node.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: i_start_node.py 6 | @date:2024/6/3 16:54 7 | @desc: 8 | """ 9 | 10 | from application.flow.i_step_node import INode, NodeResult 11 | 12 | 13 | class IStarNode(INode): 14 | type = 'start-node' 15 | 16 | def _run(self): 17 | return self.execute(**self.flow_params_serializer.data) 18 | 19 | def execute(self, question, **kwargs) -> NodeResult: 20 | pass 21 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/start_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 15:36 7 | @desc: 8 | """ 9 | from .base_start_node import BaseStartStepNode 10 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/text_to_speech_step_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .impl import * 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/text_to_speech_step_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .base_text_to_speech_node import BaseTextToSpeechNode 4 | -------------------------------------------------------------------------------- /apps/application/flow/step_node/variable_assign_node/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | from .impl import * -------------------------------------------------------------------------------- /apps/application/flow/step_node/variable_assign_node/impl/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/6/11 17:49 7 | @desc: 8 | """ 9 | from .base_variable_assign_node import * -------------------------------------------------------------------------------- /apps/application/migrations/0002_chat_client_id.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-03-28 13:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='chat', 15 | name='client_id', 16 | field=models.UUIDField(default=None, null=True, verbose_name='客户端id'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0003_application_icon.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-04-23 11:16 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0002_chat_client_id'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='application', 15 | name='icon', 16 | field=models.CharField(default='/ui/favicon.ico', max_length=256, verbose_name='应用icon'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0004_applicationaccesstoken_show_source.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-04-25 11:28 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0003_application_icon'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='applicationaccesstoken', 15 | name='show_source', 16 | field=models.BooleanField(default=False, verbose_name='是否显示知识来源'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0005_alter_chat_abstract_alter_chatrecord_answer_text.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-04-29 13:33 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0004_applicationaccesstoken_show_source'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='chat', 15 | name='abstract', 16 | field=models.CharField(max_length=1024, verbose_name='摘要'), 17 | ), 18 | migrations.AlterField( 19 | model_name='chatrecord', 20 | name='answer_text', 21 | field=models.CharField(max_length=40960, verbose_name='答案'), 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /apps/application/migrations/0007_alter_application_prologue.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-05-24 11:00 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0006_applicationapikey_allow_cross_domain_and_more'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='application', 15 | name='prologue', 16 | field=models.CharField(default='', max_length=4096, verbose_name='开场白'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0008_chat_is_deleted.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-06-13 11:46 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0007_alter_application_prologue'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='chat', 15 | name='is_deleted', 16 | field=models.BooleanField(default=False, verbose_name=''), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0010_alter_chatrecord_details.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.13 on 2024-07-15 15:52 2 | 3 | from django.db import migrations, models 4 | 5 | import common.encoder.encoder 6 | 7 | 8 | class Migration(migrations.Migration): 9 | dependencies = [ 10 | ('application', '0009_application_type_application_work_flow_and_more'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterField( 15 | model_name='chatrecord', 16 | name='details', 17 | field=models.JSONField(default=dict, encoder=common.encoder.encoder.SystemEncoder, verbose_name='对话详情'), 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /apps/application/migrations/0011_application_model_params_setting.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-08-23 14:17 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0010_alter_chatrecord_details'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='application', 15 | name='model_params_setting', 16 | field=models.JSONField(default=dict, verbose_name='模型参数相关设置'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0013_application_tts_type.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-09-12 11:01 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0012_application_stt_model_application_stt_model_enable_and_more'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='application', 15 | name='tts_type', 16 | field=models.CharField(default='BROWSER', max_length=20, verbose_name='语音播放类型'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0014_application_problem_optimization_prompt.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-09-13 18:57 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0013_application_tts_type'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='application', 15 | name='problem_optimization_prompt', 16 | field=models.CharField(blank=True, default='()里面是用户问题,根据上下文回答揣测用户问题({question}) 要求: 输出一个补全问题,并且放在标签中', max_length=102400, null=True, verbose_name='问题优化提示词'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0016_alter_chatrecord_problem_text.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-09-26 13:19 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0015_re_database_index'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='chatrecord', 15 | name='problem_text', 16 | field=models.CharField(max_length=10240, verbose_name='问题'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0017_application_tts_model_params_setting.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-10-16 13:10 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0016_alter_chatrecord_problem_text'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='application', 15 | name='tts_model_params_setting', 16 | field=models.JSONField(default=dict, verbose_name='模型参数相关设置'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0020_application_record_update_time.py: -------------------------------------------------------------------------------- 1 | from django.db import migrations, connection 2 | 3 | batch_update_update_time = """ 4 | UPDATE application_chat ac 5 | SET update_time = acr_max.max_update_time 6 | FROM ( 7 | SELECT chat_id, MAX(update_time) AS max_update_time 8 | FROM application_chat_record 9 | GROUP BY chat_id 10 | ) acr_max 11 | WHERE ac.id = acr_max.chat_id; 12 | """ 13 | 14 | 15 | class Migration(migrations.Migration): 16 | dependencies = [ 17 | ('application', '0019_application_file_upload_enable_and_more'), 18 | ] 19 | 20 | operations = [ 21 | migrations.RunSQL(batch_update_update_time), 22 | ] 23 | -------------------------------------------------------------------------------- /apps/application/migrations/0022_application_tts_autoplay.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2025-01-03 14:07 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0021_applicationpublicaccessclient_client_id_and_more'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='application', 15 | name='tts_autoplay', 16 | field=models.BooleanField(default=False, verbose_name='自动播放'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0023_application_stt_autosend.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2025-01-06 10:37 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0022_application_tts_autoplay'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='application', 15 | name='stt_autosend', 16 | field=models.BooleanField(default=False, verbose_name='自动发送'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0024_applicationaccesstoken_language.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2025-01-20 06:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ('application', '0023_application_stt_autosend'), 9 | ] 10 | 11 | operations = [ 12 | migrations.AddField( 13 | model_name='applicationaccesstoken', 14 | name='language', 15 | field=models.CharField(default=None, max_length=10, null=True, verbose_name='语言') 16 | ), 17 | ] 18 | -------------------------------------------------------------------------------- /apps/application/migrations/0025_alter_application_prologue.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.18 on 2025-01-22 09:53 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('application', '0024_applicationaccesstoken_language'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='application', 15 | name='prologue', 16 | field=models.CharField(default='', max_length=40960, verbose_name='开场白'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/application/migrations/0026_chat_asker.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.18 on 2025-03-18 06:05 2 | 3 | import application.models.application 4 | import common.encoder.encoder 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('application', '0025_alter_application_prologue'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AddField( 16 | model_name='chat', 17 | name='asker', 18 | field=models.JSONField(default=application.models.application.default_asker, encoder=common.encoder.encoder.SystemEncoder, verbose_name='访问者'), 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /apps/application/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/application/migrations/__init__.py -------------------------------------------------------------------------------- /apps/application/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/25 14:25 7 | @desc: 8 | """ 9 | from .application import * 10 | -------------------------------------------------------------------------------- /apps/application/sql/chat_record_count.sql: -------------------------------------------------------------------------------- 1 | SELECT SUM 2 | ( CASE WHEN application_chat_record.vote_status = '0' THEN 1 ELSE 0 END ) AS "star_num", 3 | SUM ( CASE WHEN application_chat_record.vote_status = '1' THEN 1 ELSE 0 END ) AS "trample_num", 4 | SUM ( application_chat_record.message_tokens + application_chat_record.answer_tokens ) as "tokens_num", 5 | "count"(DISTINCT application_chat.client_id) customer_num, 6 | "count"(application_chat_record."id") as chat_record_count 7 | FROM 8 | application_chat_record application_chat_record 9 | LEFT JOIN application_chat application_chat ON application_chat."id" = application_chat_record.chat_id -------------------------------------------------------------------------------- /apps/application/sql/chat_record_count_trend.sql: -------------------------------------------------------------------------------- 1 | SELECT SUM 2 | ( CASE WHEN application_chat_record.vote_status = '0' THEN 1 ELSE 0 END ) AS "star_num", 3 | SUM ( CASE WHEN application_chat_record.vote_status = '1' THEN 1 ELSE 0 END ) AS "trample_num", 4 | SUM ( application_chat_record.message_tokens + application_chat_record.answer_tokens ) as "tokens_num", 5 | "count"(application_chat_record."id") as chat_record_count, 6 | "count"(DISTINCT application_chat.client_id) customer_num, 7 | application_chat_record.create_time :: DATE as "day" 8 | FROM 9 | application_chat_record application_chat_record 10 | LEFT JOIN application_chat application_chat ON application_chat."id" = application_chat_record.chat_id 11 | ${default_sql} 12 | GROUP BY "day" -------------------------------------------------------------------------------- /apps/application/sql/customer_count.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ( SUM ( CASE WHEN create_time :: DATE = CURRENT_DATE THEN 1 ELSE 0 END ) ) AS "customer_today_added_count", 3 | COUNT ( "application_public_access_client"."id" ) AS "customer_added_count" 4 | FROM 5 | "application_public_access_client" -------------------------------------------------------------------------------- /apps/application/sql/customer_count_trend.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | COUNT ( "application_public_access_client"."id" ) AS "customer_added_count", 3 | create_time :: DATE as "day" 4 | FROM 5 | "application_public_access_client" 6 | ${default_sql} 7 | GROUP BY "day" -------------------------------------------------------------------------------- /apps/application/sql/list_application.sql: -------------------------------------------------------------------------------- 1 | SELECT *,to_json(dataset_setting) as dataset_setting,to_json(model_setting) as model_setting,to_json(work_flow) as work_flow FROM ( SELECT * FROM application ${application_custom_sql} UNION 2 | SELECT 3 | * 4 | FROM 5 | application 6 | WHERE 7 | application."id" IN ( SELECT team_member_permission.target FROM team_member team_member LEFT JOIN team_member_permission team_member_permission ON team_member_permission.member_id = team_member."id" ${team_member_permission_custom_sql}) 8 | ) temp_application ${default_sql} -------------------------------------------------------------------------------- /apps/application/sql/list_application_chat.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | *,to_json(asker) as asker 3 | FROM 4 | application_chat application_chat 5 | LEFT JOIN ( 6 | SELECT COUNT 7 | ( "id" ) AS chat_record_count, 8 | SUM ( CASE WHEN "vote_status" = '0' THEN 1 ELSE 0 END ) AS star_num, 9 | SUM ( CASE WHEN "vote_status" = '1' THEN 1 ELSE 0 END ) AS trample_num, 10 | SUM ( CASE WHEN array_length( application_chat_record.improve_paragraph_id_list, 1 ) IS NULL THEN 0 ELSE array_length( application_chat_record.improve_paragraph_id_list, 1 ) END ) AS mark_sum, 11 | chat_id 12 | FROM 13 | application_chat_record 14 | WHERE chat_id IN ( 15 | SELECT id FROM application_chat ${inner_queryset}) 16 | GROUP BY 17 | application_chat_record.chat_id 18 | ) chat_record_temp ON application_chat."id" = chat_record_temp.chat_id 19 | ${default_queryset} -------------------------------------------------------------------------------- /apps/application/sql/list_application_dataset.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | * 3 | FROM 4 | dataset 5 | WHERE 6 | user_id = %s UNION 7 | SELECT 8 | * 9 | FROM 10 | dataset 11 | WHERE 12 | "id" IN ( 13 | SELECT 14 | team_member_permission.target 15 | FROM 16 | team_member team_member 17 | LEFT JOIN team_member_permission team_member_permission ON team_member_permission.member_id = team_member."id" 18 | WHERE 19 | ( "team_member_permission"."auth_target_type" = 'DATASET' AND "team_member_permission"."operate"::text[] @> ARRAY['USE'] AND team_member.team_id = %s AND team_member.user_id =%s ) 20 | ) -------------------------------------------------------------------------------- /apps/application/sql/list_dataset_paragraph_by_paragraph_id.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | paragraph.*, 3 | dataset."name" AS "dataset_name", 4 | "document"."name" AS "document_name", 5 | "document"."meta" AS "meta", 6 | "document"."hit_handling_method" AS "hit_handling_method", 7 | "document"."directly_return_similarity" as "directly_return_similarity" 8 | FROM 9 | paragraph paragraph 10 | LEFT JOIN dataset dataset ON dataset."id" = paragraph.dataset_id 11 | LEFT JOIN "document" "document" ON "document"."id" =paragraph.document_id -------------------------------------------------------------------------------- /apps/application/task/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/application/task/__init__.py -------------------------------------------------------------------------------- /apps/application/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apps/application/views/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/9/25 17:12 7 | @desc: 8 | """ 9 | from .application_views import * 10 | from .chat_views import * 11 | from .application_version_views import * 12 | -------------------------------------------------------------------------------- /apps/application/views/common.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: common.py 6 | @date:2025/3/25 16:56 7 | @desc: 8 | """ 9 | 10 | from django.db.models import QuerySet 11 | 12 | from application.models import Application 13 | 14 | 15 | def get_application_operation_object(application_id): 16 | application_model = QuerySet(model=Application).filter(id=application_id).first() 17 | if application_model is not None: 18 | return { 19 | "name": application_model.name 20 | } 21 | return {} 22 | -------------------------------------------------------------------------------- /apps/common/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: smart-doc 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/14 16:22 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/common/auth/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: smart-doc 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/14 19:44 7 | @desc: 8 | """ 9 | from .authenticate import * 10 | from .authentication import * 11 | -------------------------------------------------------------------------------- /apps/common/auth/handle/auth_base_handle.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: qabot 4 | @Author:虎 5 | @file: authenticate.py 6 | @date:2024/3/14 03:02 7 | @desc: 认证处理器 8 | """ 9 | from abc import ABC, abstractmethod 10 | 11 | 12 | class AuthBaseHandle(ABC): 13 | @abstractmethod 14 | def support(self, request, token: str, get_token_details): 15 | pass 16 | 17 | @abstractmethod 18 | def handle(self, request, token: str, get_token_details): 19 | pass 20 | -------------------------------------------------------------------------------- /apps/common/cache_data/static_resource_cache.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: static_resource_cache.py 6 | @date:2024/7/25 11:30 7 | @desc: 8 | """ 9 | from common.constants.cache_code_constants import CacheCodeConstants 10 | from common.util.cache_util import get_cache 11 | 12 | 13 | @get_cache(cache_key=lambda index_path: index_path, 14 | version=CacheCodeConstants.STATIC_RESOURCE_CACHE.value) 15 | def get_index_html(index_path): 16 | file = open(index_path, "r", encoding='utf-8') 17 | content = file.read() 18 | file.close() 19 | return content 20 | -------------------------------------------------------------------------------- /apps/common/chunk/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/7/23 17:03 7 | @desc: 8 | """ 9 | from common.chunk.impl.mark_chunk_handle import MarkChunkHandle 10 | 11 | handles = [MarkChunkHandle()] 12 | 13 | 14 | def text_to_chunk(text: str): 15 | chunk_list = [text] 16 | for handle in handles: 17 | chunk_list = handle.handle(chunk_list) 18 | return chunk_list 19 | -------------------------------------------------------------------------------- /apps/common/chunk/i_chunk_handle.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: i_chunk_handle.py 6 | @date:2024/7/23 16:51 7 | @desc: 8 | """ 9 | from abc import ABC, abstractmethod 10 | from typing import List 11 | 12 | 13 | class IChunkHandle(ABC): 14 | @abstractmethod 15 | def handle(self, chunk_list: List[str]): 16 | pass 17 | -------------------------------------------------------------------------------- /apps/common/config/tokenizer_manage_config.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: tokenizer_manage_config.py 6 | @date:2024/4/28 10:17 7 | @desc: 8 | """ 9 | 10 | 11 | class TokenizerManage: 12 | tokenizer = None 13 | 14 | @staticmethod 15 | def get_tokenizer(): 16 | from transformers import GPT2TokenizerFast 17 | if TokenizerManage.tokenizer is None: 18 | TokenizerManage.tokenizer = GPT2TokenizerFast.from_pretrained( 19 | 'gpt2', 20 | cache_dir="/opt/maxkb/model/tokenizer", 21 | local_files_only=True, 22 | resume_download=False, 23 | force_download=False) 24 | return TokenizerManage.tokenizer 25 | -------------------------------------------------------------------------------- /apps/common/constants/authentication_type.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: authentication_type.py 6 | @date:2023/11/14 20:03 7 | @desc: 8 | """ 9 | from enum import Enum 10 | 11 | 12 | class AuthenticationType(Enum): 13 | # 普通用户 14 | USER = "USER" 15 | # 公共访问链接 16 | APPLICATION_ACCESS_TOKEN = "APPLICATION_ACCESS_TOKEN" 17 | # key API 18 | API_KEY = "API_KEY" 19 | # 第三方对接 20 | PLATFORM = 'PLATFORM' 21 | -------------------------------------------------------------------------------- /apps/common/constants/cache_code_constants.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: cache_code_constants.py 6 | @date:2024/7/24 18:20 7 | @desc: 8 | """ 9 | from enum import Enum 10 | 11 | 12 | class CacheCodeConstants(Enum): 13 | # 应用ACCESS_TOKEN缓存 14 | APPLICATION_ACCESS_TOKEN_CACHE = 'APPLICATION_ACCESS_TOKEN_CACHE' 15 | # 静态资源缓存 16 | STATIC_RESOURCE_CACHE = 'STATIC_RESOURCE_CACHE' 17 | # 应用API_KEY缓存 18 | APPLICATION_API_KEY_CACHE = 'APPLICATION_API_KEY_CACHE' 19 | -------------------------------------------------------------------------------- /apps/common/field/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/common/field/__init__.py -------------------------------------------------------------------------------- /apps/common/field/vector_field.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class VectorField(models.Field): 5 | 6 | def db_type(self, connection): 7 | return 'vector' 8 | 9 | 10 | class TsVectorField(models.Field): 11 | def db_type(self, connection): 12 | return 'tsvector' 13 | -------------------------------------------------------------------------------- /apps/common/forms/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/10/31 17:56 7 | @desc: 8 | """ 9 | from .array_object_card import * 10 | from .base_field import * 11 | from .base_form import * 12 | from .multi_select import * 13 | from .object_card import * 14 | from .password_input import * 15 | from .radio_field import * 16 | from .single_select_field import * 17 | from .tab_card import * 18 | from .table_radio import * 19 | from .text_input_field import * 20 | from .radio_button_field import * 21 | from .table_checkbox import * 22 | from .radio_card_field import * 23 | from .label import * 24 | from .slider_field import * 25 | from .switch_field import * 26 | -------------------------------------------------------------------------------- /apps/common/forms/label/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/8/22 17:19 7 | @desc: 8 | """ 9 | from .base_label import * 10 | from .tooltip_label import * 11 | -------------------------------------------------------------------------------- /apps/common/forms/label/tooltip_label.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: tooltip_label.py 6 | @date:2024/8/22 17:19 7 | @desc: 8 | """ 9 | from common.forms.label.base_label import BaseLabel 10 | 11 | 12 | class TooltipLabel(BaseLabel): 13 | def __init__(self, label, tooltip): 14 | super().__init__('TooltipLabel', label, attrs={'tooltip': tooltip}, props_info={}) 15 | -------------------------------------------------------------------------------- /apps/common/forms/password_input.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: password_input.py 6 | @date:2023/11/1 14:48 7 | @desc: 8 | """ 9 | from typing import Dict 10 | 11 | from common.forms import BaseField, TriggerType 12 | 13 | 14 | class PasswordInputField(BaseField): 15 | """ 16 | 文本输入框 17 | """ 18 | 19 | def __init__(self, label: str, 20 | required: bool = False, 21 | default_value=None, 22 | relation_show_field_dict: Dict = None, 23 | attrs=None, props_info=None): 24 | super().__init__('PasswordInput', label, required, default_value, relation_show_field_dict, 25 | {}, 26 | TriggerType.OPTION_LIST, attrs, props_info) 27 | -------------------------------------------------------------------------------- /apps/common/handle/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: qabot 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/9/6 10:09 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/common/handle/base_parse_table_handle.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: base_parse_qa_handle.py 6 | @date:2024/5/21 14:56 7 | @desc: 8 | """ 9 | from abc import ABC, abstractmethod 10 | 11 | 12 | class BaseParseTableHandle(ABC): 13 | @abstractmethod 14 | def support(self, file, get_buffer): 15 | pass 16 | 17 | @abstractmethod 18 | def handle(self, file, get_buffer,save_image): 19 | pass 20 | 21 | @abstractmethod 22 | def get_content(self, file, save_image): 23 | pass -------------------------------------------------------------------------------- /apps/common/handle/base_split_handle.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: base_split_handle.py 6 | @date:2024/3/27 18:13 7 | @desc: 8 | """ 9 | from abc import ABC, abstractmethod 10 | from typing import List 11 | 12 | 13 | class BaseSplitHandle(ABC): 14 | @abstractmethod 15 | def support(self, file, get_buffer): 16 | pass 17 | 18 | @abstractmethod 19 | def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image): 20 | pass 21 | 22 | @abstractmethod 23 | def get_content(self, file, save_image): 24 | pass 25 | -------------------------------------------------------------------------------- /apps/common/job/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/3/14 11:54 7 | @desc: 8 | """ 9 | from .client_access_num_job import * 10 | from .clean_chat_job import * 11 | from .clean_debug_file_job import * 12 | 13 | 14 | def run(): 15 | client_access_num_job.run() 16 | clean_chat_job.run() 17 | clean_debug_file_job.run() 18 | -------------------------------------------------------------------------------- /apps/common/lock/base_lock.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: base_lock.py 6 | @date:2024/8/20 10:33 7 | @desc: 8 | """ 9 | 10 | from abc import ABC, abstractmethod 11 | 12 | 13 | class BaseLock(ABC): 14 | @abstractmethod 15 | def try_lock(self, key, timeout): 16 | pass 17 | 18 | @abstractmethod 19 | def un_lock(self, key): 20 | pass 21 | -------------------------------------------------------------------------------- /apps/common/management/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/common/management/__init__.py -------------------------------------------------------------------------------- /apps/common/management/commands/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/common/management/commands/__init__.py -------------------------------------------------------------------------------- /apps/common/management/commands/restart.py: -------------------------------------------------------------------------------- 1 | from .services.command import BaseActionCommand, Action 2 | 3 | 4 | class Command(BaseActionCommand): 5 | help = 'Restart services' 6 | action = Action.restart.value 7 | -------------------------------------------------------------------------------- /apps/common/management/commands/services/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/common/management/commands/services/__init__.py -------------------------------------------------------------------------------- /apps/common/management/commands/services/hands.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | import sys 4 | 5 | from smartdoc.const import CONFIG, PROJECT_DIR 6 | 7 | try: 8 | from apps.smartdoc import const 9 | 10 | __version__ = const.VERSION 11 | except ImportError as e: 12 | print("Not found __version__: {}".format(e)) 13 | print("Python is: ") 14 | logging.info(sys.executable) 15 | __version__ = 'Unknown' 16 | sys.exit(1) 17 | 18 | HTTP_HOST = '0.0.0.0' 19 | HTTP_PORT = CONFIG.HTTP_LISTEN_PORT or 8080 20 | DEBUG = CONFIG.DEBUG or False 21 | 22 | LOG_DIR = os.path.join(PROJECT_DIR, 'data', 'logs') 23 | APPS_DIR = os.path.join(PROJECT_DIR, 'apps') 24 | TMP_DIR = os.path.join(PROJECT_DIR, 'tmp') 25 | if not os.path.exists(TMP_DIR): 26 | os.makedirs(TMP_DIR) 27 | -------------------------------------------------------------------------------- /apps/common/management/commands/services/services/__init__.py: -------------------------------------------------------------------------------- 1 | from .celery_default import * 2 | from .gunicorn import * 3 | from .local_model import * -------------------------------------------------------------------------------- /apps/common/management/commands/services/services/celery_default.py: -------------------------------------------------------------------------------- 1 | from .celery_base import CeleryBaseService 2 | 3 | __all__ = ['CeleryDefaultService'] 4 | 5 | 6 | class CeleryDefaultService(CeleryBaseService): 7 | 8 | def __init__(self, **kwargs): 9 | kwargs['queue'] = 'celery' 10 | super().__init__(**kwargs) 11 | -------------------------------------------------------------------------------- /apps/common/management/commands/start.py: -------------------------------------------------------------------------------- 1 | from .services.command import BaseActionCommand, Action 2 | 3 | 4 | class Command(BaseActionCommand): 5 | help = 'Start services' 6 | action = Action.start.value 7 | -------------------------------------------------------------------------------- /apps/common/management/commands/status.py: -------------------------------------------------------------------------------- 1 | from .services.command import BaseActionCommand, Action 2 | 3 | 4 | class Command(BaseActionCommand): 5 | help = 'Show services status' 6 | action = Action.status.value 7 | -------------------------------------------------------------------------------- /apps/common/management/commands/stop.py: -------------------------------------------------------------------------------- 1 | from .services.command import BaseActionCommand, Action 2 | 3 | 4 | class Command(BaseActionCommand): 5 | help = 'Stop services' 6 | action = Action.stop.value 7 | -------------------------------------------------------------------------------- /apps/common/mixins/api_mixin.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: smart-doc 4 | @Author:虎 5 | @file: api_mixin.py 6 | @date:2023/9/14 17:50 7 | @desc: 8 | """ 9 | from rest_framework import serializers 10 | 11 | 12 | class ApiMixin(serializers.Serializer): 13 | 14 | @staticmethod 15 | def get_request_params_api(): 16 | pass 17 | 18 | @staticmethod 19 | def get_request_body_api(): 20 | pass 21 | 22 | @staticmethod 23 | def get_response_body_api(): 24 | pass 25 | -------------------------------------------------------------------------------- /apps/common/mixins/app_model_mixin.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: app_model_mixin.py 6 | @date:2023/9/21 9:41 7 | @desc: 8 | """ 9 | from django.db import models 10 | 11 | 12 | class AppModelMixin(models.Model): 13 | create_time = models.DateTimeField(verbose_name="创建时间", auto_now_add=True) 14 | update_time = models.DateTimeField(verbose_name="修改时间", auto_now=True) 15 | 16 | class Meta: 17 | abstract = True 18 | ordering = ['create_time'] 19 | -------------------------------------------------------------------------------- /apps/common/models/handle/base_handle.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: base_handle.py 6 | @date:2024/7/22 17:02 7 | @desc: 8 | """ 9 | from abc import ABC, abstractmethod 10 | 11 | 12 | class IBaseModelHandle(ABC): 13 | @abstractmethod 14 | def get_model_dict(self): 15 | pass 16 | -------------------------------------------------------------------------------- /apps/common/models/handle/impl/default_base_model_handle.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: default_base_model_handle.py 6 | @date:2024/7/22 17:06 7 | @desc: 8 | """ 9 | from common.models.handle.base_handle import IBaseModelHandle 10 | 11 | 12 | class DefaultBaseModelHandle(IBaseModelHandle): 13 | def get_model_dict(self): 14 | return {} 15 | -------------------------------------------------------------------------------- /apps/common/task/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/common/task/__init__.py -------------------------------------------------------------------------------- /apps/common/util/file_util.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: file_util.py 6 | @date:2023/9/25 21:06 7 | @desc: 8 | """ 9 | 10 | 11 | def get_file_content(path): 12 | with open(path, "r", encoding='utf-8') as file: 13 | content = file.read() 14 | return content 15 | -------------------------------------------------------------------------------- /apps/dataset/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/__init__.py -------------------------------------------------------------------------------- /apps/dataset/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DatasetConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'dataset' 7 | -------------------------------------------------------------------------------- /apps/dataset/migrations/0003_document_hit_handling_method.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-04-24 15:36 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('dataset', '0002_image'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='document', 15 | name='hit_handling_method', 16 | field=models.CharField(choices=[('optimization', '模型优化'), ('directly_return', '直接返回')], default='optimization', max_length=20, verbose_name='命中处理方式'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/dataset/migrations/0004_document_directly_return_similarity.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-05-08 16:43 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('dataset', '0003_document_hit_handling_method'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='document', 15 | name='directly_return_similarity', 16 | field=models.FloatField(default=0.9, verbose_name='直接回答相似度'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/dataset/migrations/0006_dataset_embedding_mode.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.13 on 2024-07-17 13:56 2 | 3 | import dataset.models.data_set 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('setting', '0005_model_permission_type'), 12 | ('dataset', '0005_file'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AddField( 17 | model_name='dataset', 18 | name='embedding_mode', 19 | field=models.ForeignKey(default=dataset.models.data_set.default_model, on_delete=django.db.models.deletion.DO_NOTHING, to='setting.model', verbose_name='向量模型'), 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /apps/dataset/migrations/0007_alter_paragraph_content.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.14 on 2024-07-24 14:35 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('dataset', '0006_dataset_embedding_mode'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='paragraph', 15 | name='content', 16 | field=models.CharField(max_length=102400, verbose_name='段落内容'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/dataset/migrations/0010_file_meta.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-11-07 15:32 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('dataset', '0009_alter_document_status_alter_paragraph_status'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='file', 15 | name='meta', 16 | field=models.JSONField(default=dict, verbose_name='文件关联数据'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/dataset/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/migrations/__init__.py -------------------------------------------------------------------------------- /apps/dataset/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/21 9:32 7 | @desc: 8 | """ 9 | from .data_set import * 10 | -------------------------------------------------------------------------------- /apps/dataset/sql/list_dataset_application.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | * 3 | FROM 4 | application 5 | WHERE 6 | user_id = %s UNION 7 | SELECT 8 | * 9 | FROM 10 | application 11 | WHERE 12 | "id" IN ( 13 | SELECT 14 | team_member_permission.target 15 | FROM 16 | team_member team_member 17 | LEFT JOIN team_member_permission team_member_permission ON team_member_permission.member_id = team_member."id" 18 | WHERE 19 | ( "team_member_permission"."auth_target_type" = 'APPLICATION' AND "team_member_permission"."operate"::text[] @> ARRAY['USE'] AND team_member.team_id = %s AND team_member.user_id =%s ) 20 | ) -------------------------------------------------------------------------------- /apps/dataset/sql/list_document.sql: -------------------------------------------------------------------------------- 1 | SELECT * from ( 2 | SELECT 3 | "document".* , 4 | to_json("document"."meta") as meta, 5 | to_json("document"."status_meta") as status_meta, 6 | (SELECT "count"("id") FROM "paragraph" WHERE document_id="document"."id") as "paragraph_count" 7 | FROM 8 | "document" "document" 9 | ${document_custom_sql} 10 | ) temp 11 | ${order_by_query} -------------------------------------------------------------------------------- /apps/dataset/sql/list_paragraph.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | (SELECT "name" FROM "document" WHERE "id"=document_id) as document_name, 3 | (SELECT "name" FROM "dataset" WHERE "id"=dataset_id) as dataset_name, 4 | * 5 | FROM 6 | "paragraph" 7 | -------------------------------------------------------------------------------- /apps/dataset/sql/list_paragraph_document_name.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | (SELECT "name" FROM "document" WHERE "id"=document_id) as document_name, 3 | * 4 | FROM 5 | "paragraph" 6 | -------------------------------------------------------------------------------- /apps/dataset/sql/list_problem.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | problem.*, 3 | (SELECT "count"("id") FROM "problem_paragraph_mapping" WHERE problem_id="problem"."id") as "paragraph_count" 4 | FROM 5 | problem problem 6 | -------------------------------------------------------------------------------- /apps/dataset/sql/list_problem_mapping.sql: -------------------------------------------------------------------------------- 1 | SELECT "problem"."content",problem_paragraph_mapping.paragraph_id FROM problem problem 2 | LEFT JOIN problem_paragraph_mapping problem_paragraph_mapping ON problem_paragraph_mapping.problem_id=problem."id" -------------------------------------------------------------------------------- /apps/dataset/sql/update_document_char_length.sql: -------------------------------------------------------------------------------- 1 | UPDATE "document" 2 | SET "char_length" = ( SELECT CASE WHEN 3 | "sum" ( "char_length" ( "content" ) ) IS NULL THEN 4 | 0 ELSE "sum" ( "char_length" ( "content" ) ) 5 | END FROM paragraph WHERE "document_id" = %s ) 6 | WHERE 7 | "id" = %s -------------------------------------------------------------------------------- /apps/dataset/sql/update_document_status_meta.sql: -------------------------------------------------------------------------------- 1 | UPDATE "document" "document" 2 | SET status_meta = jsonb_set ( "document".status_meta, '{aggs}', tmp.status_meta ) 3 | FROM 4 | ( 5 | SELECT COALESCE 6 | ( jsonb_agg ( jsonb_delete ( ( row_to_json ( record ) :: JSONB ), 'document_id' ) ), '[]' :: JSONB ) AS status_meta, 7 | document_id AS document_id 8 | FROM 9 | ( 10 | SELECT 11 | "paragraph".status, 12 | "count" ( "paragraph"."id" ), 13 | "document"."id" AS document_id 14 | FROM 15 | "document" "document" 16 | LEFT JOIN "paragraph" "paragraph" ON "document"."id" = paragraph.document_id 17 | ${document_custom_sql} 18 | GROUP BY 19 | "paragraph".status, 20 | "document"."id" 21 | ) record 22 | GROUP BY 23 | document_id 24 | ) tmp 25 | WHERE "document".id="tmp".document_id -------------------------------------------------------------------------------- /apps/dataset/sql/update_paragraph_status.sql: -------------------------------------------------------------------------------- 1 | UPDATE "${table_name}" 2 | SET status = reverse ( 3 | SUBSTRING ( reverse ( LPAD( status, ${bit_number}, 'n' ) ) :: TEXT FROM 1 FOR ${up_index} ) || ${status_number} || SUBSTRING ( reverse ( LPAD( status, ${bit_number}, 'n' ) ) :: TEXT FROM ${next_index} ) 4 | ), 5 | status_meta = jsonb_set ( 6 | "${table_name}".status_meta, 7 | '{state_time,${current_index}}', 8 | jsonb_set ( 9 | COALESCE ( "${table_name}".status_meta #> '{state_time,${current_index}}', jsonb_build_object ( '${status_number}', '${current_time}' ) ), 10 | '{${status_number}}', 11 | CONCAT ( '"', '${current_time}', '"' ) :: JSONB 12 | ) 13 | ) -------------------------------------------------------------------------------- /apps/dataset/swagger_api/image_api.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: image_api.py 6 | @date:2024/4/23 11:23 7 | @desc: 8 | """ 9 | from drf_yasg import openapi 10 | 11 | from common.mixins.api_mixin import ApiMixin 12 | from django.utils.translation import gettext_lazy as _ 13 | 14 | 15 | class ImageApi(ApiMixin): 16 | @staticmethod 17 | def get_request_params_api(): 18 | return [openapi.Parameter(name='file', 19 | in_=openapi.IN_FORM, 20 | type=openapi.TYPE_FILE, 21 | required=True, 22 | description=_('image file')) 23 | ] 24 | -------------------------------------------------------------------------------- /apps/dataset/task/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/8/21 9:57 7 | @desc: 8 | """ 9 | from .sync import * 10 | from .generate import * 11 | -------------------------------------------------------------------------------- /apps/dataset/template/csv_template_zh.csv: -------------------------------------------------------------------------------- 1 | 分段标题(选填),分段内容(必填,问题答案)),问题(选填,单元格内一行一个) 2 | MaxKB产品介绍,"MaxKB 是一款基于 LLM 大语言模型的知识库问答系统。MaxKB = Max Knowledge Base,旨在成为企业的最强大脑。 3 | 开箱即用:支持直接上传文档、自动爬取在线文档,支持文本自动拆分、向量化,智能问答交互体验好; 4 | 无缝嵌入:支持零编码快速嵌入到第三方业务系统; 5 | 多模型支持:支持对接主流的大模型,包括 Ollama 本地私有大模型(如 Llama 2、Llama 3、qwen)、通义千问、OpenAI、Azure OpenAI、Kimi、智谱 AI、讯飞星火和百度千帆大模型等。","MaxKB是什么? 6 | MaxKB产品介绍 7 | MaxKB支持的大语言模型 8 | MaxKB优势" 9 | -------------------------------------------------------------------------------- /apps/dataset/template/csv_template_zh_Hant.csv: -------------------------------------------------------------------------------- 1 | 分段標題(選填),分段內容(必填,問題答案)),問題(選填,單元格內一行一個) 2 | MaxKB產品介紹,"MaxKB 是一款基於 LLM 大語言模型的知識庫問答系統。MaxKB = Max Knowledge Base,旨在成為企業的最強大大腦。 3 | 開箱即用:支援直接上傳文檔、自動爬取線上文檔,支援文字自動分割、向量化,智慧問答互動體驗好; 4 | 無縫嵌入:支援零編碼快速嵌入到第三方業務系統; 5 | 多模型支援:支持對接主流的大模型,包括Ollama 本地私有大模型(如Llama 2、Llama 3、qwen)、通義千問、OpenAI、Azure OpenAI、Kimi、智譜AI、訊飛星火和百度千帆大模型等。 ","MaxKB是什麼? 6 | MaxKB產品介紹 7 | MaxKB支援的大語言模型 8 | MaxKB優勢" -------------------------------------------------------------------------------- /apps/dataset/template/excel_template_en.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/template/excel_template_en.xlsx -------------------------------------------------------------------------------- /apps/dataset/template/excel_template_zh.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/template/excel_template_zh.xlsx -------------------------------------------------------------------------------- /apps/dataset/template/excel_template_zh_Hant.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/template/excel_template_zh_Hant.xlsx -------------------------------------------------------------------------------- /apps/dataset/template/table_template_en.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/template/table_template_en.xlsx -------------------------------------------------------------------------------- /apps/dataset/template/table_template_zh.csv: -------------------------------------------------------------------------------- 1 | 职务,报销类型,一线城市报销标准(元),二线城市报销标准(元),三线城市报销标准(元) 2 | 普通员工,住宿费,500,400,300 3 | 部门主管,住宿费,600,500,400 4 | 部门总监,住宿费,700,600,500 5 | 区域总经理,住宿费,800,700,600 6 | 普通员工,伙食费,50,40,30 7 | 部门主管,伙食费,50,40,30 8 | 部门总监,伙食费,50,40,30 9 | 区域总经理,伙食费,50,40,30 10 | 普通员工,交通费,50,40,30 11 | 部门主管,交通费,50,40,30 12 | 部门总监,交通费,50,40,30 13 | 区域总经理,交通费,50,40,30 14 | -------------------------------------------------------------------------------- /apps/dataset/template/table_template_zh.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/template/table_template_zh.xlsx -------------------------------------------------------------------------------- /apps/dataset/template/table_template_zh_Hant.csv: -------------------------------------------------------------------------------- 1 | 職務,報銷類型,一線城市報銷標準(元),二線城市報銷標準(元),三線城市報銷標準(元) 2 | 普通員工,住宿費,500,400,300 3 | 部門主管,住宿費,600,500,400 4 | 部門總監,住宿費,700,600,500 5 | 區域總經理,住宿費,800,700,600 6 | 普通員工,伙食費,50,40,30 7 | 部門主管,伙食費,50,40,30 8 | 部門總監,伙食費,50,40,30 9 | 區域總經理,伙食費,50,40,30 10 | 普通員工,交通費,50,40,30 11 | 部門主管,交通費,50,40,30 12 | 部門總監,交通費,50,40,30 13 | 區域總經理,交通費,50,40,30 -------------------------------------------------------------------------------- /apps/dataset/template/table_template_zh_Hant.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/dataset/template/table_template_zh_Hant.xlsx -------------------------------------------------------------------------------- /apps/dataset/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apps/dataset/views/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/21 9:32 7 | @desc: 8 | """ 9 | from .dataset import * 10 | from .document import * 11 | from .paragraph import * 12 | from .problem import * 13 | from .image import * 14 | from .file import * 15 | -------------------------------------------------------------------------------- /apps/embedding/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/embedding/__init__.py -------------------------------------------------------------------------------- /apps/embedding/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apps/embedding/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class EmbeddingConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'embedding' 7 | -------------------------------------------------------------------------------- /apps/embedding/migrations/0003_alter_embedding_unique_together.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.14 on 2024-07-23 18:14 2 | 3 | from django.db import migrations 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('embedding', '0002_embedding_search_vector'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterUniqueTogether( 14 | name='embedding', 15 | unique_together=set(), 16 | ), 17 | ] 18 | -------------------------------------------------------------------------------- /apps/embedding/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/embedding/migrations/__init__.py -------------------------------------------------------------------------------- /apps/embedding/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/21 14:53 7 | @desc: 8 | """ 9 | from .embedding import * 10 | -------------------------------------------------------------------------------- /apps/embedding/sql/blend_search.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | paragraph_id, 3 | comprehensive_score, 4 | comprehensive_score AS similarity 5 | FROM 6 | ( 7 | SELECT DISTINCT ON 8 | ( "paragraph_id" ) ( similarity ),* , 9 | similarity AS comprehensive_score 10 | FROM 11 | ( 12 | SELECT 13 | *, 14 | (( 1 - ( embedding.embedding <=> %s ) )+ts_rank_cd( embedding.search_vector, websearch_to_tsquery('simple', %s ), 32 )) AS similarity 15 | FROM 16 | embedding ${embedding_query} 17 | ) TEMP 18 | ORDER BY 19 | paragraph_id, 20 | similarity DESC 21 | ) DISTINCT_TEMP 22 | WHERE 23 | comprehensive_score >%s 24 | ORDER BY 25 | comprehensive_score DESC 26 | LIMIT %s -------------------------------------------------------------------------------- /apps/embedding/sql/embedding_search.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | paragraph_id, 3 | comprehensive_score, 4 | comprehensive_score as similarity 5 | FROM 6 | ( 7 | SELECT DISTINCT ON 8 | ("paragraph_id") ( similarity ),* ,similarity AS comprehensive_score 9 | FROM 10 | ( SELECT *, ( 1 - ( embedding.embedding <=> %s ) ) AS similarity FROM embedding ${embedding_query}) TEMP 11 | ORDER BY 12 | paragraph_id, 13 | similarity DESC 14 | ) DISTINCT_TEMP 15 | WHERE comprehensive_score>%s 16 | ORDER BY comprehensive_score DESC 17 | LIMIT %s -------------------------------------------------------------------------------- /apps/embedding/sql/hit_test.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | paragraph_id, 3 | comprehensive_score, 4 | comprehensive_score as similarity 5 | FROM 6 | ( 7 | SELECT DISTINCT ON 8 | ("paragraph_id") ( similarity ),* ,similarity AS comprehensive_score 9 | FROM 10 | ( SELECT *, ( 1 - ( embedding.embedding <=> %s ) ) AS similarity FROM embedding ${embedding_query} ) TEMP 11 | ORDER BY 12 | paragraph_id, 13 | similarity DESC 14 | ) DISTINCT_TEMP 15 | WHERE comprehensive_score>%s 16 | ORDER BY comprehensive_score DESC 17 | LIMIT %s -------------------------------------------------------------------------------- /apps/embedding/sql/keywords_search.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | paragraph_id, 3 | comprehensive_score, 4 | comprehensive_score as similarity 5 | FROM 6 | ( 7 | SELECT DISTINCT ON 8 | ("paragraph_id") ( similarity ),* ,similarity AS comprehensive_score 9 | FROM 10 | ( SELECT *,ts_rank_cd(embedding.search_vector,websearch_to_tsquery('simple',%s),32) AS similarity FROM embedding ${keywords_query}) TEMP 11 | ORDER BY 12 | paragraph_id, 13 | similarity DESC 14 | ) DISTINCT_TEMP 15 | WHERE comprehensive_score>%s 16 | ORDER BY comprehensive_score DESC 17 | LIMIT %s -------------------------------------------------------------------------------- /apps/embedding/task/__init__.py: -------------------------------------------------------------------------------- 1 | from .embedding import * 2 | -------------------------------------------------------------------------------- /apps/embedding/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apps/embedding/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /apps/function_lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/function_lib/__init__.py -------------------------------------------------------------------------------- /apps/function_lib/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apps/function_lib/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class FunctionLibConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'function_lib' 7 | -------------------------------------------------------------------------------- /apps/function_lib/migrations/0002_functionlib_is_active_functionlib_permission_type.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-09-14 11:23 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('function_lib', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='functionlib', 15 | name='is_active', 16 | field=models.BooleanField(default=True), 17 | ), 18 | migrations.AddField( 19 | model_name='functionlib', 20 | name='permission_type', 21 | field=models.CharField(choices=[('PUBLIC', '公开'), ('PRIVATE', '私有')], default='PRIVATE', max_length=20, verbose_name='权限类型'), 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /apps/function_lib/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/function_lib/migrations/__init__.py -------------------------------------------------------------------------------- /apps/function_lib/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/8/2 14:55 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/function_lib/serializers/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/8/2 14:55 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/function_lib/swagger_api/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/8/2 14:55 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/function_lib/swagger_api/py_lint_api.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: py_lint_api.py 6 | @date:2024/9/30 15:48 7 | @desc: 8 | """ 9 | from drf_yasg import openapi 10 | 11 | from common.mixins.api_mixin import ApiMixin 12 | from django.utils.translation import gettext_lazy as _ 13 | 14 | 15 | class PyLintApi(ApiMixin): 16 | @staticmethod 17 | def get_request_body_api(): 18 | return openapi.Schema( 19 | type=openapi.TYPE_OBJECT, 20 | required=['code'], 21 | properties={ 22 | 'code': openapi.Schema(type=openapi.TYPE_STRING, title=_('function content'), 23 | description=_('function content')) 24 | } 25 | ) 26 | -------------------------------------------------------------------------------- /apps/function_lib/task/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/function_lib/task/__init__.py -------------------------------------------------------------------------------- /apps/function_lib/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apps/function_lib/views/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/8/2 14:53 7 | @desc: 8 | """ 9 | from .function_lib_views import * 10 | from .py_lint import * 11 | -------------------------------------------------------------------------------- /apps/function_lib/views/common.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: common.py 6 | @date:2025/3/25 17:27 7 | @desc: 8 | """ 9 | from django.db.models import QuerySet 10 | 11 | from function_lib.models.function import FunctionLib 12 | 13 | 14 | def get_function_lib_operation_object(function_lib_id): 15 | function_lib_model = QuerySet(model=FunctionLib).filter(id=function_lib_id).first() 16 | if function_lib_model is not None: 17 | return { 18 | "name": function_lib_model.name 19 | } 20 | return {} 21 | -------------------------------------------------------------------------------- /apps/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smartdoc.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /apps/ops/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/8/16 14:47 7 | @desc: 8 | """ 9 | from .celery import app as celery_app 10 | -------------------------------------------------------------------------------- /apps/ops/celery/const.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | 4 | CELERY_LOG_MAGIC_MARK = b'\x00\x00\x00\x00\x00' -------------------------------------------------------------------------------- /apps/setting/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/__init__.py -------------------------------------------------------------------------------- /apps/setting/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /apps/setting/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SettingConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'setting' 7 | -------------------------------------------------------------------------------- /apps/setting/migrations/0003_model_meta_model_status.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-03-22 17:51 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('setting', '0002_systemsetting'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='model', 15 | name='meta', 16 | field=models.JSONField(default=dict, verbose_name='模型元数据,用于存储下载,或者错误信息'), 17 | ), 18 | migrations.AddField( 19 | model_name='model', 20 | name='status', 21 | field=models.CharField(choices=[('SUCCESS', '成功'), ('ERROR', '失败'), ('DOWNLOAD', '下载中')], default='SUCCESS', max_length=20, verbose_name='设置类型'), 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /apps/setting/migrations/0004_alter_model_credential.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-04-28 18:06 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('setting', '0003_model_meta_model_status'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='model', 15 | name='credential', 16 | field=models.CharField(max_length=102400, verbose_name='模型认证信息'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/setting/migrations/0006_alter_model_status.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.14 on 2024-07-23 18:14 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('setting', '0005_model_permission_type'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='model', 15 | name='status', 16 | field=models.CharField(choices=[('SUCCESS', '成功'), ('ERROR', '失败'), ('DOWNLOAD', '下载中'), ('PAUSE_DOWNLOAD', '暂停下载')], default='SUCCESS', max_length=20, verbose_name='设置类型'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/setting/migrations/0007_model_model_params_form.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2024-10-15 14:49 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('setting', '0006_alter_model_status'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='model', 15 | name='model_params_form', 16 | field=models.JSONField(default=list, verbose_name='模型参数配置'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/setting/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/migrations/__init__.py -------------------------------------------------------------------------------- /apps/setting/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/25 15:04 7 | @desc: 8 | """ 9 | from .team_management import * 10 | from .model_management import * 11 | from .system_management import * 12 | -------------------------------------------------------------------------------- /apps/setting/models/system_management.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: system_management.py 6 | @date:2024/3/19 13:47 7 | @desc: 邮箱管理 8 | """ 9 | 10 | from django.db import models 11 | 12 | from common.mixins.app_model_mixin import AppModelMixin 13 | 14 | 15 | class SettingType(models.IntegerChoices): 16 | """系统设置类型""" 17 | EMAIL = 0, '邮箱' 18 | 19 | RSA = 1, "私钥秘钥" 20 | 21 | 22 | class SystemSetting(AppModelMixin): 23 | """ 24 | 系统设置 25 | """ 26 | type = models.IntegerField(primary_key=True, verbose_name='设置类型', choices=SettingType.choices, 27 | default=SettingType.EMAIL) 28 | 29 | meta = models.JSONField(verbose_name="配置数据", default=dict) 30 | 31 | class Meta: 32 | db_table = "system_setting" 33 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/aliyun_bai_lian_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/9/9 17:42 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/aliyun_bai_lian_model_provider/model/iat_mp3_16k.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/models_provider/impl/aliyun_bai_lian_model_provider/model/iat_mp3_16k.mp3 -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/aliyun_bai_lian_model_provider/model/reranker.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: reranker.py.py 6 | @date:2024/9/2 16:42 7 | @desc: 8 | """ 9 | from typing import Dict 10 | 11 | from langchain_community.document_compressors import DashScopeRerank 12 | 13 | from setting.models_provider.base_model_provider import MaxKBBaseModel 14 | 15 | 16 | class AliyunBaiLianReranker(MaxKBBaseModel, DashScopeRerank): 17 | @staticmethod 18 | def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): 19 | return AliyunBaiLianReranker(model=model_name, dashscope_api_key=model_credential.get('dashscope_api_key'), 20 | top_n=model_kwargs.get('top_n', 3)) 21 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/anthropic_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/3/28 16:25 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/anthropic_model_provider/icon/anthropic_icon_svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/aws_bedrock_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: UTF-8 -*- 3 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/azure_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/10/31 17:16 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/base_stt.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | from abc import abstractmethod 3 | 4 | from pydantic import BaseModel 5 | 6 | 7 | class BaseSpeechToText(BaseModel): 8 | @abstractmethod 9 | def check_auth(self): 10 | pass 11 | 12 | @abstractmethod 13 | def speech_to_text(self, audio_file): 14 | pass 15 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/base_tti.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | from abc import abstractmethod 3 | 4 | from pydantic import BaseModel 5 | 6 | 7 | class BaseTextToImage(BaseModel): 8 | @abstractmethod 9 | def check_auth(self): 10 | pass 11 | 12 | @abstractmethod 13 | def generate_image(self, prompt: str, negative_prompt: str = None): 14 | pass 15 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/base_tts.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | from abc import abstractmethod 3 | 4 | from pydantic import BaseModel 5 | 6 | 7 | class BaseTextToSpeech(BaseModel): 8 | @abstractmethod 9 | def check_auth(self): 10 | pass 11 | 12 | @abstractmethod 13 | def text_to_speech(self, text): 14 | pass 15 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/deepseek_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: UTF-8 -*- 3 | """ 4 | @Project :MaxKB 5 | @File :__init__.py.py 6 | @Author :Brian Yang 7 | @Date :5/12/24 7:38 AM 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/gemini_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: UTF-8 -*- 3 | """ 4 | @Project :MaxKB 5 | @File :__init__.py.py 6 | @Author :Brian Yang 7 | @Date :5/13/24 7:40 AM 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/gemini_model_provider/model/embedding.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: embedding.py 6 | @date:2024/7/12 17:44 7 | @desc: 8 | """ 9 | from typing import Dict 10 | 11 | from langchain_google_genai import GoogleGenerativeAIEmbeddings 12 | 13 | from setting.models_provider.base_model_provider import MaxKBBaseModel 14 | 15 | 16 | class GeminiEmbeddingModel(MaxKBBaseModel, GoogleGenerativeAIEmbeddings): 17 | @staticmethod 18 | def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): 19 | return GeminiEmbeddingModel( 20 | google_api_key=model_credential.get('api_key'), 21 | model=model_name, 22 | ) 23 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/kimi_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/10/31 17:16 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/local_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2024/7/10 17:48 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/ollama_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/3/5 17:20 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/openai_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/3/28 16:25 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/qwen_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/10/31 17:16 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/regolo_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/3/28 16:25 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/regolo_model_provider/model/embedding.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: embedding.py 6 | @date:2024/7/12 17:44 7 | @desc: 8 | """ 9 | from typing import Dict 10 | 11 | from langchain_community.embeddings import OpenAIEmbeddings 12 | 13 | from setting.models_provider.base_model_provider import MaxKBBaseModel 14 | 15 | 16 | class RegoloEmbeddingModel(MaxKBBaseModel, OpenAIEmbeddings): 17 | @staticmethod 18 | def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): 19 | return RegoloEmbeddingModel( 20 | api_key=model_credential.get('api_key'), 21 | model=model_name, 22 | openai_api_base="https://api.regolo.ai/v1", 23 | ) 24 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/siliconCloud_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/3/28 16:25 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/siliconCloud_model_provider/model/embedding.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: embedding.py 6 | @date:2024/7/12 17:44 7 | @desc: 8 | """ 9 | from typing import Dict 10 | 11 | from langchain_community.embeddings import OpenAIEmbeddings 12 | 13 | from setting.models_provider.base_model_provider import MaxKBBaseModel 14 | 15 | 16 | class SiliconCloudEmbeddingModel(MaxKBBaseModel, OpenAIEmbeddings): 17 | @staticmethod 18 | def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): 19 | return SiliconCloudEmbeddingModel( 20 | api_key=model_credential.get('api_key'), 21 | model=model_name, 22 | openai_api_base=model_credential.get('api_base'), 23 | ) 24 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/tencent_cloud_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/3/28 16:25 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/tencent_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: UTF-8 -*- 3 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/vllm_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/vllm_model_provider/model/embedding.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: embedding.py 6 | @date:2024/7/12 17:44 7 | @desc: 8 | """ 9 | from typing import Dict 10 | 11 | from langchain_community.embeddings import OpenAIEmbeddings 12 | 13 | from setting.models_provider.base_model_provider import MaxKBBaseModel 14 | 15 | 16 | class VllmEmbeddingModel(MaxKBBaseModel, OpenAIEmbeddings): 17 | @staticmethod 18 | def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): 19 | return VllmEmbeddingModel( 20 | model=model_name, 21 | openai_api_key=model_credential.get('api_key'), 22 | openai_api_base=model_credential.get('api_base'), 23 | ) 24 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/volcanic_engine_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: UTF-8 -*- 3 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/volcanic_engine_model_provider/model/embedding.py: -------------------------------------------------------------------------------- 1 | from typing import Dict 2 | 3 | from langchain_openai import OpenAIEmbeddings 4 | 5 | from setting.models_provider.base_model_provider import MaxKBBaseModel 6 | 7 | 8 | class VolcanicEngineEmbeddingModel(MaxKBBaseModel, OpenAIEmbeddings): 9 | @staticmethod 10 | def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): 11 | return VolcanicEngineEmbeddingModel( 12 | openai_api_key=model_credential.get('api_key'), 13 | model=model_name, 14 | openai_api_base=model_credential.get('api_base'), 15 | check_embedding_ctx_length=False, 16 | ) 17 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/volcanic_engine_model_provider/model/iat_mp3_16k.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/models_provider/impl/volcanic_engine_model_provider/model/iat_mp3_16k.mp3 -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/wenxin_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/10/31 17:16 7 | @desc: 8 | """ 9 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/wenxin_model_provider/model/embedding.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: embedding.py 6 | @date:2024/10/17 16:48 7 | @desc: 8 | """ 9 | from typing import Dict 10 | 11 | from langchain_community.embeddings import QianfanEmbeddingsEndpoint 12 | 13 | from setting.models_provider.base_model_provider import MaxKBBaseModel 14 | 15 | 16 | class QianfanEmbeddings(MaxKBBaseModel, QianfanEmbeddingsEndpoint): 17 | @staticmethod 18 | def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): 19 | return QianfanEmbeddings( 20 | model=model_name, 21 | qianfan_ak=model_credential.get('qianfan_ak'), 22 | qianfan_sk=model_credential.get('qianfan_sk'), 23 | ) 24 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/xf_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2024/04/19 15:55 7 | @desc: 8 | """ -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/xf_model_provider/credential/img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/models_provider/impl/xf_model_provider/credential/img_1.png -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/xf_model_provider/model/iat_mp3_16k.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/models_provider/impl/xf_model_provider/model/iat_mp3_16k.mp3 -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/xf_model_provider/model/img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/models_provider/impl/xf_model_provider/model/img_1.png -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/xinference_model_provider/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | -------------------------------------------------------------------------------- /apps/setting/models_provider/impl/zhipu_model_provider/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/setting/models_provider/impl/zhipu_model_provider/__init__.py -------------------------------------------------------------------------------- /apps/setting/sql/check_member_permission_target_exists.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | static_temp."target_id"::text 3 | FROM 4 | (SELECT * FROM json_to_recordset( 5 | %s 6 | ) AS x(target_id uuid,type text)) static_temp 7 | LEFT JOIN ( 8 | SELECT 9 | "id", 10 | 'DATASET' AS "type", 11 | user_id, 12 | ARRAY [ 'MANAGE', 13 | 'USE', 14 | 'DELETE' ] AS "operate" 15 | FROM 16 | dataset 17 | WHERE 18 | "user_id" = %s UNION 19 | SELECT 20 | "id", 21 | 'APPLICATION' AS "type", 22 | user_id, 23 | ARRAY [ 'MANAGE', 24 | 'USE', 25 | 'DELETE' ] AS "operate" 26 | FROM 27 | application 28 | WHERE 29 | "user_id" = %s 30 | ) "app_and_dataset_temp" 31 | ON "app_and_dataset_temp"."id" = static_temp."target_id" and app_and_dataset_temp."type"=static_temp."type" 32 | WHERE app_and_dataset_temp.id is NULL ; -------------------------------------------------------------------------------- /apps/setting/sql/get_member_permission.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | app_or_dataset.*, 3 | team_member_permission.member_id, 4 | team_member_permission.operate 5 | FROM 6 | ( 7 | SELECT 8 | "id", 9 | "name", 10 | 'DATASET' AS "type", 11 | user_id, 12 | "type" AS "icon" 13 | FROM 14 | dataset 15 | WHERE 16 | "user_id" = %s UNION 17 | SELECT 18 | "id", 19 | "name", 20 | 'APPLICATION' AS "type", 21 | user_id, 22 | "icon" AS "icon" 23 | FROM 24 | application 25 | WHERE 26 | "user_id" = %s 27 | ) app_or_dataset 28 | LEFT JOIN ( SELECT * FROM team_member_permission WHERE member_id = %s ) team_member_permission ON team_member_permission.target = app_or_dataset."id" -------------------------------------------------------------------------------- /apps/setting/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /apps/setting/views/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: maxkb 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/9/25 17:12 7 | @desc: 8 | """ 9 | from .Team import * 10 | from .model import * 11 | from .system_setting import * 12 | from .valid import * 13 | from .model_apply import * 14 | -------------------------------------------------------------------------------- /apps/smartdoc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/smartdoc/__init__.py -------------------------------------------------------------------------------- /apps/smartdoc/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for apps project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smartdoc.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /apps/smartdoc/const.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | import os 4 | 5 | from .conf import ConfigManager 6 | 7 | __all__ = ['BASE_DIR', 'PROJECT_DIR', 'VERSION', 'CONFIG'] 8 | 9 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 10 | PROJECT_DIR = os.path.dirname(BASE_DIR) 11 | VERSION = '1.0.0' 12 | CONFIG = ConfigManager.load_user_config(root_path=os.path.abspath('/opt/maxkb/conf')) 13 | -------------------------------------------------------------------------------- /apps/smartdoc/settings/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: smart-doc 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/14 15:45 7 | @desc: 8 | """ 9 | from .base import * 10 | from .logging import * 11 | from .auth import * 12 | from .lib import * 13 | -------------------------------------------------------------------------------- /apps/smartdoc/settings/auth.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: MaxKB 4 | @Author:虎 5 | @file: auth.py 6 | @date:2024/7/9 18:47 7 | @desc: 8 | """ 9 | USER_TOKEN_AUTH = 'common.auth.handle.impl.user_token.UserToken' 10 | 11 | PUBLIC_ACCESS_TOKEN_AUTH = 'common.auth.handle.impl.public_access_token.PublicAccessToken' 12 | 13 | APPLICATION_KEY_AUTH = 'common.auth.handle.impl.application_key.ApplicationKey' 14 | 15 | AUTH_HANDLES = [ 16 | USER_TOKEN_AUTH, 17 | PUBLIC_ACCESS_TOKEN_AUTH, 18 | APPLICATION_KEY_AUTH 19 | ] 20 | -------------------------------------------------------------------------------- /apps/smartdoc/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for apps project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smartdoc.settings') 15 | 16 | application = get_wsgi_application() 17 | 18 | 19 | def post_handler(): 20 | from common import event 21 | from common import job 22 | from common.models.db_model_manage import DBModelManage 23 | event.run() 24 | job.run() 25 | DBModelManage.init() 26 | 27 | 28 | post_handler() 29 | -------------------------------------------------------------------------------- /apps/users/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/users/__init__.py -------------------------------------------------------------------------------- /apps/users/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class UsersConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'users' 7 | 8 | def ready(self): 9 | from ops.celery import signal_handler 10 | -------------------------------------------------------------------------------- /apps/users/migrations/0002_user_create_time_user_update_time.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.13 on 2024-03-20 12:27 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('users', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='user', 15 | name='create_time', 16 | field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='创建时间'), 17 | ), 18 | migrations.AddField( 19 | model_name='user', 20 | name='update_time', 21 | field=models.DateTimeField(auto_now=True, null=True, verbose_name='修改时间'), 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /apps/users/migrations/0003_user_source.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.13 on 2024-07-11 19:16 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('users', '0002_user_create_time_user_update_time'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='user', 15 | name='source', 16 | field=models.CharField(default='LOCAL', max_length=10, verbose_name='来源'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/users/migrations/0004_alter_user_email.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.13 on 2024-07-16 17:03 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('users', '0003_user_source'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='user', 15 | name='email', 16 | field=models.EmailField(blank=True, max_length=254, null=True, unique=True, verbose_name='邮箱'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /apps/users/migrations/0005_user_language.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.15 on 2025-01-20 06:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ('users', '0004_alter_user_email'), 9 | ] 10 | 11 | operations = [ 12 | migrations.AddField( 13 | model_name='user', 14 | name='language', 15 | field=models.CharField(default=None, null=True, max_length=10, verbose_name='语言'), 16 | ), 17 | ] 18 | -------------------------------------------------------------------------------- /apps/users/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/users/migrations/__init__.py -------------------------------------------------------------------------------- /apps/users/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: qabot 4 | @Author:虎 5 | @file: __init__.py 6 | @date:2023/9/4 10:08 7 | @desc: 8 | """ 9 | from .user import * -------------------------------------------------------------------------------- /apps/users/task/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/apps/users/task/__init__.py -------------------------------------------------------------------------------- /apps/users/views/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | @project: smart-doc 4 | @Author:虎 5 | @file: __init__.py.py 6 | @date:2023/9/14 19:01 7 | @desc: 8 | """ 9 | from .user import * 10 | -------------------------------------------------------------------------------- /config_example.yml: -------------------------------------------------------------------------------- 1 | # 数据库链接信息 2 | DB_NAME: maxkb 3 | DB_HOST: localhost 4 | DB_PORT: 5432 5 | DB_USER: root 6 | DB_PASSWORD: xxxxxxx 7 | DB_ENGINE: django.db.backends.postgresql_psycopg2 8 | 9 | DEBUG: false 10 | 11 | TIME_ZONE: Asia/Shanghai 12 | 13 | -------------------------------------------------------------------------------- /installer/Dockerfile-python-pg: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim-bullseye AS python-stage 2 | FROM postgres:15.8-bullseye 3 | 4 | ARG DEPENDENCIES=" \ 5 | libexpat1-dev \ 6 | libffi-dev \ 7 | curl \ 8 | ca-certificates \ 9 | vim \ 10 | gettext \ 11 | postgresql-15-pgvector" 12 | 13 | RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ 14 | echo "Asia/Shanghai" > /etc/timezone && \ 15 | apt-get update && apt-get install -y --no-install-recommends $DEPENDENCIES && \ 16 | apt-get clean all && \ 17 | rm -rf /var/lib/apt/lists/* 18 | 19 | COPY --from=python-stage /usr/local /usr/local -------------------------------------------------------------------------------- /installer/Dockerfile-vector-model: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim-bookworm AS vector-model 2 | 3 | COPY installer/install_model.py install_model.py 4 | RUN pip3 install --upgrade pip setuptools && \ 5 | pip install pycrawlers && \ 6 | pip install transformers && \ 7 | python3 install_model.py 8 | 9 | FROM scratch 10 | COPY --from=vector-model model /opt/maxkb/app/model -------------------------------------------------------------------------------- /installer/config.yaml: -------------------------------------------------------------------------------- 1 | # 邮箱配置 2 | EMAIL_ADDRESS: ${EMAIL_ADDRESS} 3 | EMAIL_USE_TLS: ${EMAIL_USE_TLS} 4 | EMAIL_USE_SSL: ${EMAIL_USE_SSL} 5 | EMAIL_HOST: ${EMAIL_HOST} 6 | EMAIL_PORT: ${EMAIL_PORT} 7 | EMAIL_HOST_USER: ${EMAIL_HOST_USER} 8 | EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD} 9 | 10 | # 数据库链接信息 11 | DB_NAME: maxkb 12 | DB_HOST: 127.0.0.1 13 | DB_PORT: 5432 14 | DB_USER: root 15 | DB_PASSWORD: Password123@postgres 16 | DB_ENGINE: dj_db_conn_pool.backends.postgresql 17 | EMBEDDING_MODEL_PATH: /opt/maxkb/model/embedding 18 | EMBEDDING_MODEL_NAME: /opt/maxkb/model/embedding/shibing624_text2vec-base-chinese 19 | 20 | DEBUG: false -------------------------------------------------------------------------------- /installer/init.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE "maxkb"; 2 | 3 | \c "maxkb"; 4 | 5 | CREATE EXTENSION "vector"; -------------------------------------------------------------------------------- /installer/run-maxkb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -f /opt/maxkb/app/tmp/*.pid 3 | # Start postgresql 4 | docker-entrypoint.sh postgres -c max_connections=${POSTGRES_MAX_CONNECTIONS} & 5 | sleep 10 6 | # Wait postgresql 7 | until pg_isready --host=127.0.0.1; do sleep 1 && echo "waiting for postgres"; done 8 | 9 | # Start MaxKB 10 | python /opt/maxkb/app/main.py start -------------------------------------------------------------------------------- /installer/start-maxkb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -f /opt/maxkb/app/tmp/*.pid 3 | python /opt/maxkb/app/main.py start -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MaxKB", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | 8 | -------------------------------------------------------------------------------- /ui/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | require('@rushstack/eslint-patch/modern-module-resolution') 3 | 4 | module.exports = { 5 | root: true, 6 | 'extends': [ 7 | 'plugin:vue/vue3-essential', 8 | 'eslint:recommended', 9 | '@vue/eslint-config-typescript', 10 | '@vue/eslint-config-prettier/skip-formatting' 11 | ], 12 | parserOptions: { 13 | ecmaVersion: 'latest' 14 | }, 15 | rules: { 16 | // 添加组件命名忽略规则 17 | "vue/multi-word-component-names": ["error",{ 18 | "ignores": ["index","main"]//需要忽略的组件名 19 | }] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ui/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .DS_Store 12 | dist 13 | dist-ssr 14 | coverage 15 | *.local 16 | 17 | /cypress/videos/ 18 | /cypress/screenshots/ 19 | 20 | # Editor directories and files 21 | .vscode/* 22 | !.vscode/extensions.json 23 | .idea 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | -------------------------------------------------------------------------------- /ui/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/prettierrc", 3 | "semi": false, 4 | "tabWidth": 2, 5 | "singleQuote": true, 6 | "printWidth": 100, 7 | "trailingComma": "none" 8 | } -------------------------------------------------------------------------------- /ui/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /ui/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module 'element-plus/dist/locale/zh-cn.mjs' 3 | declare module 'element-plus/dist/locale/en.mjs' 4 | declare module 'element-plus/dist/locale/zh-tw.mjs' 5 | declare module 'markdown-it-task-lists' 6 | declare module 'markdown-it-abbr' 7 | declare module 'markdown-it-anchor' 8 | declare module 'markdown-it-footnote' 9 | declare module 'markdown-it-sub' 10 | declare module 'markdown-it-sup' 11 | declare module 'markdown-it-toc-done-right' 12 | declare module 'katex' 13 | interface Window { 14 | sendMessage: ?((message: string, other_params_data: any) => void) 15 | } 16 | interface ImportMeta { 17 | readonly env: ImportMetaEnv 18 | } 19 | declare type Recordable = Record 20 | -------------------------------------------------------------------------------- /ui/env/.env: -------------------------------------------------------------------------------- 1 | VITE_APP_NAME=ui 2 | VITE_BASE_PATH=/ui/ 3 | VITE_APP_PORT=3000 4 | VITE_APP_TITLE = 'MaxKB' -------------------------------------------------------------------------------- /ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | %VITE_APP_TITLE% 13 | 14 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ui/public/MaxKB.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/MaxKB.gif -------------------------------------------------------------------------------- /ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/favicon.ico -------------------------------------------------------------------------------- /ui/public/fx/bochaai/detail.md: -------------------------------------------------------------------------------- 1 | ## 概述 2 | 3 | 博查工具是一个支持自然语言搜索的 Web Search API,从近百亿网页和生态内容源中搜索高质量世界知识,包括新闻、图片、视频、百科、机酒、学术等。 4 | 5 | 6 | ## 配置 7 | 8 | 1. 获取API Key  9 | 在[博查开放平台](https://open.bochaai.com/overview) 上申请 API 密钥。 10 | ![API Key](/ui/fx/img/bocha_APIKey.jpg) 11 | 2. 在函数库中配置 12 | 在函数库的博查函数面板中,点击 … > 启用参数,填写 API 密钥,并启用该函数。 13 | ![启动参数](/ui/fx/img/bocha_setting.jpg) 14 | 3. 在应用中使用 15 | 在高级编排应用中,点击添加组件->函数库->博查,设置使用参数。 16 | ![应用中使用](/ui/fx/img/bocha_app_used.jpg) 17 | -------------------------------------------------------------------------------- /ui/public/fx/bochaai/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/bochaai/icon.png -------------------------------------------------------------------------------- /ui/public/fx/google_search/detail.md: -------------------------------------------------------------------------------- 1 | ## 概述 2 | 3 | Google 搜索工具是一个实时 API,可提取搜索引擎结果,提供来自 Google 的结构化数据。它支持各种搜索类型,包括 Web、图像、新闻和地图。 4 | 5 | ## 配置 6 | 7 | 1. 创建 Google Custom Search Engine 8 | 在[Programmable Search Engine](https://programmablesearchengine.google.com/)中 添加 Search Engine 9 | ![google 创建引擎](/ui/fx/img/google_AddSearchEngine.jpg) 10 | 2. 获取cx参数 11 | 进入添加的引擎详情中,在【基本】菜单中获取搜索引擎的ID,即cx。 12 | ![google cx ](/ui/fx/img/google_cx.jpg) 13 | 3. 获取 API Key 14 | 打开 https://developers.google.com/custom-search/v1/overview?hl=zh-cn 获取API Key。 15 | ![google API Key](/ui/fx/img/google_APIKey.jpg) 16 | 4. 配置启动参数 17 | 在Google 搜索函数的启动参数中填写配置以上参数,并启用该函数。 18 | ![启动参数](/ui/fx/img/google_setting.jpg) 19 | 5. 在应用中使用 20 | 在高级编排应用中,点击添加组件->函数库->Google搜索,设置使用参数。 21 | ![应用中使用](/ui/fx/img/google_app_used.jpg) 22 | -------------------------------------------------------------------------------- /ui/public/fx/google_search/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/google_search/icon.png -------------------------------------------------------------------------------- /ui/public/fx/img/MySQL_app_used.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/MySQL_app_used.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/MySQL_setting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/MySQL_setting.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/PostgreSQL_app_used.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/PostgreSQL_app_used.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/PostgreSQL_setting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/PostgreSQL_setting.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/bocha_APIKey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/bocha_APIKey.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/bocha_app_used.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/bocha_app_used.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/bocha_setting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/bocha_setting.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/google_APIKey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/google_APIKey.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/google_AddSearchEngine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/google_AddSearchEngine.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/google_app_used.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/google_app_used.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/google_cx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/google_cx.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/google_setting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/google_setting.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/langsearch_APIKey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/langsearch_APIKey.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/langsearch_app_used.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/langsearch_app_used.jpg -------------------------------------------------------------------------------- /ui/public/fx/img/langsearch_setting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/img/langsearch_setting.jpg -------------------------------------------------------------------------------- /ui/public/fx/langsearch/detail.md: -------------------------------------------------------------------------------- 1 | ## 概述 2 | 3 | LangSearch 是一个提供免费Web Search API和Rerank API的服务,支持新闻、图像、视频等内容。它结合了关键词和向量进行混合搜索,以提高准确性。 4 | 5 | 6 | ## 配置 7 | 8 | 1. 获取API Key  9 | 在[LangSearch](https://langsearch.com/overview) 上申请 API 密钥。 10 | ![API Key](/ui/fx/img/langsearch_APIKey.jpg) 11 | 2. 在函数库中配置 12 | 在函数库的LangSearch函数面板中,点击 … > 启用参数,填写 API 密钥,并启用该函数。 13 | ![启动参数](/ui/fx/img/langsearch_setting.jpg) 14 | 3. 在应用中使用 15 | 在高级编排应用中,点击添加组件->函数库->LangSearch,设置使用参数。 16 | ![应用中使用](/ui/fx/img/langsearch_app_used.jpg) 17 | -------------------------------------------------------------------------------- /ui/public/fx/langsearch/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/langsearch/icon.png -------------------------------------------------------------------------------- /ui/public/fx/mysql/detail.md: -------------------------------------------------------------------------------- 1 | ## 概述 2 | 3 | MySQL查询是一个连接MySQL数据库执行SQL查询的工具。 4 | 5 | 6 | ## 配置 7 |   8 | 1. 在函数库中配置启动参数 9 | 在函数库的MySQL函数面板中,点击 … > 启用参数,填写数据库连接参数,并启用该函数。 10 | ![启动参数](/ui/fx/img/MySQL_setting.jpg) 11 | 2. 在应用中使用 12 | 在高级编排应用中,点击添加组件->函数库->MySQL查询,设置查询内容。 13 | ![应用中使用](/ui/fx/img/MySQL_app_used.jpg) 14 | -------------------------------------------------------------------------------- /ui/public/fx/mysql/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/mysql/icon.png -------------------------------------------------------------------------------- /ui/public/fx/postgresql/detail.md: -------------------------------------------------------------------------------- 1 | ## 概述 2 | 3 | PostgreSQL查询是一个连接PostgreSQL数据库执行SQL查询的工具。 4 | 5 | 6 | ## 配置 7 |   8 | 1. 在函数库中配置启动参数 9 | 在函数库的PostgreSQL函数面板中,点击 … > 启用参数,填写数据库连接参数,并启用该函数。 10 | ![启动参数](/ui/fx/img/PostgreSQL_setting.jpg) 11 | 2. 在应用中使用 12 | 在高级编排应用中,点击添加组件->函数库->PostgreSQL查询,设置查询内容。 13 | ![应用中使用](/ui/fx/img/PostgreSQL_app_used.jpg) 14 | -------------------------------------------------------------------------------- /ui/public/fx/postgresql/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/public/fx/postgresql/icon.png -------------------------------------------------------------------------------- /ui/src/App.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ui/src/api/image.ts: -------------------------------------------------------------------------------- 1 | import { Result } from '@/request/Result' 2 | import { get, post, del, put } from '@/request/index' 3 | 4 | const prefix = '/image' 5 | /** 6 | * 上传图片 7 | * @param 参数 file:file 8 | */ 9 | const postImage: (data: any) => Promise> = (data) => { 10 | return post(`${prefix}`, data) 11 | } 12 | 13 | export default { 14 | postImage 15 | } 16 | -------------------------------------------------------------------------------- /ui/src/api/license.ts: -------------------------------------------------------------------------------- 1 | import { Result } from '@/request/Result' 2 | import { get, post, del, put } from '@/request/index' 3 | import { type Ref } from 'vue' 4 | 5 | const prefix = '/license' 6 | 7 | /** 8 | * 获得license信息 9 | */ 10 | const getLicense: (loading?: Ref) => Promise> = (loading) => { 11 | return get(`${prefix}/profile`, undefined, loading) 12 | } 13 | /** 14 | * 更新license信息 15 | * @param 参数 license_file:file 16 | */ 17 | const putLicense: (data: any, loading?: Ref) => Promise> = (data, loading) => { 18 | return put(`${prefix}/profile`, data, undefined, loading) 19 | } 20 | 21 | export default { 22 | getLicense, 23 | putLicense 24 | } 25 | -------------------------------------------------------------------------------- /ui/src/api/provider.ts: -------------------------------------------------------------------------------- 1 | import { Result } from '@/request/Result' 2 | import { get, post } from '@/request/index' 3 | import type { Ref } from 'vue' 4 | const trigger: ( 5 | provider: string, 6 | method: string, 7 | request_body: any, 8 | loading?: Ref 9 | ) => Promise | string>> = (provider, method, request_body, loading) => { 10 | return post(`provider/${provider}/${method}`, {}, request_body, loading) 11 | } 12 | export default { trigger, get } 13 | -------------------------------------------------------------------------------- /ui/src/api/type/common.ts: -------------------------------------------------------------------------------- 1 | interface KeyValue { 2 | key: K 3 | value: V 4 | } 5 | interface Dict { 6 | [propName: string]: V 7 | } 8 | 9 | interface pageRequest { 10 | current_page: number 11 | page_size: number 12 | } 13 | 14 | export type { KeyValue, Dict, pageRequest } 15 | -------------------------------------------------------------------------------- /ui/src/api/type/dataset.ts: -------------------------------------------------------------------------------- 1 | interface datasetData { 2 | name: String 3 | desc: String 4 | documents?: Array 5 | type?: String 6 | embedding_mode_id?: String 7 | } 8 | 9 | export type { datasetData } 10 | -------------------------------------------------------------------------------- /ui/src/api/type/function-lib.ts: -------------------------------------------------------------------------------- 1 | interface functionLibData { 2 | id?: String 3 | name?: String 4 | icon?: String 5 | desc?: String 6 | code?: String 7 | permission_type?: 'PRIVATE' | 'PUBLIC' 8 | input_field_list?: Array 9 | init_field_list?: Array 10 | is_active?: Boolean 11 | } 12 | 13 | export type { functionLibData } 14 | -------------------------------------------------------------------------------- /ui/src/api/type/team.ts: -------------------------------------------------------------------------------- 1 | interface TeamMember { 2 | id: string 3 | username: string 4 | email: string 5 | team_id: string 6 | /** 7 | * 类型:type:manage 所有者; 8 | */ 9 | type: string 10 | user_id: string 11 | } 12 | 13 | export type { TeamMember } 14 | -------------------------------------------------------------------------------- /ui/src/assets/404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/404.png -------------------------------------------------------------------------------- /ui/src/assets/display-bg1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/display-bg1.png -------------------------------------------------------------------------------- /ui/src/assets/display-bg2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/display-bg2.png -------------------------------------------------------------------------------- /ui/src/assets/display-bg3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/display-bg3.png -------------------------------------------------------------------------------- /ui/src/assets/fileType/doc-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ui/src/assets/fileType/docx-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ui/src/assets/fileType/xls-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ui/src/assets/fileType/xlsx-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ui/src/assets/hit-test-empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/hit-test-empty.png -------------------------------------------------------------------------------- /ui/src/assets/icon_file-folder_colorful.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ui/src/assets/icon_mcp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ui/src/assets/icon_web.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ui/src/assets/load_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/load_error.png -------------------------------------------------------------------------------- /ui/src/assets/sort.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/src/assets/theme/default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/theme/default.jpg -------------------------------------------------------------------------------- /ui/src/assets/theme/green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/theme/green.jpg -------------------------------------------------------------------------------- /ui/src/assets/theme/orange.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/theme/orange.jpg -------------------------------------------------------------------------------- /ui/src/assets/theme/purple.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/theme/purple.jpg -------------------------------------------------------------------------------- /ui/src/assets/theme/red.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/theme/red.jpg -------------------------------------------------------------------------------- /ui/src/assets/tipIMG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/tipIMG.jpg -------------------------------------------------------------------------------- /ui/src/assets/window1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/window1.png -------------------------------------------------------------------------------- /ui/src/assets/window2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/window2.png -------------------------------------------------------------------------------- /ui/src/assets/window3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/assets/window3.png -------------------------------------------------------------------------------- /ui/src/bus/index.ts: -------------------------------------------------------------------------------- 1 | import mitt from "mitt"; 2 | const bus: any = {}; 3 | const emitter = mitt(); 4 | bus.on = emitter.on; 5 | bus.off = emitter.off; 6 | bus.emit = emitter.emit; 7 | 8 | export default bus; 9 | -------------------------------------------------------------------------------- /ui/src/components/app-charts/index.vue: -------------------------------------------------------------------------------- 1 | 10 | 31 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/FormItemLabel.vue: -------------------------------------------------------------------------------- 1 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/items/DatePicker.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/items/PasswordInput.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/items/TextInput.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/items/label/TooltipLabel.vue: -------------------------------------------------------------------------------- 1 | 14 | 20 | 21 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/items/slider/Slider.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 12 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/items/switch/SwitchInput.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /ui/src/components/dynamics-form/items/table/TableColumn.vue: -------------------------------------------------------------------------------- 1 | 4 | 22 | 23 | -------------------------------------------------------------------------------- /ui/src/components/markdown/MdPreview.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 24 | -------------------------------------------------------------------------------- /ui/src/components/tag-ellipsis/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 9 | 27 | -------------------------------------------------------------------------------- /ui/src/directives/clickoutside.ts: -------------------------------------------------------------------------------- 1 | import type { App } from 'vue' 2 | import { ClickOutside as vClickOutside } from 'element-plus' 3 | export default { 4 | install: (app: App) => { 5 | app.directive('click-outside', vClickOutside) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ui/src/directives/hasPermission.ts: -------------------------------------------------------------------------------- 1 | import type { App } from 'vue' 2 | import { hasPermission } from '@/utils/permission' 3 | 4 | const display = async (el: any, binding: any) => { 5 | const has = hasPermission( 6 | binding.value?.permission || binding.value, 7 | binding.value?.compare || 'OR' 8 | ) 9 | if (!has) { 10 | el.style.display = 'none' 11 | } else { 12 | delete el.style.display 13 | } 14 | } 15 | 16 | export default { 17 | install: (app: App) => { 18 | app.directive('hasPermission', { 19 | async created(el: any, binding: any) { 20 | display(el, binding) 21 | }, 22 | async beforeUpdate(el: any, binding: any) { 23 | display(el, binding) 24 | } 25 | }) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ui/src/directives/index.ts: -------------------------------------------------------------------------------- 1 | import type { App } from 'vue' 2 | 3 | const directives = import.meta.glob('./*.ts', { eager: true }) 4 | const install = (app: App) => { 5 | Object.keys(directives) 6 | .filter((key: string) => { 7 | return !key.endsWith('index.ts') 8 | }) 9 | .forEach((key: string) => { 10 | const directive: any = directives[key] 11 | app.use(directive.default) 12 | }) 13 | } 14 | export default { install } 15 | -------------------------------------------------------------------------------- /ui/src/enums/application.ts: -------------------------------------------------------------------------------- 1 | export enum SearchMode { 2 | embedding = 'views.application.applicationForm.dialog.vectorSearch', 3 | keywords = 'views.application.applicationForm.dialog.fullTextSearch', 4 | blend = 'views.application.applicationForm.dialog.hybridSearch' 5 | } 6 | -------------------------------------------------------------------------------- /ui/src/enums/common.ts: -------------------------------------------------------------------------------- 1 | export enum DeviceType { 2 | Mobile = 'Mobile', 3 | Desktop = 'Desktop' 4 | } 5 | 6 | export enum ValidType { 7 | Application = 'application', 8 | Dataset = 'dataset', 9 | User = 'user' 10 | } 11 | 12 | export enum ValidCount { 13 | Application = 5, 14 | Dataset = 50, 15 | User = 2 16 | } 17 | -------------------------------------------------------------------------------- /ui/src/enums/document.ts: -------------------------------------------------------------------------------- 1 | export enum hitHandlingMethod { 2 | optimization = 'views.document.hitHandlingMethod.optimization', 3 | directly_return = 'views.document.hitHandlingMethod.directly_return' 4 | } 5 | -------------------------------------------------------------------------------- /ui/src/enums/model.ts: -------------------------------------------------------------------------------- 1 | export enum PermissionType { 2 | PRIVATE = 'common.private', 3 | PUBLIC = 'common.public' 4 | } 5 | export enum PermissionDesc { 6 | PRIVATE = 'views.template.templateForm.form.permissionType.privateDesc', 7 | PUBLIC = 'views.template.templateForm.form.permissionType.publicDesc', 8 | } 9 | 10 | export enum modelType { 11 | EMBEDDING = 'views.template.model.EMBEDDING', 12 | LLM = 'views.template.model.LLM', 13 | STT = 'views.template.model.STT', 14 | TTS = 'views.template.model.TTS', 15 | IMAGE = 'views.template.model.IMAGE', 16 | TTI = 'views.template.model.TTI', 17 | RERANKER = 'views.template.model.RERANKER' 18 | } 19 | -------------------------------------------------------------------------------- /ui/src/enums/team.ts: -------------------------------------------------------------------------------- 1 | export enum TeamEnum { 2 | MANAGE = 'MANAGE', 3 | USE = 'USE', 4 | DATASET = 'DATASET', 5 | APPLICATION = 'APPLICATION' 6 | } 7 | -------------------------------------------------------------------------------- /ui/src/enums/workflow.ts: -------------------------------------------------------------------------------- 1 | export enum WorkflowType { 2 | Base = 'base-node', 3 | Start = 'start-node', 4 | AiChat = 'ai-chat-node', 5 | SearchDataset = 'search-dataset-node', 6 | Question = 'question-node', 7 | Condition = 'condition-node', 8 | Reply = 'reply-node', 9 | FunctionLib = 'function-lib-node', 10 | FunctionLibCustom = 'function-node', 11 | RrerankerNode = 'reranker-node', 12 | Application = 'application-node', 13 | DocumentExtractNode = 'document-extract-node', 14 | ImageUnderstandNode = 'image-understand-node', 15 | VariableAssignNode = 'variable-assign-node', 16 | FormNode = 'form-node', 17 | TextToSpeechNode = 'text-to-speech-node', 18 | SpeechToTextNode = 'speech-to-text-node', 19 | ImageGenerateNode = 'image-generate-node', 20 | McpNode = 'mcp-node', 21 | } 22 | -------------------------------------------------------------------------------- /ui/src/layout/components/app-main/index.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 25 | -------------------------------------------------------------------------------- /ui/src/layout/components/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Sidebar } from './sidebar/index.vue' 2 | export { default as AppMain } from './app-main/index.vue' 3 | export { default as TopBar } from './top-bar/index.vue' 4 | export { default as AppHeader } from './app-header/index.vue' 5 | -------------------------------------------------------------------------------- /ui/src/layout/components/top-bar/top-menu/index.vue: -------------------------------------------------------------------------------- 1 | 12 | 21 | 24 | -------------------------------------------------------------------------------- /ui/src/layout/layout-template/AppLayout.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | 18 | -------------------------------------------------------------------------------- /ui/src/layout/layout-template/DetailLayout.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 15 | 19 | -------------------------------------------------------------------------------- /ui/src/layout/layout-template/SystemLayout.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | -------------------------------------------------------------------------------- /ui/src/layout/layout-template/index.scss: -------------------------------------------------------------------------------- 1 | .app-layout { 2 | background-color: var(--app-layout-bg-color); 3 | height: 100%; 4 | } 5 | 6 | .app-main { 7 | position: relative; 8 | height: 100%; 9 | padding: var(--app-header-height) 0 0 !important; 10 | box-sizing: border-box; 11 | overflow: auto; 12 | &.isExpire { 13 | padding-top: calc(var(--app-header-height) + 40px) !important; 14 | } 15 | } 16 | 17 | .sidebar-container { 18 | box-sizing: border-box; 19 | transition: width 0.28s; 20 | width: var(--sidebar-width); 21 | min-width: var(--sidebar-width); 22 | background-color: var(--sidebar-bg-color); 23 | } 24 | .view-container { 25 | width: calc(100% - var(--sidebar-width)); 26 | } 27 | -------------------------------------------------------------------------------- /ui/src/locales/lang/en-US/components.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | quickCreatePlaceholder: 'Quickly create blank document', 3 | quickCreateName: 'document name', 4 | noData: 'No Data', 5 | loading: 'Loading', 6 | noMore: 'No more! ', 7 | selectParagraph: { 8 | title: 'Select Segments', 9 | error: 'Process only the failed segments', 10 | all: 'All Segments' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/locales/lang/en-US/index.ts: -------------------------------------------------------------------------------- 1 | import en from 'element-plus/es/locale/lang/en' 2 | import components from './components' 3 | import layout from './layout' 4 | import views from './views' 5 | import common from './common' 6 | import dynamicsForm from './dynamics-form' 7 | import chat from './ai-chat' 8 | export default { 9 | lang: 'English', 10 | layout, 11 | views, 12 | components, 13 | en, 14 | common, 15 | dynamicsForm, 16 | chat 17 | } 18 | -------------------------------------------------------------------------------- /ui/src/locales/lang/en-US/views/404.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: "404", 3 | message: "Unable to Access APP", 4 | operate: "Back to Home", 5 | }; 6 | -------------------------------------------------------------------------------- /ui/src/locales/lang/en-US/views/operate-log.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: 'Operate Logs', 3 | table: { 4 | menu: { 5 | label: 'Operate menu' 6 | }, 7 | operate: { 8 | label: 'Operate', 9 | detail: 'Operate details' 10 | }, 11 | user: { 12 | label: 'Operate user' 13 | }, 14 | status: { 15 | label: 'Status', 16 | success: 'Successful', 17 | fail: 'Failed', 18 | all: 'All' 19 | }, 20 | ip_address: { 21 | label: 'IP Address' 22 | }, 23 | opt: { 24 | label: 'API Details' 25 | }, 26 | operateTime: { 27 | label: 'Operate Time' 28 | } 29 | }, 30 | close: 'Close' 31 | } 32 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-CN/components.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | quickCreatePlaceholder: '快速创建空白文档', 3 | quickCreateName: '文档名称', 4 | noData: '无匹配数据', 5 | loading: '加载中', 6 | noMore: '到底啦!', 7 | selectParagraph: { 8 | title: '选择分段', 9 | error: '仅执行未成功分段', 10 | all: '全部分段' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-CN/index.ts: -------------------------------------------------------------------------------- 1 | import zhCn from 'element-plus/es/locale/lang/zh-cn' 2 | import components from './components' 3 | import layout from './layout' 4 | import views from './views' 5 | import common from './common' 6 | import dynamicsForm from './dynamics-form' 7 | import chat from './ai-chat' 8 | export default { 9 | lang: '简体中文', 10 | layout, 11 | views, 12 | components, 13 | zhCn, 14 | common, 15 | dynamicsForm, 16 | chat 17 | } 18 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-CN/views/404.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: "404", 3 | message: "无法访问应用", 4 | operate: "返回首页", 5 | }; 6 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-CN/views/login.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '普通登录', 3 | jump_tip: '即将跳转至认证源页面进行认证', 4 | jump: '跳转', 5 | resetPassword: '修改密码', 6 | forgotPassword: '忘记密码', 7 | userRegister: '用户注册', 8 | buttons: { 9 | login: '登录', 10 | register: '注册', 11 | backLogin: '返回登录', 12 | checkCode: '立即验证' 13 | }, 14 | newPassword: '新密码', 15 | enterPassword: '请输入修改密码', 16 | useEmail: '使用邮箱', 17 | moreMethod: '更多登录方式', 18 | verificationCode: { 19 | placeholder: '请输入验证码', 20 | getVerificationCode: '获取验证码', 21 | successMessage: '验证码发送成功', 22 | resend: '重新发送' 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-CN/views/operate-log.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '操作日志', 3 | table: { 4 | menu: { 5 | label: '操作菜单' 6 | }, 7 | operate: { 8 | label: '操作', 9 | detail: '操作详情' 10 | }, 11 | user: { 12 | label: '操作用户' 13 | }, 14 | status: { 15 | label: '状态', 16 | success: '成功', 17 | fail: '失败', 18 | all: '全部' 19 | }, 20 | ip_address: { 21 | label: 'IP地址' 22 | }, 23 | opt: { 24 | label: 'API详情' 25 | }, 26 | operateTime: { 27 | label: '操作时间' 28 | } 29 | }, 30 | close: '关闭' 31 | } 32 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-CN/views/paragraph.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '段落', 3 | paragraph_count: '段落', 4 | editParagraph: '编辑分段', 5 | addParagraph: '添加分段', 6 | paragraphDetail: '分段详情', 7 | character_count: '个字符', 8 | setting: { 9 | batchSelected: '批量选择', 10 | cancelSelected: '取消选择' 11 | }, 12 | delete: { 13 | confirmTitle: '是否删除段落:', 14 | confirmMessage: '删除后无法恢复,请谨慎操作。' 15 | }, 16 | relatedProblem: { 17 | title: '关联问题', 18 | placeholder: '请选择问题' 19 | }, 20 | form: { 21 | paragraphTitle: { 22 | label: '分段标题', 23 | placeholder: '请输入分段标题' 24 | }, 25 | content: { 26 | label: '分段内容', 27 | placeholder: '请输入分段内容', 28 | requiredMessage1: '请输入分段内容', 29 | requiredMessage2: '内容最多不超过 100000 个字' 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-CN/views/team.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '团队成员', 3 | member: '成员', 4 | manage: '所有者', 5 | permissionSetting: '权限设置', 6 | addMember: '添加成员', 7 | addSubTitle: '成员登录后可以访问到您授权的数据。', 8 | searchBar: { 9 | placeholder: '请输入用户名搜索' 10 | }, 11 | delete: { 12 | button: '移除', 13 | confirmTitle: '是否移除成员:', 14 | confirmMessage: '移除后将会取消成员拥有的知识库和应用权限。' 15 | }, 16 | setting: { 17 | management: '管理', 18 | check: '查看' 19 | }, 20 | teamForm: { 21 | form: { 22 | userName: { 23 | label: '用户名/邮箱', 24 | placeholder: '请输入成员的用户名或邮箱', 25 | requiredMessage: '请输入用户名/邮箱' 26 | }, 27 | 28 | }, 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-Hant/components.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | quickCreatePlaceholder: '快速創建空白文檔', 3 | quickCreateName: '文檔名稱', 4 | noData: '無匹配数据', 5 | loading: '加載中', 6 | noMore: '到底啦!', 7 | selectParagraph: { 8 | title: '選擇分段', 9 | error: '僅執行未成功分段', 10 | all: '全部分段' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-Hant/index.ts: -------------------------------------------------------------------------------- 1 | import zhTw from 'element-plus/es/locale/lang/zh-tw' 2 | import components from './components' 3 | import layout from './layout' 4 | import views from './views' 5 | import common from './common' 6 | import dynamicsForm from './dynamics-form' 7 | import chat from './ai-chat' 8 | export default { 9 | lang: '繁體中文', 10 | layout, 11 | common, 12 | views, 13 | components, 14 | zhTw, 15 | dynamicsForm, 16 | chat 17 | } 18 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-Hant/views/404.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '404', 3 | message: '無法訪問應用', 4 | operate: '返回首頁' 5 | } 6 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-Hant/views/login.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '普通登錄', 3 | jump_tip: '即將跳轉至認證源頁面進行認證', 4 | jump: '跳轉', 5 | resetPassword: '修改密碼', 6 | forgotPassword: '忘記密碼', 7 | userRegister: '用戶註冊', 8 | buttons: { 9 | login: '登錄', 10 | register: '註冊', 11 | backLogin: '返回登錄', 12 | checkCode: '立即驗證' 13 | }, 14 | newPassword: '新密碼', 15 | enterPassword: '請輸入新密碼', 16 | useEmail: '使用電子郵箱', 17 | moreMethod: '更多登錄方式', 18 | verificationCode: { 19 | placeholder: '請輸入驗證碼', 20 | getVerificationCode: '獲取驗證碼', 21 | successMessage: '驗證碼發送成功', 22 | resend: '重新發送' 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-Hant/views/operate-log.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '操作日誌', 3 | table: { 4 | menu: { 5 | label: '操作菜單' 6 | }, 7 | operate: { 8 | label: '操作', 9 | detail: '操作詳情' 10 | }, 11 | user: { 12 | label: '操作用戶' 13 | }, 14 | status: { 15 | label: '狀態', 16 | success: '成功', 17 | fail: '失敗', 18 | all: '全部' 19 | }, 20 | ip_address: { 21 | label: 'IP地址' 22 | }, 23 | opt: { 24 | label: 'API詳情' 25 | }, 26 | operateTime: { 27 | label: '操作時間' 28 | } 29 | }, 30 | close: '關閉' 31 | } 32 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-Hant/views/paragraph.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '段落', 3 | paragraph_count: '段落', 4 | editParagraph: '編輯分段', 5 | addParagraph: '添加分段', 6 | paragraphDetail: '分段詳情', 7 | character_count: '個字符', 8 | setting: { 9 | batchSelected: '批量選擇', 10 | cancelSelected: '取消選擇' 11 | }, 12 | delete: { 13 | confirmTitle: '是否刪除段落:', 14 | confirmMessage: '刪除後無法恢復,請謹慎操作。' 15 | }, 16 | relatedProblem: { 17 | title: '關聯問題', 18 | placeholder: '請選擇問題' 19 | }, 20 | form: { 21 | paragraphTitle: { 22 | label: '分段標題', 23 | placeholder: '請輸入分段標題' 24 | }, 25 | content: { 26 | label: '分段內容', 27 | placeholder: '請輸入分段內容', 28 | requiredMessage1: '請輸入分段內容', 29 | requiredMessage2: '內容最多不超過 100000 個字' 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ui/src/locales/lang/zh-Hant/views/team.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '團隊成員', 3 | member: '成員', 4 | manage: '所有者', 5 | permissionSetting: '權限設定', 6 | addMember: '新增成員', 7 | addSubTitle: '成員登入後可以存取您授權的資料。', 8 | searchBar: { 9 | placeholder: '請輸入使用者名稱搜尋' 10 | }, 11 | delete: { 12 | button: '移除', 13 | confirmTitle: '是否移除成員:', 14 | confirmMessage: '移除後將會取消成員擁有之知識庫和應用程式權限。' 15 | }, 16 | setting: { 17 | management: '管理', 18 | check: '查看' 19 | }, 20 | teamForm: { 21 | form: { 22 | userName: { 23 | label: '使用者名稱/電子郵件', 24 | placeholder: '請輸入成員的使用者名稱或電子郵件', 25 | requiredMessage: '請輸入使用者名稱/電子郵件' 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ui/src/router/modules/function-lib.ts: -------------------------------------------------------------------------------- 1 | const functionLibRouter = { 2 | path: '/function-lib', 3 | name: 'function_lib', 4 | meta: { title: 'views.functionLib.title', permission: 'APPLICATION:READ' }, 5 | redirect: '/function-lib', 6 | component: () => import('@/layout/layout-template/AppLayout.vue'), 7 | children: [ 8 | { 9 | path: '/function-lib', 10 | name: 'function-lib-index', 11 | meta: { title: '函数库主页', activeMenu: '/function-lib' }, 12 | component: () => import('@/views/function-lib/index.vue') 13 | } 14 | ] 15 | } 16 | 17 | export default functionLibRouter 18 | -------------------------------------------------------------------------------- /ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.eot -------------------------------------------------------------------------------- /ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.otf -------------------------------------------------------------------------------- /ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.ttf -------------------------------------------------------------------------------- /ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.woff -------------------------------------------------------------------------------- /ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Panel-dev/MaxKB/7ce66a7bf3ddf123a648e23db920eeaeb00cbe42/ui/src/styles/font/AlibabaPuHuiTi-3-55-Regular.woff2 -------------------------------------------------------------------------------- /ui/src/styles/index.scss: -------------------------------------------------------------------------------- 1 | @import 'element-plus/dist/index.css'; 2 | @import './variables.scss'; 3 | @import './app.scss'; 4 | @import './element-plus.scss'; 5 | @import 'nprogress/nprogress.css'; 6 | @import 'md-editor-v3/lib/style.css'; 7 | @import './md-editor.scss'; 8 | -------------------------------------------------------------------------------- /ui/src/utils/application.ts: -------------------------------------------------------------------------------- 1 | export const defaultIcon = '/ui/favicon.ico' 2 | 3 | // 是否显示字母 / icon 4 | export function isAppIcon(url: String | undefined) { 5 | return url === defaultIcon ? '' : url 6 | } 7 | 8 | export function isWorkFlow(type: string | undefined) { 9 | return type === 'WORK_FLOW' 10 | } 11 | -------------------------------------------------------------------------------- /ui/src/utils/clipboard.ts: -------------------------------------------------------------------------------- 1 | import Clipboard from 'vue-clipboard3' 2 | import { MsgSuccess, MsgError } from '@/utils/message' 3 | import { t } from '@/locales' 4 | /* 5 | 复制粘贴 6 | */ 7 | export async function copyClick(info: string) { 8 | const { toClipboard } = Clipboard() 9 | try { 10 | await toClipboard(info) 11 | MsgSuccess(t('common.copySuccess')) 12 | } catch (e) { 13 | console.error(e) 14 | MsgError(t('common.copyError')) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ui/src/utils/common.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 拆分数组 每n个拆分为一个数组 3 | * @param sourceDataList 资源数据 4 | * @param splitNum 每多少个拆分为一个数组 5 | * @returns 拆分后数组 6 | */ 7 | export function splitArray(sourceDataList: Array, splitNum: number) { 8 | const count = 9 | sourceDataList.length % splitNum == 0 10 | ? sourceDataList.length / splitNum 11 | : sourceDataList.length / splitNum + 1 12 | const arrayList: Array> = [] 13 | for (let i = 0; i < count; i++) { 14 | let index = i * splitNum 15 | const list: Array = [] 16 | let j = 0 17 | while (j < splitNum && index < sourceDataList.length) { 18 | list.push(sourceDataList[index++]) 19 | j++ 20 | } 21 | arrayList.push(list) 22 | } 23 | return arrayList 24 | } 25 | -------------------------------------------------------------------------------- /ui/src/utils/decimalFormat.ts: -------------------------------------------------------------------------------- 1 | function format(decimal?: number, digits?: number): string | undefined { 2 | if (digits == undefined) { 3 | digits = 0; 4 | } 5 | return decimal?.toLocaleString("zh-CN", { 6 | style: "decimal", 7 | minimumFractionDigits: digits, 8 | maximumFractionDigits: digits, 9 | }); 10 | } 11 | 12 | const util = { 13 | format, 14 | }; 15 | 16 | export default util; 17 | -------------------------------------------------------------------------------- /ui/src/utils/permission/type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 角色对象 3 | */ 4 | export class Role { 5 | role: string 6 | 7 | constructor(role: string) { 8 | this.role = role 9 | } 10 | } 11 | /** 12 | * 权限对象 13 | */ 14 | export class Permission { 15 | permission: string 16 | 17 | constructor(permission: string) { 18 | this.permission = permission 19 | } 20 | } 21 | /** 22 | * 复杂权限对象 23 | */ 24 | export class ComplexPermission { 25 | roleList: Array 26 | 27 | permissionList: Array 28 | 29 | compare: 'OR' | 'AND' 30 | 31 | constructor(roleList: Array, permissionList: Array, compare: 'OR' | 'AND') { 32 | this.roleList = roleList 33 | this.permissionList = permissionList 34 | this.compare = compare 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ui/src/views/first/index.vue: -------------------------------------------------------------------------------- 1 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /ui/src/views/template/component/data.ts: -------------------------------------------------------------------------------- 1 | import { modelType } from '@/enums/model' 2 | import { t } from '@/locales' 3 | export const modelTypeList = [ 4 | { text: t(modelType['LLM']), value: 'LLM' }, 5 | { text: t(modelType['EMBEDDING']), value: 'EMBEDDING' }, 6 | { text: t(modelType['RERANKER']), value: 'RERANKER' }, 7 | { text: t(modelType['STT']), value: 'STT' }, 8 | { text: t(modelType['TTS']), value: 'TTS' }, 9 | { text: t(modelType['IMAGE']), value: 'IMAGE' }, 10 | { text: t(modelType['TTI']), value: 'TTI' } 11 | ] 12 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/ai-chat-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/application-node-icon.vue: -------------------------------------------------------------------------------- 1 | 20 | 29 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/base-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/condition-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/document-extract-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/form-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/function-lib-node-icon.vue: -------------------------------------------------------------------------------- 1 | 15 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/function-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/global-icon.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/image-generate-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/image-understand-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/mcp-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/question-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/reply-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/reranker-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/search-dataset-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/speech-to-text-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/start-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/text-to-speech-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/utils.ts: -------------------------------------------------------------------------------- 1 | const icons: any = import.meta.glob('./**.vue', { eager: true }) 2 | export function iconComponent(name: string) { 3 | const url = `./${name}.vue` 4 | return icons[url]?.default || null 5 | } 6 | -------------------------------------------------------------------------------- /ui/src/workflow/icons/variable-assign-node-icon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/ai-chat-node/index.ts: -------------------------------------------------------------------------------- 1 | import ChatNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class ChatNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, ChatNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'ai-chat-node', 10 | model: AppNodeModel, 11 | view: ChatNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/application-node/index.ts: -------------------------------------------------------------------------------- 1 | import ChatNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class ChatNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, ChatNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'application-node', 10 | model: AppNodeModel, 11 | view: ChatNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/base-node/index.ts: -------------------------------------------------------------------------------- 1 | import BaseNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | 4 | class BaseNode extends AppNode { 5 | constructor(props: any) { 6 | super(props, BaseNodeVue) 7 | } 8 | } 9 | 10 | class BaseModel extends AppNodeModel { 11 | constructor(data: any, graphModel: any) { 12 | super(data, graphModel) 13 | } 14 | get_width() { 15 | return 600 16 | } 17 | } 18 | export default { 19 | type: 'base-node', 20 | model: BaseModel, 21 | view: BaseNode 22 | } 23 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/document-extract-node/index.ts: -------------------------------------------------------------------------------- 1 | import DocumentExtractNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class RerankerNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, DocumentExtractNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'document-extract-node', 10 | model: AppNodeModel, 11 | view: RerankerNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/function-lib-node/index.ts: -------------------------------------------------------------------------------- 1 | import FunctionLibNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class FunctionLibNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, FunctionLibNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'function-lib-node', 10 | model: AppNodeModel, 11 | view: FunctionLibNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/function-node/index.ts: -------------------------------------------------------------------------------- 1 | import FunctionNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class FunctionLibCustomNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, FunctionNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'function-node', 10 | model: AppNodeModel, 11 | view: FunctionLibCustomNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/image-generate/index.ts: -------------------------------------------------------------------------------- 1 | import ImageGenerateNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | 4 | class RerankerNode extends AppNode { 5 | constructor(props: any) { 6 | super(props, ImageGenerateNodeVue) 7 | } 8 | } 9 | 10 | export default { 11 | type: 'image-generate-node', 12 | model: AppNodeModel, 13 | view: RerankerNode 14 | } 15 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/image-understand/index.ts: -------------------------------------------------------------------------------- 1 | import ImageUnderstandNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | 4 | class RerankerNode extends AppNode { 5 | constructor(props: any) { 6 | super(props, ImageUnderstandNodeVue) 7 | } 8 | } 9 | 10 | export default { 11 | type: 'image-understand-node', 12 | model: AppNodeModel, 13 | view: RerankerNode 14 | } 15 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/mcp-node/index.ts: -------------------------------------------------------------------------------- 1 | import McpNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | 4 | class McpNode extends AppNode { 5 | constructor(props: any) { 6 | super(props, McpNodeVue) 7 | } 8 | } 9 | 10 | export default { 11 | type: 'mcp-node', 12 | model: AppNodeModel, 13 | view: McpNode 14 | } 15 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/question-node/index.ts: -------------------------------------------------------------------------------- 1 | import QuestionNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class QuestionNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, QuestionNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'question-node', 10 | model: AppNodeModel, 11 | view: QuestionNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/reply-node/index.ts: -------------------------------------------------------------------------------- 1 | import ReplyNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class ReplyNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, ReplyNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'reply-node', 10 | model: AppNodeModel, 11 | view: ReplyNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/reranker-node/index.ts: -------------------------------------------------------------------------------- 1 | import RerankerNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class RerankerNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, RerankerNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'reranker-node', 10 | model: AppNodeModel, 11 | view: RerankerNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/search-dataset-node/index.ts: -------------------------------------------------------------------------------- 1 | import SearchDatasetVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class SearchDatasetNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, SearchDatasetVue) 6 | } 7 | } 8 | export default { 9 | type: 'search-dataset-node', 10 | model: AppNodeModel, 11 | view: SearchDatasetNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/speech-to-text-node/index.ts: -------------------------------------------------------------------------------- 1 | import SpeechToTextVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class SpeechToTextNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, SpeechToTextVue) 6 | } 7 | } 8 | export default { 9 | type: 'speech-to-text-node', 10 | model: AppNodeModel, 11 | view: SpeechToTextNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/start-node/index.ts: -------------------------------------------------------------------------------- 1 | import StartNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class StartNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, StartNodeVue) 6 | } 7 | } 8 | export default { 9 | type: 'start-node', 10 | model: AppNodeModel, 11 | view: StartNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/text-to-speech-node/index.ts: -------------------------------------------------------------------------------- 1 | import TextToSpeechVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | class TextToSpeechNode extends AppNode { 4 | constructor(props: any) { 5 | super(props, TextToSpeechVue) 6 | } 7 | } 8 | export default { 9 | type: 'text-to-speech-node', 10 | model: AppNodeModel, 11 | view: TextToSpeechNode 12 | } 13 | -------------------------------------------------------------------------------- /ui/src/workflow/nodes/variable-assign-node/index.ts: -------------------------------------------------------------------------------- 1 | import VariableAssignNodeVue from './index.vue' 2 | import { AppNode, AppNodeModel } from '@/workflow/common/app-node' 3 | 4 | class VariableAssignNode extends AppNode { 5 | constructor(props: any) { 6 | super(props, VariableAssignNodeVue) 7 | } 8 | } 9 | 10 | export default { 11 | type: 'variable-assign-node', 12 | model: AppNodeModel, 13 | view: VariableAssignNode 14 | } 15 | -------------------------------------------------------------------------------- /ui/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.dom.json", 3 | "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], 4 | "exclude": ["src/**/__tests__/*"], 5 | "compilerOptions": { 6 | "composite": true, 7 | "moduleResolution": "node", 8 | "baseUrl": ".", 9 | "target": "esnext", // 使用ES最新语法 10 | "module": "esnext", // 使用ES模块语法 11 | "paths": { 12 | "@/*": ["./src/*"] 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "files": [], 4 | 5 | "references": [ 6 | { 7 | "path": "./tsconfig.node.json" 8 | }, 9 | { 10 | "path": "./tsconfig.app.json" 11 | }, 12 | { 13 | "path": "./tsconfig.vitest.json" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ui/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node18/tsconfig.json", 3 | "include": [ 4 | "vite.config.*", 5 | "vitest.config.*", 6 | "cypress.config.*", 7 | "nightwatch.conf.*", 8 | "playwright.config.*" 9 | ], 10 | "compilerOptions": { 11 | "composite": true, 12 | "module": "ESNext", 13 | "moduleResolution": "node", 14 | "skipLibCheck": true, // 跳过node依赖包语法检查 15 | "types": [ 16 | "node" 17 | ] 18 | } 19 | } -------------------------------------------------------------------------------- /ui/tsconfig.vitest.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.app.json", 3 | "exclude": [], 4 | "compilerOptions": { 5 | "composite": true, 6 | "target": "esnext", // 使用ES最新语法 7 | "module": "esnext", // 使用ES模块语法 8 | "lib": [], 9 | "types": ["node", "jsdom"] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ui/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath } from 'node:url' 2 | import { mergeConfig, defineConfig, configDefaults } from 'vitest/config' 3 | import viteConfig from './vite.config' 4 | 5 | export default mergeConfig( 6 | viteConfig as never, 7 | defineConfig({ 8 | test: { 9 | environment: 'jsdom', 10 | exclude: [...configDefaults.exclude, 'e2e/*'], 11 | root: fileURLToPath(new URL('./', import.meta.url)) 12 | } 13 | }) 14 | ) 15 | --------------------------------------------------------------------------------