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(