From ff46f322608a00b95092e4e71c925673a9780d64 Mon Sep 17 00:00:00 2001 From: estromenko Date: Tue, 21 Oct 2025 20:43:10 +0300 Subject: [PATCH] Fix vacancy search and redis decoding --- backend/agent.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/agent.py b/backend/agent.py index b20c8bf..12f1ac0 100644 --- a/backend/agent.py +++ b/backend/agent.py @@ -38,14 +38,17 @@ search_tool = DuckDuckGoSearchRun() async def get_relevant_vacancies(requirements: str): """Получает релевантные вакансии из базы данных по переданным требованиям.""" - documents = await vectorstore.asimilarity_search(requirements, k=5) - return "\n\n".join(document.page_content for document in documents) + formatted_vacancies = "" + for document in await vectorstore.asimilarity_search(requirements, k=5): + metadata = document.metadata + formatted_vacancies += f"chat_id = {metadata['chat_id']}\ntelegram_id = {metadata['telegram_id']}\n{document.page_content}" + return formatted_vacancies async def get_user_resume(user_id: int): """Получает резюме пользователя для подбора вакансий.""" resume_bytes = await redis.get(user_id) - return resume_bytes.decode("utf-8") + return resume_bytes.decode("utf-8") if resume_bytes else "" agent = create_agent(