Class: Rasti::AI::AssistantState

Inherits:
Object
  • Object
show all
Defined in:
lib/rasti/ai/assistant_state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context: nil) ⇒ AssistantState

Returns a new instance of AssistantState.



7
8
9
10
11
# File 'lib/rasti/ai/assistant_state.rb', line 7

def initialize(context:nil)
  @messages = []
  @cache = {}
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/rasti/ai/assistant_state.rb', line 5

def context
  @context
end

#messagesObject (readonly)

Returns the value of attribute messages.



5
6
7
# File 'lib/rasti/ai/assistant_state.rb', line 5

def messages
  @messages
end

Instance Method Details

#fetch(key, &block) ⇒ Object



13
14
15
16
# File 'lib/rasti/ai/assistant_state.rb', line 13

def fetch(key, &block)
  cache[key] = block.call unless cache.key? key
  cache[key]
end