MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / is_valid

Method is_valid

apps/knowledge/serializers/document.py:590–603  ·  view source on GitHub ↗
(self, *, raise_exception=False)

Source from the content-addressed store, hash-verified

588 document_id = serializers.UUIDField(required=True, label=_("document id"))
589
590 def is_valid(self, *, raise_exception=False):
591 super().is_valid(raise_exception=True)
592 workspace_id = self.data.get("workspace_id")
593 query_set = QuerySet(Knowledge).filter(id=self.data.get("knowledge_id"))
594 if workspace_id:
595 query_set = query_set.filter(workspace_id=workspace_id)
596 if not query_set.exists():
597 raise AppApiException(500, _("Knowledge id does not exist"))
598 document_id = self.data.get("document_id")
599 first = QuerySet(Document).filter(id=document_id).first()
600 if first is None:
601 raise AppApiException(500, _("document id not exist"))
602 if first.type != KnowledgeType.WEB:
603 raise AppApiException(500, _("Synchronization is only supported for web site types"))
604
605 @transaction.atomic
606 def sync(self, with_valid=True, with_embedding=True):

Callers 1

syncMethod · 0.95

Calls 3

AppApiExceptionClass · 0.90
is_validMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected