Skip to content

Commit 26f6deb

Browse files
committed
code refactoring
1 parent 1e8435d commit 26f6deb

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

app/helpers/chat_gpt_helper.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11

22
module ChatGptHelper
33

4-
5-
def self.construct_prompt_for_rfc(request_for_comment, file)
6-
submission = request_for_comment.submission
7-
test_run_results = Testrun.where(submission_id: submission.id).map(&:log).join("\n")
8-
options = {
9-
learner_solution: file.content,
10-
exercise: submission.exercise.description,
11-
test_results: test_run_results,
12-
question: request_for_comment.question
13-
}
14-
format_prompt(options)
15-
end
16-
174
def self. format_prompt(options)
185
if I18n.locale == :en
196
file_path = Rails.root.join('app', 'services/chat_gpt_service/chat_gpt_prompts', 'prompt_en.xml')

app/jobs/generate_automatic_comments_job.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ def perform(request_for_comment, current_user)
2727
private
2828

2929
def perform_chat_gpt_request(request_for_comment, file, chat_gpt_service)
30-
prompt = ChatGptHelper.construct_prompt_for_rfc(request_for_comment, file)
30+
prompt = ChatGptHelper.format_prompt(
31+
learner_solution: file.content,
32+
exercise: request_for_comment.submission.exercise.description,
33+
test_results: Testrun.where(submission_id: request_for_comment.submission.id).map(&:log).join("\n"),
34+
question: request_for_comment.question
35+
)
3136
response = chat_gpt_service.make_chat_gpt_request(prompt, true)
3237
ChatGptHistoryOnRfc.create!(
3338
rfc_id: request_for_comment.id,

0 commit comments

Comments
 (0)