Compare commits

..

No commits in common. "3a7098f751e91f90290b36748996c683bbaa1246" and "55ee3b7ba43757cd76c93cc6b901aab21a2543a4" have entirely different histories.

6 changed files with 16 additions and 66 deletions

View File

@ -1,3 +0,0 @@
import logging
logging.basicConfig(level=logging.INFO)

View File

@ -1,6 +1,5 @@
import io
import os
import asyncio
import traceback
from asgiref.sync import sync_to_async
@ -67,7 +66,7 @@ async def next_vacancy(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(chat_id=update.effective_chat.id, text=message)
return
vacancy = await asyncio.to_thread(get_next_vacancy, customer_cv)
vacancy = get_next_vacancy(customer_cv)
if not vacancy:
message = "Вакансии закончились, возвращайтесь позже!"
await context.bot.send_message(chat_id=update.effective_chat.id, text=message)
@ -126,24 +125,25 @@ async def handle_document(update: Update, context: ContextTypes.DEFAULT_TYPE):
job_titles: list[Literal[tuple(db_job_titles)]]
min_salary_rub: int | None
max_salary_rub: int | None
years_of_experience: int | None
work_format: Literal["Удаленный", "Офис", "Гибрид", None]
openai_client = ChatOpenAI(model_name="gpt-5-mini")
openai_client = ChatOpenAI(model_name="gpt-5-mini", temperature=0, seed=42, top_p=1)
structured_llm = openai_client.with_structured_output(Structure)
prompt = f"Extract sturcture from following CV. {resume}"
print('1')
prompt = f"""
Ты HR-классификатор. Ниже приведён список допустимых профессий.
Твоя задача выбрать наиболее подходящие по смыслу.
Качество классификации - самое важное.
Игнорируй орфографические и стилистические различия.
Резюме:
{resume}
"""
response = await structured_llm.ainvoke(prompt)
print('2')
customer = await Customer.objects.aget(telegram_id=update.effective_user.id)
customer_cv, _ = await CustomerCV.objects.aupdate_or_create(customer=customer, defaults=dict(
content=resume,
min_salary_rub=response.min_salary_rub,
max_salary_rub=response.max_salary_rub,
years_of_experience=response.years_of_experience,
work_format=response.work_format,
))
await customer_cv.job_titles.aset([job_title_map[job_title] for job_title in response.job_titles])

View File

@ -24,8 +24,7 @@ WHERE timestamp >= %(timestamp)s
'заниматься', 'формат', 'занятость', 'вилка', 'должност', 'контакт'
]) >= 5
AND arrayCount(x -> position(lower(message), x) > 0, [
'о себе', 'обо мне', 'умею', '#ищу', '#резюме', 'университет', 'колледж',
'не будет опубликовано'
'о себе', 'обо мне', 'умею', '#ищу', '#резюме', 'университет', 'колледж'
]) = 0
ORDER BY timestamp ASC
"""
@ -42,10 +41,8 @@ class Command(BaseCommand):
job_title: Literal[tuple(job_titles)]
min_salary_rub: int | None
max_salary_rub: int | None
min_years_of_experience: int
work_format: Literal["remote", "office", None]
openai_client = ChatOpenAI(model_name="gpt-5-mini", temperature=0, seed=42, top_p=1)
openai_client = ChatOpenAI(model_name="gpt-5-mini", reasoning_effort="minimal", temperature=0, seed=42, top_p=1)
structured_llm = openai_client.with_structured_output(Structure)
last_timestamp = timezone.now() - timedelta(days=30)
@ -62,7 +59,6 @@ class Command(BaseCommand):
Ты HR-классификатор. Ниже приведён список допустимых профессий.
Твоя задача выбрать наиболее подходящую по смыслу.
Качество классификации - самое важное.
Если не уверен, то лучше укажи "Другое", ошибки недопустимы.
Игнорируй орфографические и стилистические различия.
Вакансия:
{row[3]}
@ -78,8 +74,6 @@ class Command(BaseCommand):
job_title_id=job_title_map[response.job_title],
min_salary_rub=response.min_salary_rub,
max_salary_rub=response.max_salary_rub,
min_years_of_experience=response.min_years_of_experience,
work_format=response.work_format,
content=message,
timestamp=timezone.make_aware(timestamp),
link=f"https://t.me/{chat_username}/{telegram_id}",

View File

@ -1,35 +0,0 @@
# Generated by Django 5.2.7 on 2025-11-09 12:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0011_remove_customercv_job_title_customercv_job_titles_and_more'),
]
operations = [
migrations.AddField(
model_name='customercv',
name='work_format',
field=models.CharField(blank=True, max_length=64, null=True),
),
migrations.AddField(
model_name='customercv',
name='years_of_experience',
field=models.PositiveBigIntegerField(default=0),
preserve_default=False,
),
migrations.AddField(
model_name='vacancy',
name='min_years_of_experience',
field=models.PositiveBigIntegerField(default=0),
preserve_default=False,
),
migrations.AddField(
model_name='vacancy',
name='work_format',
field=models.CharField(blank=True, max_length=64, null=True),
),
]

View File

@ -28,8 +28,6 @@ class CustomerCV(models.Model):
job_titles = models.ManyToManyField(JobTitle, related_name="vacancies")
min_salary_rub = models.PositiveIntegerField(null=True, blank=True, default=None)
max_salary_rub = models.PositiveIntegerField(null=True, blank=True, default=None)
years_of_experience = models.PositiveBigIntegerField()
work_format = models.CharField(max_length=64, null=True, blank=True)
content = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
@ -47,8 +45,6 @@ class Vacancy(models.Model):
external_id = models.CharField(max_length=255, unique=True)
min_salary_rub = models.PositiveIntegerField(null=True, blank=True, default=None)
max_salary_rub = models.PositiveIntegerField(null=True, blank=True, default=None)
min_years_of_experience = models.PositiveBigIntegerField()
work_format = models.CharField(max_length=64, null=True, blank=True)
content = models.TextField()
timestamp = models.DateTimeField()
link = models.URLField()

View File

@ -1,14 +1,12 @@
from vacancies.main.models import Vacancy
from django.db.models import Q
def get_next_vacancy(customer_cv):
vacancy = Vacancy.objects.filter(
~Q(id__in=customer_cv.customer.recommended_vacancies.values_list("vacancy_id", flat=True)),
Q(min_salary_rub__isnull=True) | Q(min_salary_rub__gt=customer_cv.min_salary_rub),
Q(work_format__isnull=True) | Q(work_format=customer_cv.work_format),
vacancy = Vacancy.objects.exclude(
id__in=customer_cv.customer.recommended_vacancies.values_list("vacancy_id", flat=True),
).filter(
job_title__title__in=customer_cv.job_titles.values_list("title", flat=True),
min_years_of_experience__lte=customer_cv.years_of_experience,
min_salary_rub__gt=customer_cv.min_salary_rub,
).first()
if vacancy:
customer_cv.customer.recommended_vacancies.create(vacancy=vacancy)