Class: Rasti::AI::OpenAI::AssistantState
- Inherits:
-
Object
- Object
- Rasti::AI::OpenAI::AssistantState
- Defined in:
- lib/rasti/ai/open_ai/assistant_state.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
- #fetch(key, &block) ⇒ Object
-
#initialize(context: nil) ⇒ AssistantState
constructor
A new instance of AssistantState.
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) = [] @cache = {} << {role: Roles::SYSTEM, content: context} if context end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
6 7 8 |
# File 'lib/rasti/ai/open_ai/assistant_state.rb', line 6 def 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 |