Class: ActiveGenie::Extractor::Explanation
- Inherits:
-
BaseModule
- Object
- BaseModule
- ActiveGenie::Extractor::Explanation
- Defined in:
- lib/active_genie/extractor/explanation.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text, data_to_extract, config: {}) ⇒ Hash
constructor
Extracts structured data from text based on a predefined schema.
Methods inherited from BaseModule
Constructor Details
#initialize(text, data_to_extract, config: {}) ⇒ Hash
Extracts structured data from text based on a predefined schema.
28 29 30 31 32 |
# File 'lib/active_genie/extractor/explanation.rb', line 28 def initialize(text, data_to_extract, config: {}) @text = text @data_to_extract = data_to_extract super(config:) end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active_genie/extractor/explanation.rb', line 34 def call = [ { role: 'system', content: prompt }, { role: 'user', content: @text } ] properties = data_to_extract_with_explanation function = JSON.parse(File.read(File.join(__dir__, 'explanation.json')), symbolize_names: true) function[:parameters][:properties] = properties function[:parameters][:required] = properties.keys provider_response = ::ActiveGenie::Providers::UnifiedProvider.function_calling( , function, config: config ) response_formatted(provider_response) end |