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

Method edit

apps/knowledge/serializers/document.py:778–789  ·  view source on GitHub ↗
(self, instance: Dict, with_valid=False)

Source from the content-addressed store, hash-verified

776 )
777
778 def edit(self, instance: Dict, with_valid=False):
779 if with_valid:
780 self.is_valid(raise_exception=True)
781 _document = QuerySet(Document).get(id=self.data.get("document_id"))
782 if with_valid:
783 DocumentEditInstanceSerializer(data=instance).is_valid(document=_document)
784 update_keys = ["name", "is_active", "hit_handling_method", "directly_return_similarity", "meta"]
785 for update_key in update_keys:
786 if update_key in instance and instance.get(update_key) is not None:
787 _document.__setattr__(update_key, instance.get(update_key))
788 _document.save()
789 return self.one()
790
791 def cancel(self, instance, with_valid=True):
792 if with_valid:

Callers

nothing calls this directly

Calls 6

is_validMethod · 0.95
oneMethod · 0.95
getMethod · 0.45
is_validMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected