Class: Llm::Functions::AddToMemory
- Defined in:
- lib/llm/functions/add_to_memory.rb
Instance Method Summary collapse
- #definition ⇒ Object
- #execute_and_generate_message(args) ⇒ Object
- #function_name ⇒ Object
-
#initialize(message_container) ⇒ AddToMemory
constructor
A new instance of AddToMemory.
Methods inherited from Base
Constructor Details
#initialize(message_container) ⇒ AddToMemory
Returns a new instance of AddToMemory.
8 9 10 |
# File 'lib/llm/functions/add_to_memory.rb', line 8 def initialize() @message_container = end |
Instance Method Details
#definition ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/llm/functions/add_to_memory.rb', line 12 def definition return @definition unless @definition.nil? @definition = { name: self.function_name, description: I18n.t("ghostest.functions.#{self.function_name}.description"), parameters: { type: :object, properties: { contents_to_memory: { type: :string, description: I18n.t("ghostest.functions.#{self.function_name}.parameters.contents_to_memory"), }, }, required: [:contents_to_memory], }, } @definition end |
#execute_and_generate_message(args) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/llm/functions/add_to_memory.rb', line 32 def (args) if args[:contents_to_memory].nil? || args[:contents_to_memory].empty? raise "contents_to_memory is required" end @message_container.(I18n.t("ghostest.functions.#{self.function_name}.system_message_prefix", contents_to_memory: args[:contents_to_memory])) { result: 'success' } end |
#function_name ⇒ Object
4 5 6 |
# File 'lib/llm/functions/add_to_memory.rb', line 4 def function_name :add_to_memory end |