diff --git a/vacancies/main/bot.py b/vacancies/main/bot.py index 890559d..2b33700 100644 --- a/vacancies/main/bot.py +++ b/vacancies/main/bot.py @@ -1,4 +1,5 @@ import io +import asyncio import os import traceback @@ -126,13 +127,18 @@ async def handle_document(update: Update, context: ContextTypes.DEFAULT_TYPE): customer_cv, _ = await CustomerCV.objects.aupdate_or_create(customer=customer, defaults=dict( content=resume, )) - features = batch_extract_features(customer_cv.content)[0] - add_vectors( - "cvs", - customer_cv.id, - embed_features(features.model_dump())[0], - {'content': customer_cv.content, 'features_json': features.model_dump()}, - ) + + def upload_vectors(): + features = batch_extract_features([customer_cv.content])[0] + add_vectors( + "cvs", + customer_cv.id, + features.model_dump(), + {'content': customer_cv.content, 'features_json': features.model_dump()}, + embed_features(features.model_dump()), + ) + + await asyncio.to_thread(upload_vectors) await context.bot.editMessageText("Отлично! Запомнил Ваше резюме.", update.effective_chat.id, message.id)