mirror of
https://github.com/langgenius/dify.git
synced 2026-05-29 05:07:55 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: EvanYao826 <155432245+EvanYao826@users.noreply.github.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: 盐粒 Yanli <yanli@dify.ai> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Tianle <40735546+Tianlel@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: zyssyz123 <916125788@qq.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Nian <11332799+Lillian68@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Carmen Fernández Ruiz <279459669+zeus1959@users.noreply.github.com> Co-authored-by: wangxiaolei <fatelei@gmail.com> Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: L1nSn0w <l1nsn0w@qq.com> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: Escape0707 <tothesong@gmail.com> Co-authored-by: Jingyi <jingyi.qi@dify.ai> Co-authored-by: Amr Sherif <140330826+amr-sheriff@users.noreply.github.com> Co-authored-by: ZHOU ZHICHEN <118870511+zhuiguangzhe2003@users.noreply.github.com> Co-authored-by: unknown <EI05187@apwx.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
from uuid import UUID
|
|
|
|
from controllers.common.schema import register_response_schema_models, register_schema_models
|
|
from controllers.console.datasets.hit_testing_base import DatasetsHitTestingBase, HitTestingPayload
|
|
from controllers.service_api import service_api_ns
|
|
from controllers.service_api.wraps import DatasetApiResource, cloud_edition_billing_rate_limit_check
|
|
from fields.hit_testing_fields import HitTestingResponse
|
|
from libs.helper import dump_response
|
|
|
|
register_schema_models(service_api_ns, HitTestingPayload)
|
|
register_response_schema_models(service_api_ns, HitTestingResponse)
|
|
|
|
|
|
@service_api_ns.route("/datasets/<uuid:dataset_id>/hit-testing", "/datasets/<uuid:dataset_id>/retrieve")
|
|
class HitTestingApi(DatasetApiResource, DatasetsHitTestingBase):
|
|
@service_api_ns.doc("dataset_hit_testing")
|
|
@service_api_ns.doc(description="Perform hit testing on a dataset")
|
|
@service_api_ns.doc(params={"dataset_id": "Dataset ID"})
|
|
@service_api_ns.response(
|
|
200,
|
|
"Hit testing results",
|
|
model=service_api_ns.models[HitTestingResponse.__name__],
|
|
)
|
|
@service_api_ns.response(401, "Unauthorized - invalid API token")
|
|
@service_api_ns.response(404, "Dataset not found")
|
|
@service_api_ns.expect(service_api_ns.models[HitTestingPayload.__name__])
|
|
@cloud_edition_billing_rate_limit_check("knowledge", "dataset")
|
|
def post(self, tenant_id: str, dataset_id: UUID) -> dict[str, object]:
|
|
"""Perform hit testing on a dataset.
|
|
|
|
Tests retrieval performance for the specified dataset.
|
|
"""
|
|
dataset_id_str = str(dataset_id)
|
|
|
|
dataset = self.get_and_validate_dataset(dataset_id_str)
|
|
args = self.parse_args(service_api_ns.payload)
|
|
self.hit_testing_args_check(args)
|
|
|
|
return dump_response(HitTestingResponse, self.perform_hit_testing(dataset, args))
|