Skip to content
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

Merged
merged 1 commit into from
Apr 19, 2023
Merged

implement openAI #516

merged 1 commit into from
Apr 19, 2023

Conversation

usernaimandrey
Copy link
Contributor

No description provided.

Copy link
Contributor

@grozwalker grozwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне кажется в целом норм! Только я не знаю OPenAiService - это сервис ли или просто ф-ция...

Но придет Серега думаю лучше подскажет


ActiveRecord::Base.transaction do
user = User.find_by(email: ENV.fetch('EMAIL_SPECIAL_USER'))
form = Web::Resumes::AnswerForm.new(content:)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему здесь используется форма, просто создать answer и передать контент

@@ -0,0 +1,40 @@
# frozen_string_literal: true

class OpenAiService
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переименовать название класса


class OpenAiService
class << self
def call(resume_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переименовать название метода

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']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрать и рейзить ошибки в методах api

class OpenAiService
class << self
def call(resume_id)
resume = Resume.find(resume_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенести поиск резюме в job а сюда передовать объект

@client = OpenAI::Client.new
end

def evaluate_resume(resume)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

при ошибке выбрасывать exeption

end
end

def serializable_resume(resume)
Copy link
Contributor Author

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переименовать поле в evaluated_ai

@@ -1,4 +1,10 @@
ru:
recommendation_open_ai: "### Рекомендация по улучшению:\n %{recommendation}\n### Сопроводительное письмо:\n %{letter}\n### Редактура:\n %{edit_text}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ecommendation_open_ai: |

Рекомендация по улучшению:

%{recommendation}

@@ -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:
Copy link
Contributor Author

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',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

уточнить имя бота

@@ -0,0 +1,33 @@
# frozen_string_literal: true

class OpenAiApi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перименовать на helper или перенести код в сервис, а в application_container положить сам клиент

def chat(messages = [])
client.chat(
parameters: {
model: 'gpt-3.5-turbo',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынести в константы

chat([{ role: 'user', content: I18n.t('open_ai_command.evaluate_resume') }, { role: 'user', content: resume }])
end

def write_cover_letter(resume)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрать все в один метод и передовать туда текст резюме и prompt(команду)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants