Skip to content

Commit 1e8435d

Browse files
committed
storing the prompt and feedback for chatgpt
1 parent c0531d5 commit 1e8435d

File tree

8 files changed

+44
-6
lines changed

8 files changed

+44
-6
lines changed

app/jobs/generate_automatic_comments_job.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ def perform(request_for_comment, current_user)
2929
def perform_chat_gpt_request(request_for_comment, file, chat_gpt_service)
3030
prompt = ChatGptHelper.construct_prompt_for_rfc(request_for_comment, file)
3131
response = chat_gpt_service.make_chat_gpt_request(prompt, true)
32+
ChatGptHistoryOnRfc.create!(
33+
rfc_id: request_for_comment.id,
34+
prompt: prompt,
35+
response: response
36+
)
3237
ChatGptHelper.format_response(response)
3338
end
3439

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ChatGptHistoryOnRfc < ApplicationRecord
2+
validates :prompt, :response, presence: true
3+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ChatGptHistoryOnScore < ApplicationRecord
2+
validates :prompt, :response, presence: true
3+
end

app/models/testrun.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ def generate_ai_feedback
4848

4949
feedback_message = chatgpt_request.make_chat_gpt_request(prompt, false)
5050

51+
# Store AI feedback history
52+
ChatGptHistoryOnScore.create!(
53+
testrun_id: self.id,
54+
prompt: prompt,
55+
response: feedback_message
56+
)
57+
5158
# Format and sanitize the feedback message
5259
formatted_feedback = Kramdown::Document.new(feedback_message).to_html
5360
sanitized_feedback = ActionController::Base.helpers.sanitize(

app/services/chat_gpt_service/chat_gpt_prompts/prompt_de.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<prompt>
2-
<case>
3-
1-1 Syntaxfehler-Anfänger
4-
</case>
52
<role>
63
Du agierst als Tutor für einen Lernenden, der ein Problem bei einer Programmieraufgabe hat. Antworte im Folgenden entsprechend deiner Rolle als Tutor!
74
</role>

app/services/chat_gpt_service/chat_gpt_prompts/prompt_en.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<prompt>
2-
<case>
3-
1-1 Syntax Error - Beginner
4-
</case>
52
<role>
63
You are acting as a tutor for a learner who has encountered a problem in a programming task. Respond in accordance with your role as a tutor in the following!
74
</role>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
class CreateChatGptHistoryOnScore < ActiveRecord::Migration[7.2]
4+
def change
5+
create_table :chat_gpt_history_on_scores, id: :uuid do |t|
6+
t.integer :testrun_id
7+
t.text :prompt
8+
t.text :response
9+
10+
t.timestamps
11+
end
12+
end
13+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
class CreateChatGptHistoryOnRfc < ActiveRecord::Migration[7.2]
4+
def change
5+
create_table :chat_gpt_history_on_rfcs, id: :uuid do |t|
6+
t.integer :rfc_id
7+
t.text :prompt
8+
t.text :response
9+
10+
t.timestamps
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)