-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement openAI #516
implement openAI #516
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется в целом норм! Только я не знаю OPenAiService - это сервис ли или просто ф-ция...
Но придет Серега думаю лучше подскажет
app/services/open_ai_service.rb
Outdated
|
||
ActiveRecord::Base.transaction do | ||
user = User.find_by(email: ENV.fetch('EMAIL_SPECIAL_USER')) | ||
form = Web::Resumes::AnswerForm.new(content:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему здесь используется форма, просто создать answer и передать контент
app/services/open_ai_service.rb
Outdated
@@ -0,0 +1,40 @@ | |||
# frozen_string_literal: true | |||
|
|||
class OpenAiService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
переименовать название класса
app/services/open_ai_service.rb
Outdated
|
||
class OpenAiService | ||
class << self | ||
def call(resume_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
переименовать название метода
app/services/open_ai_service.rb
Outdated
response_covering_letter = client.write_cover_letter(resume_summary) | ||
response_edited_text = client.edit_text_resume(resume_summary) | ||
|
||
return if response_recommendation['error'] || response_covering_letter['error'] || response_edited_text['error'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрать и рейзить ошибки в методах api
app/services/open_ai_service.rb
Outdated
class OpenAiService | ||
class << self | ||
def call(resume_id) | ||
resume = Resume.find(resume_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести поиск резюме в job а сюда передовать объект
app/lib/open_ai_api.rb
Outdated
@client = OpenAI::Client.new | ||
end | ||
|
||
def evaluate_resume(resume) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
при ошибке выбрасывать exeption
app/services/open_ai_service.rb
Outdated
end | ||
end | ||
|
||
def serializable_resume(resume) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
переименовать метод на prepare_resume
@@ -0,0 +1,5 @@ | |||
class AddEvaluatedOpenAiToResumes < ActiveRecord::Migration[7.0] | |||
def change | |||
add_column :resumes, :evaluated_open_ai, :boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
переименовать поле в evaluated_ai
config/locales/ru.yml
Outdated
@@ -1,4 +1,10 @@ | |||
ru: | |||
recommendation_open_ai: "### Рекомендация по улучшению:\n %{recommendation}\n### Сопроводительное письмо:\n %{letter}\n### Редактура:\n %{edit_text}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ecommendation_open_ai: |
Рекомендация по улучшению:
%{recommendation}
config/locales/en.yml
Outdated
@@ -1,4 +1,9 @@ | |||
en: | |||
recommendation_open_ai: "### Improvement recommendation:\n %{recommendation}\n### Cover letter:\n %{letter}\n### Editing:\n %{edit_text}" | |||
open_ai_command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавить ключ resume_summary_for_open_ai:
class AddSpecialUser < ActiveRecord::Migration[7.0] | ||
def change | ||
user = User.new( | ||
first_name: 'openAI', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
уточнить имя бота
app/lib/open_ai_api.rb
Outdated
@@ -0,0 +1,33 @@ | |||
# frozen_string_literal: true | |||
|
|||
class OpenAiApi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перименовать на helper или перенести код в сервис, а в application_container положить сам клиент
app/lib/open_ai_api.rb
Outdated
def chat(messages = []) | ||
client.chat( | ||
parameters: { | ||
model: 'gpt-3.5-turbo', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вынести в константы
app/lib/open_ai_api.rb
Outdated
chat([{ role: 'user', content: I18n.t('open_ai_command.evaluate_resume') }, { role: 'user', content: resume }]) | ||
end | ||
|
||
def write_cover_letter(resume) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрать все в один метод и передовать туда текст резюме и prompt(команду)
8bb3d71
to
3848292
Compare
No description provided.