mirror of
https://github.com/langgenius/dify.git
synced 2026-02-25 04:06:30 +08:00
* test: adding some web tests (#27792) * feat: add validation to prevent saving empty opening statement in conversation opener modal (#27843) * fix(web): improve the consistency of the inputs-form UI (#27837) * fix(web): increase z-index of PortalToFollowElemContent (#27823) * fix: installation_id is missing when in tools page (#27849) * fix: avoid passing empty uniqueIdentifier to InstallFromMarketplace (#27802) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * test: create new test scripts and update some existing test scripts o… (#27850) * feat: change feedback to forum (#27862) * chore: translate i18n files and update type definitions (#27868) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> * Fix/template transformer line number (#27867) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> * bump vite to 6.4.1 (#27877) * Add WEAVIATE_GRPC_ENDPOINT as designed in weaviate migration guide (#27861) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * Fix: correct DraftWorkflowApi.post response model (#27289) Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix Version 2.0.0-beta.2: Chat annotations Api Error #25506 (#27206) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> * fix jina reader creadential migration command (#27883) * fix agent putout the output of workflow-tool twice (#26835) (#27087) * fix jina reader transform (#27922) * fix: prevent fetch version info in enterprise edition (#27923) * fix(api): fix `VariablePool.get` adding unexpected keys to variable_dictionary (#26767) Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: implement tenant self queue for rag tasks (#27559) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> * fix: bump brotli to 1.2.0 resloved CVE-2025-6176 (#27950) Signed-off-by: kenwoodjw <blackxin55+@gmail.com> --------- Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Signed-off-by: kenwoodjw <blackxin55+@gmail.com> Co-authored-by: aka James4u <smart.jamesjin@gmail.com> Co-authored-by: Novice <novice12185727@gmail.com> Co-authored-by: yangzheli <43645580+yangzheli@users.noreply.github.com> Co-authored-by: Elliott <105957288+Elliott-byte@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: johnny0120 <johnny0120@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Gritty_dev <101377478+codomposer@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: wangjifeng <163279492+kk-wangjifeng@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: Cursx <33718736+Cursx@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: red_sun <56100962+redSun64@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: hj24 <huangjian@dify.ai> Co-authored-by: kenwoodjw <blackxin55+@gmail.com>
84 lines
3.5 KiB
Python
84 lines
3.5 KiB
Python
import logging
|
|
from collections.abc import Callable, Sequence
|
|
from dataclasses import asdict
|
|
from functools import cached_property
|
|
|
|
from core.entities.document_task import DocumentTask
|
|
from core.rag.pipeline.queue import TenantIsolatedTaskQueue
|
|
from enums.cloud_plan import CloudPlan
|
|
from services.feature_service import FeatureService
|
|
from tasks.document_indexing_task import normal_document_indexing_task, priority_document_indexing_task
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class DocumentIndexingTaskProxy:
|
|
def __init__(self, tenant_id: str, dataset_id: str, document_ids: Sequence[str]):
|
|
self._tenant_id = tenant_id
|
|
self._dataset_id = dataset_id
|
|
self._document_ids = document_ids
|
|
self._tenant_isolated_task_queue = TenantIsolatedTaskQueue(tenant_id, "document_indexing")
|
|
|
|
@cached_property
|
|
def features(self):
|
|
return FeatureService.get_features(self._tenant_id)
|
|
|
|
def _send_to_direct_queue(self, task_func: Callable[[str, str, Sequence[str]], None]):
|
|
logger.info("send dataset %s to direct queue", self._dataset_id)
|
|
task_func.delay( # type: ignore
|
|
tenant_id=self._tenant_id, dataset_id=self._dataset_id, document_ids=self._document_ids
|
|
)
|
|
|
|
def _send_to_tenant_queue(self, task_func: Callable[[str, str, Sequence[str]], None]):
|
|
logger.info("send dataset %s to tenant queue", self._dataset_id)
|
|
if self._tenant_isolated_task_queue.get_task_key():
|
|
# Add to waiting queue using List operations (lpush)
|
|
self._tenant_isolated_task_queue.push_tasks(
|
|
[
|
|
asdict(
|
|
DocumentTask(
|
|
tenant_id=self._tenant_id, dataset_id=self._dataset_id, document_ids=self._document_ids
|
|
)
|
|
)
|
|
]
|
|
)
|
|
logger.info("push tasks: %s - %s", self._dataset_id, self._document_ids)
|
|
else:
|
|
# Set flag and execute task
|
|
self._tenant_isolated_task_queue.set_task_waiting_time()
|
|
task_func.delay( # type: ignore
|
|
tenant_id=self._tenant_id, dataset_id=self._dataset_id, document_ids=self._document_ids
|
|
)
|
|
logger.info("init tasks: %s - %s", self._dataset_id, self._document_ids)
|
|
|
|
def _send_to_default_tenant_queue(self):
|
|
self._send_to_tenant_queue(normal_document_indexing_task)
|
|
|
|
def _send_to_priority_tenant_queue(self):
|
|
self._send_to_tenant_queue(priority_document_indexing_task)
|
|
|
|
def _send_to_priority_direct_queue(self):
|
|
self._send_to_direct_queue(priority_document_indexing_task)
|
|
|
|
def _dispatch(self):
|
|
logger.info(
|
|
"dispatch args: %s - %s - %s",
|
|
self._tenant_id,
|
|
self.features.billing.enabled,
|
|
self.features.billing.subscription.plan,
|
|
)
|
|
# dispatch to different indexing queue with tenant isolation when billing enabled
|
|
if self.features.billing.enabled:
|
|
if self.features.billing.subscription.plan == CloudPlan.SANDBOX:
|
|
# dispatch to normal pipeline queue with tenant self sub queue for sandbox plan
|
|
self._send_to_default_tenant_queue()
|
|
else:
|
|
# dispatch to priority pipeline queue with tenant self sub queue for other plans
|
|
self._send_to_priority_tenant_queue()
|
|
else:
|
|
# dispatch to priority queue without tenant isolation for others, e.g.: self-hosted or enterprise
|
|
self._send_to_priority_direct_queue()
|
|
|
|
def delay(self):
|
|
self._dispatch()
|