Class: Llm::Functions::MakeNewFile
- Defined in:
- lib/llm/functions/make_new_file.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#definition ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/llm/functions/make_new_file.rb', line 8 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: { filepath: { type: :string, description: I18n.t("ghostest.functions.#{self.function_name}.parameters.filepath"), }, file_contents: { type: :string, description: I18n.t("ghostest.functions.#{self.function_name}.parameters.file_contents"), }, }, required: [:filepath, :file_contents], }, } @definition end |
#execute_and_generate_message(args) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/llm/functions/make_new_file.rb', line 32 def (args) dirname = File.dirname(args[:filepath]) unless File.directory?(dirname) FileUtils.mkdir_p(dirname) end File.write(args[:filepath], args[:file_contents]) { result: "success" } end |
#function_name ⇒ Object
4 5 6 |
# File 'lib/llm/functions/make_new_file.rb', line 4 def function_name :make_new_file end |