Skip to content

Commit

Permalink
Save line breaks on AI response
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Sep 20, 2023
1 parent d2de9d0 commit 312bf21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def process_as_ai

def respond_to_ai
if current_user.can_ai?
@entry.body += "<hr><strong>👤 You:</strong><br/>#{params[:entry][:ai_response]}"
@entry.body += "<hr><strong>👤 You:</strong><br/>#{ActionController::Base.helpers.simple_format(params[:entry][:ai_response])}"
if params[:entry][:ai_response].present? && @entry.save
AiEntryJob.perform_later(current_user.id, @entry.id, email: false)
flash[:notice] = "DabbleMeGPT response is generating."
Expand Down
6 changes: 3 additions & 3 deletions app/models/concerns/entry/ai_assistant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def respond_as_ai(messages)
max_tokens: MAX_RESPONSE_TOKENS
}
)
if resp["choices"].present?
resp.dig("choices", 0, "message", "content")
end
return unless resp["choices"].present?

resp.dig("choices", 0, "message", "content")
end

def as_life_coach
Expand Down

0 comments on commit 312bf21

Please sign in to comment.