Class: SublayerActionGenerator

Inherits:
Sublayer::Generators::Base show all
Defined in:
lib/sublayer/cli/commands/generators/sublayer_action_generator.rb

Instance Attribute Summary

Attributes inherited from Sublayer::Generators::Base

#results

Instance Method Summary collapse

Methods inherited from Sublayer::Generators::Base

llm_output_adapter

Constructor Details

#initialize(description:) ⇒ SublayerActionGenerator

Returns a new instance of SublayerActionGenerator.



10
11
12
# File 'lib/sublayer/cli/commands/generators/sublayer_action_generator.rb', line 10

def initialize(description:)
  @description = description
end

Instance Method Details

#generateObject



14
15
16
# File 'lib/sublayer/cli/commands/generators/sublayer_action_generator.rb', line 14

def generate
  super
end

#promptObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sublayer/cli/commands/generators/sublayer_action_generator.rb', line 18

def prompt
  <<-PROMPT
  You are an expert ruby programmer and are great at repurposing code examples to use for new situations.

  A Sublayer Action is an example of a command pattern that is used in the Sublayer AI framework to perform actions in the outside world such as manipulating files or making API calls.

  The Sublayer framework also has a component called a Generator that takes data in, sends it to an LLM and gets structured data out.
  Sublayer::Actions are used both to retrieve data for use in a generator or perform actions based on the output of the generator.
  This is used to both aid in generating new composable bits of functionality and to ease testing.

  A sublayer action is initialized with the data it needs and then exposes a `call` method which is used to perform the action.

  An example of an action being used to save a file to the file system, for example after generating the contents is:
  <example_file_manipulation_action>
  #{example_filesystem_action}
  </example_file_manipulation_action>

  An example action being used to make a call to an external api, such as OpenAI's text to speech API is:
  <example_api_call_action>
  #{example_api_action}
  </example_api_call_action>

  Your task is to generate a new Sublayer::Action::Base subclass that performs an action based on the description provided.
  <description>
  #{@description}
  </description>
  PROMPT
end