Class: Google::Genai::Chat
- Inherits:
-
Object
- Object
- Google::Genai::Chat
- Defined in:
- lib/google/genai/chats.rb
Instance Attribute Summary collapse
-
#history ⇒ Object
readonly
Returns the value of attribute history.
Instance Method Summary collapse
-
#initialize(client:, model:, history: [], config: nil) ⇒ Chat
constructor
A new instance of Chat.
- #send_message(message) ⇒ Object
Constructor Details
#initialize(client:, model:, history: [], config: nil) ⇒ Chat
Returns a new instance of Chat.
18 19 20 21 22 23 |
# File 'lib/google/genai/chats.rb', line 18 def initialize(client:, model:, history: [], config: nil) @client = client @model = model @history = history @config = config end |
Instance Attribute Details
#history ⇒ Object (readonly)
Returns the value of attribute history.
16 17 18 |
# File 'lib/google/genai/chats.rb', line 16 def history @history end |
Instance Method Details
#send_message(message) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/google/genai/chats.rb', line 25 def () @history << { role: 'user', parts: [{ text: }] } response = @client.models.generate_content( model: @model, contents: @history, config: @config ) @history << response.candidates.first.content.to_h response end |