mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
improvements(ai): Improve AI streaming UI/UX interactions + better separation of AI provider responsibilities (#2039)
* Start refactor * Interface updates * Rework Assistant, Provider, and tests for better domain boundaries * Consolidate and simplify OpenAI provider and provider concepts * Clean up assistant streaming * Improve assistant message orchestration logic * Clean up "thinking" UI interactions * Remove stale class * Regenerate VCR test responses
This commit is contained in:
@@ -23,15 +23,25 @@ class Chat < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def needs_assistant_response?
|
||||
conversation_messages.ordered.last.role != "assistant"
|
||||
end
|
||||
|
||||
def retry_last_message!
|
||||
update!(error: nil)
|
||||
|
||||
last_message = conversation_messages.ordered.last
|
||||
|
||||
if last_message.present? && last_message.role == "user"
|
||||
update!(error: nil)
|
||||
|
||||
ask_assistant_later(last_message)
|
||||
end
|
||||
end
|
||||
|
||||
def update_latest_response!(provider_response_id)
|
||||
update!(latest_assistant_response_id: provider_response_id)
|
||||
end
|
||||
|
||||
def add_error(e)
|
||||
update! error: e.to_json
|
||||
broadcast_append target: "messages", partial: "chats/error", locals: { chat: self }
|
||||
@@ -47,6 +57,7 @@ class Chat < ApplicationRecord
|
||||
end
|
||||
|
||||
def ask_assistant_later(message)
|
||||
clear_error
|
||||
AssistantResponseJob.perform_later(message)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user