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

Function embedding_by_document

apps/knowledge/task/embedding.py:62–92  ·  view source on GitHub ↗

向量化文档 @param state_list: @param document_id: 文档id @param model_id 向量模型 :return: None

(document_id, model_id, state_list=None)

Source from the content-addressed store, hash-verified

60
61@celery_app.task(base=QueueOnce, once={"keys": ["document_id"]}, name="celery:embedding_by_document")
62def embedding_by_document(document_id, model_id, state_list=None):
63 """
64 向量化文档
65 @param state_list:
66 @param document_id: 文档id
67 @param model_id 向量模型
68 :return: None
69 """
70
71 if state_list is None:
72 state_list = [
73 State.PENDING.value,
74 State.STARTED.value,
75 State.SUCCESS.value,
76 State.FAILURE.value,
77 State.REVOKE.value,
78 State.REVOKED.value,
79 State.IGNORED.value,
80 ]
81
82 def exception_handler(e):
83 ListenerManagement.update_status(QuerySet(Document).filter(id=document_id), TaskType.EMBEDDING, State.FAILURE)
84 maxkb_logger.error(
85 _("Failed to obtain vector model: {error} {traceback}").format(
86 error=str(e), traceback=traceback.format_exc()
87 )
88 )
89
90 embedding_model = get_embedding_model(model_id, exception_handler)
91 #
92 ListenerManagement.embedding_by_document(document_id, embedding_model, state_list)
93
94
95@celery_app.task(name="celery:embedding_by_document_list")

Callers

nothing calls this directly

Calls 2

embedding_by_documentMethod · 0.80
get_embedding_modelFunction · 0.70

Tested by

no test coverage detected