Class: ActiveGenie::Extractor::Data
- Inherits:
-
BaseModule
- Object
- BaseModule
- ActiveGenie::Extractor::Data
- Defined in:
- lib/active_genie/extractor/data.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.
26 27 28 29 30 |
# File 'lib/active_genie/extractor/data.rb', line 26 def initialize(text, data_to_extract, config: {}) @text = text @data_to_extract = data_to_extract super(config:) end |
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_genie/extractor/data.rb', line 32 def call = [ { role: 'system', content: prompt }, { role: 'user', content: @text } ] function = JSON.parse(File.read(File.join(__dir__, 'data.json')), symbolize_names: true) function[:parameters][:properties] = @data_to_extract function[:parameters][:required] = @data_to_extract.keys provider_response = ::ActiveGenie::Providers::UnifiedProvider.function_calling( , function, config: config ) response_formatted(provider_response) end |