6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/glancer/workflow/ar_extractor.rb', line 6
def self.(text)
Glancer::Utils::Logger.info("Workflow::ARExtractor", "Extracting Ruby expression from LLM response...")
code = if text =~ /```(?:ruby)?\s*\n?(.*?)\s*```/mi
Glancer::Utils::Logger.debug("Workflow::ARExtractor", "Extracted from code block.")
::Regexp.last_match(1).strip
else
Glancer::Utils::Logger.debug("Workflow::ARExtractor", "No code block found, using raw text.")
text.strip
end
Glancer::Utils::Logger.debug("Workflow::ARExtractor", "Extracted expression:\n#{code}")
code
rescue StandardError => e
Glancer::Utils::Logger.error("Workflow::ARExtractor", "Extraction failed: #{e.message}")
raise Glancer::Error, "AR code extraction failed: #{e.message}"
end
|