Class: Ad::AgentArchitecture::Dsl::PromptDsl
- Defined in:
- lib/ad/agent_architecture/dsl/prompt_dsl.rb
Overview
This class is responsible for defining the prompts of a workflow
Instance Attribute Summary collapse
-
#current_prompt ⇒ Object
readonly
Returns the value of attribute current_prompt.
Attributes inherited from ChildDsl
Instance Method Summary collapse
- #content(content) ⇒ Object
- #description(description) ⇒ Object
- #load_file(file) ⇒ Object
- #prompt(name, path: nil, content: nil, description: nil, &block) ⇒ Object
Methods inherited from ChildDsl
Methods included from DataAccessors
#attributes, #get_attribute, #get_prompt, #get_setting, #prompt_content, #prompts, #sections, #setting_value, #settings
Constructor Details
This class inherits a constructor from Ad::AgentArchitecture::Dsl::ChildDsl
Instance Attribute Details
#current_prompt ⇒ Object (readonly)
Returns the value of attribute current_prompt.
8 9 10 |
# File 'lib/ad/agent_architecture/dsl/prompt_dsl.rb', line 8 def current_prompt @current_prompt end |
Instance Method Details
#content(content) ⇒ Object
28 29 30 31 32 |
# File 'lib/ad/agent_architecture/dsl/prompt_dsl.rb', line 28 def content(content) current_prompt[:content] = content self end |
#description(description) ⇒ Object
22 23 24 25 26 |
# File 'lib/ad/agent_architecture/dsl/prompt_dsl.rb', line 22 def description(description) current_prompt[:description] = description self end |
#load_file(file) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/ad/agent_architecture/dsl/prompt_dsl.rb', line 34 def load_file(file) prompt_path = settings[:prompt_path] raise 'Prompt path not defined in settings. Set "prompt_path" to the path where you are keping prompts' unless prompt_path full_path = File.join(prompt_path[:value], file) File.read(full_path) end |
#prompt(name, path: nil, content: nil, description: nil, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ad/agent_architecture/dsl/prompt_dsl.rb', line 10 def prompt(name, path: nil, content: nil, description: nil, &block) raise ArgumentError, 'Prompt name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol) @current_prompt = { name: name, path: path, content: content, description: description } prompts[name] = current_prompt instance_eval(&block) if block_given? self end |