Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

hit_testing.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from flask_restx import Resource, fields
  2. from controllers.console import api, console_ns
  3. from controllers.console.datasets.hit_testing_base import DatasetsHitTestingBase
  4. from controllers.console.wraps import (
  5. account_initialization_required,
  6. cloud_edition_billing_rate_limit_check,
  7. setup_required,
  8. )
  9. from libs.login import login_required
  10. @console_ns.route("/datasets/<uuid:dataset_id>/hit-testing")
  11. class HitTestingApi(Resource, DatasetsHitTestingBase):
  12. @api.doc("test_dataset_retrieval")
  13. @api.doc(description="Test dataset knowledge retrieval")
  14. @api.doc(params={"dataset_id": "Dataset ID"})
  15. @api.expect(
  16. api.model(
  17. "HitTestingRequest",
  18. {
  19. "query": fields.String(required=True, description="Query text for testing"),
  20. "retrieval_model": fields.Raw(description="Retrieval model configuration"),
  21. "top_k": fields.Integer(description="Number of top results to return"),
  22. "score_threshold": fields.Float(description="Score threshold for filtering results"),
  23. },
  24. )
  25. )
  26. @api.response(200, "Hit testing completed successfully")
  27. @api.response(404, "Dataset not found")
  28. @api.response(400, "Invalid parameters")
  29. @setup_required
  30. @login_required
  31. @account_initialization_required
  32. @cloud_edition_billing_rate_limit_check("knowledge")
  33. def post(self, dataset_id):
  34. dataset_id_str = str(dataset_id)
  35. dataset = self.get_and_validate_dataset(dataset_id_str)
  36. args = self.parse_args()
  37. self.hit_testing_args_check(args)
  38. return self.perform_hit_testing(dataset, args)