2024-12-24 18:38:51 +08:00
|
|
|
from flask_restful import Resource # type: ignore
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
from controllers.console import api
|
2024-10-14 17:26:04 +08:00
|
|
|
from controllers.console.datasets.hit_testing_base import DatasetsHitTestingBase
|
2025-03-10 19:50:11 +08:00
|
|
|
from controllers.console.wraps import (
|
|
|
|
account_initialization_required,
|
|
|
|
cloud_edition_billing_rate_limit_check,
|
|
|
|
setup_required,
|
|
|
|
)
|
2024-01-12 12:34:01 +08:00
|
|
|
from libs.login import login_required
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
|
2024-10-14 17:26:04 +08:00
|
|
|
class HitTestingApi(Resource, DatasetsHitTestingBase):
|
2023-05-15 08:51:32 +08:00
|
|
|
@setup_required
|
|
|
|
@login_required
|
|
|
|
@account_initialization_required
|
2025-03-10 19:50:11 +08:00
|
|
|
@cloud_edition_billing_rate_limit_check("knowledge")
|
2023-05-15 08:51:32 +08:00
|
|
|
def post(self, dataset_id):
|
|
|
|
dataset_id_str = str(dataset_id)
|
|
|
|
|
2024-10-14 17:26:04 +08:00
|
|
|
dataset = self.get_and_validate_dataset(dataset_id_str)
|
|
|
|
args = self.parse_args()
|
|
|
|
self.hit_testing_args_check(args)
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-10-14 17:26:04 +08:00
|
|
|
return self.perform_hit_testing(dataset, args)
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
|
2024-08-26 15:29:10 +08:00
|
|
|
api.add_resource(HitTestingApi, "/datasets/<uuid:dataset_id>/hit-testing")
|