Class: ActiveIntelligence::Chat
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActiveIntelligence::Chat
- Includes:
- Promptable
- Defined in:
- app/models/active_intelligence/chat.rb
Instance Method Summary collapse
Instance Method Details
#as_json(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/models/active_intelligence/chat.rb', line 12 def as_json( = {}) if .empty? [:only] = %i[id created_at updated_at] [:methods] = %i[messages_count] [:include] = [messages: { only: %i[id role content created_at updated_at] }] end super() end |
#reply(options = {}) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/models/active_intelligence/chat.rb', line 22 def reply( = {}) = .dup llm = ActiveIntelligence::LLM::Config.new.adapter([:adapter]) prompt = .delete(:prompt) || to_prompt(.delete(:name)) reply = llm.reply(self, prompt, ) return .create!(role: 'assistant', content: reply) end |