Class: AIRefactor::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_refactor/prompt.rb

Constant Summary collapse

INPUT_FILE_PATH_MARKER =
"__{{input_file_path}}__"
OUTPUT_FILE_PATH_MARKER =
"__{{output_file_path}}__"
HEADER_MARKER =
"__{{prompt_header}}__"
"__{{prompt_footer}}__"
CONTEXT_MARKER =
"__{{context}}__"
CONTENT_MARKER =
"__{{content}}__"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options:, logger:, context: nil, input_content: nil, input_path: nil, output_file_path: nil, prompt: nil, prompt_header: nil, prompt_footer: nil) ⇒ Prompt

Returns a new instance of Prompt.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ai_refactor/prompt.rb', line 14

def initialize(options:, logger:, context: nil, input_content: nil, input_path: nil, output_file_path: nil, prompt: nil, prompt_header: nil, prompt_footer: nil)
  @input_content = input_content
  @input_file_path = input_path
  @output_file_path = output_file_path
  @logger = logger
  @header = prompt_header
  @footer = prompt_footer
  @diff = options[:diff]
  @context = context
  @prompt = prompt || raise(StandardError, "Prompt not provided")
end

Instance Attribute Details

#input_file_pathObject (readonly)

Returns the value of attribute input_file_path.



12
13
14
# File 'lib/ai_refactor/prompt.rb', line 12

def input_file_path
  @input_file_path
end

Instance Method Details

#chat_messagesObject



26
27
28
29
30
31
# File 'lib/ai_refactor/prompt.rb', line 26

def chat_messages
  [
    {role: "system", content: system_prompt},
    {role: "user", content: user_prompt}
  ]
end