Class: Askcii::Chat
- Inherits:
-
Object
- Object
- Askcii::Chat
- Defined in:
- lib/askcii/models/chat.rb
Instance Method Summary collapse
Instance Method Details
#persist_message_completion(message) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/askcii/models/chat.rb', line 31 def () return unless .update( role: .role, content: .content, model_id: .model_id, input_tokens: .input_tokens, output_tokens: .output_tokens ) end |
#persist_new_message ⇒ Object
24 25 26 27 28 29 |
# File 'lib/askcii/models/chat.rb', line 24 def = ( role: :assistant, content: String.new ) end |
#to_llm ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/askcii/models/chat.rb', line 7 def to_llm current_config = Askcii::Config.current_configuration provider_symbol = current_config['provider'] ? current_config['provider'].to_sym : :openai @chat = RubyLLM.chat( model: model_id, provider: provider_symbol, assume_model_exists: true ) .each do |msg| @chat.(msg.to_llm) end @chat. { } @chat. { |msg| (msg) } @chat end |