Class: Artificial::Prompt
- Inherits:
-
Object
- Object
- Artificial::Prompt
- Defined in:
- lib/artificial/prompt.rb
Instance Attribute Summary collapse
-
#assistant_prefill ⇒ Object
Returns the value of attribute assistant_prefill.
-
#citation_style ⇒ Object
Returns the value of attribute citation_style.
-
#constraints ⇒ Object
Returns the value of attribute constraints.
-
#context ⇒ Object
Returns the value of attribute context.
-
#data ⇒ Object
Returns the value of attribute data.
-
#documents ⇒ Object
Returns the value of attribute documents.
-
#examples ⇒ Object
Returns the value of attribute examples.
-
#format ⇒ Object
Returns the value of attribute format.
-
#grounding ⇒ Object
Returns the value of attribute grounding.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#optimization ⇒ Object
Returns the value of attribute optimization.
-
#output_format ⇒ Object
Returns the value of attribute output_format.
-
#retrieval ⇒ Object
Returns the value of attribute retrieval.
-
#system ⇒ Object
Returns the value of attribute system.
-
#text ⇒ Object
Returns the value of attribute text.
-
#thinking ⇒ Object
Returns the value of attribute thinking.
-
#tone ⇒ Object
Returns the value of attribute tone.
-
#tools ⇒ Object
Returns the value of attribute tools.
-
#validation ⇒ Object
Returns the value of attribute validation.
Instance Method Summary collapse
-
#initialize(input = nil, **options) ⇒ Prompt
constructor
A new instance of Prompt.
-
#to_s ⇒ Object
Generate the final prompt structure.
- #with_constraints(*constraint_list) ⇒ Object
- #with_context(**context_options) ⇒ Object
- #with_data(data_hash) ⇒ Object
- #with_documents(*document_list) ⇒ Object
- #with_examples(*example_list) ⇒ Object
- #with_grounding(require_quotes: false, require_sources: false, allow_uncertainty: false) ⇒ Object
- #with_prefill(prefill_text) ⇒ Object
-
#with_system(system_prompt) ⇒ Object
Method chaining support.
- #with_thinking(enabled: true, style: 'step_by_step', show_reasoning: true) ⇒ Object
- #with_tools(*tool_list) ⇒ Object
Constructor Details
#initialize(input = nil, **options) ⇒ Prompt
Returns a new instance of Prompt.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/artificial/prompt.rb', line 14 def initialize(input = nil, **) @format = [:format] || 'xml' @context = {} @examples = [] @constraints = [] @grounding = {} @tools = [] @documents = [] parse_input(input, ) () end |
Instance Attribute Details
#assistant_prefill ⇒ Object
Returns the value of attribute assistant_prefill.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def assistant_prefill @assistant_prefill end |
#citation_style ⇒ Object
Returns the value of attribute citation_style.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def citation_style @citation_style end |
#constraints ⇒ Object
Returns the value of attribute constraints.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def constraints @constraints end |
#context ⇒ Object
Returns the value of attribute context.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def context @context end |
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def data @data end |
#documents ⇒ Object
Returns the value of attribute documents.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def documents @documents end |
#examples ⇒ Object
Returns the value of attribute examples.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def examples @examples end |
#format ⇒ Object
Returns the value of attribute format.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def format @format end |
#grounding ⇒ Object
Returns the value of attribute grounding.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def grounding @grounding end |
#instructions ⇒ Object
Returns the value of attribute instructions.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def instructions @instructions end |
#messages ⇒ Object
Returns the value of attribute messages.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def @messages end |
#optimization ⇒ Object
Returns the value of attribute optimization.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def optimization @optimization end |
#output_format ⇒ Object
Returns the value of attribute output_format.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def output_format @output_format end |
#retrieval ⇒ Object
Returns the value of attribute retrieval.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def retrieval @retrieval end |
#system ⇒ Object
Returns the value of attribute system.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def system @system end |
#text ⇒ Object
Returns the value of attribute text.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def text @text end |
#thinking ⇒ Object
Returns the value of attribute thinking.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def thinking @thinking end |
#tone ⇒ Object
Returns the value of attribute tone.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def tone @tone end |
#tools ⇒ Object
Returns the value of attribute tools.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def tools @tools end |
#validation ⇒ Object
Returns the value of attribute validation.
9 10 11 |
# File 'lib/artificial/prompt.rb', line 9 def validation @validation end |
Instance Method Details
#to_s ⇒ Object
Generate the final prompt structure
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/artificial/prompt.rb', line 28 def to_s case @format when 'xml' generate_xml_prompt when 'string' generate_string_prompt else generate_xml_prompt end end |
#with_constraints(*constraint_list) ⇒ Object
70 71 72 73 |
# File 'lib/artificial/prompt.rb', line 70 def with_constraints(*constraint_list) @constraints.concat(constraint_list) self end |
#with_context(**context_options) ⇒ Object
46 47 48 49 |
# File 'lib/artificial/prompt.rb', line 46 def with_context(**) @context.merge!() self end |
#with_data(data_hash) ⇒ Object
80 81 82 83 |
# File 'lib/artificial/prompt.rb', line 80 def with_data(data_hash) @data = data_hash self end |
#with_documents(*document_list) ⇒ Object
85 86 87 88 |
# File 'lib/artificial/prompt.rb', line 85 def with_documents(*document_list) @documents.concat(document_list) self end |
#with_examples(*example_list) ⇒ Object
51 52 53 54 |
# File 'lib/artificial/prompt.rb', line 51 def with_examples(*example_list) @examples.concat(example_list) self end |
#with_grounding(require_quotes: false, require_sources: false, allow_uncertainty: false) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/artificial/prompt.rb', line 61 def with_grounding(require_quotes: false, require_sources: false, allow_uncertainty: false) @grounding = { require_quotes: require_quotes, require_sources: require_sources, allow_uncertainty: allow_uncertainty } self end |
#with_prefill(prefill_text) ⇒ Object
90 91 92 93 |
# File 'lib/artificial/prompt.rb', line 90 def with_prefill(prefill_text) @assistant_prefill = prefill_text self end |
#with_system(system_prompt) ⇒ Object
Method chaining support
40 41 42 43 44 |
# File 'lib/artificial/prompt.rb', line 40 def with_system(system_prompt) validate_system_prompt(system_prompt) if system_prompt @system = system_prompt self end |
#with_thinking(enabled: true, style: 'step_by_step', show_reasoning: true) ⇒ Object
56 57 58 59 |
# File 'lib/artificial/prompt.rb', line 56 def with_thinking(enabled: true, style: 'step_by_step', show_reasoning: true) @thinking = { enabled: enabled, style: style, show_reasoning: show_reasoning } self end |
#with_tools(*tool_list) ⇒ Object
75 76 77 78 |
# File 'lib/artificial/prompt.rb', line 75 def with_tools(*tool_list) @tools.concat(tool_list) self end |