Class: Rasti::AI::OpenAI::AssistantState

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context: nil) ⇒ AssistantState

Returns a new instance of AssistantState.



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

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

  messages << {role: Roles::SYSTEM, content: context} if context
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



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

def messages
  @messages
end

Instance Method Details

#fetch(key, &block) ⇒ Object



15
16
17
18
# File 'lib/rasti/ai/open_ai/assistant_state.rb', line 15

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