Module: LangExtract

Defined in:
lib/langextract.rb,
lib/langextract/io.rb,
lib/langextract/config.rb,
lib/langextract/errors.rb,
lib/langextract/factory.rb,
lib/langextract/version.rb,
lib/langextract/core/data.rb,
lib/langextract/extractor.rb,
lib/langextract/core/types.rb,
lib/langextract/core/errors.rb,
lib/langextract/core/chunking.rb,
lib/langextract/core/resolver.rb,
lib/langextract/visualization.rb,
lib/langextract/core/prompting.rb,
lib/langextract/core/tokenizer.rb,
lib/langextract/providers/base.rb,
lib/langextract/core/annotation.rb,
lib/langextract/providers/router.rb,
lib/langextract/providers/ruby_llm.rb,
lib/langextract/core/format_handler.rb,
lib/langextract/core/prompt_validation.rb

Defined Under Namespace

Modules: Core, Factory, IO, Providers Classes: Config, Extractor, ModelConfig, Visualization

Constant Summary collapse

CONFIG_MUTEX =
Mutex.new
CharInterval =
Core::CharInterval
TokenInterval =
Core::TokenInterval
Extraction =
Core::Extraction
Document =
Core::Document
AnnotatedDocument =
Core::AnnotatedDocument
ExampleData =
Core::ExampleData
AlignmentStatus =
Core::AlignmentStatus
Error =
Core::Error
InvalidModelConfigError =
Core::InvalidModelConfigError
ProviderError =
Core::ProviderError
ProviderConfigError =
Core::ProviderConfigError
ProviderAuthError =
Core::ProviderAuthError
ProviderRateLimitError =
Core::ProviderRateLimitError
ProviderTimeoutError =
Core::ProviderTimeoutError
ProviderResponseError =
Core::ProviderResponseError
FormatParsingError =
Core::FormatParsingError
PromptValidationError =
Core::PromptValidationError
AlignmentError =
Core::AlignmentError
IOFailure =
Core::IOFailure
VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.configObject



32
33
34
# File 'lib/langextract.rb', line 32

def config
  CONFIG_MUTEX.synchronize { @config ||= Config.new }
end

.configure {|config| ... } ⇒ Object

Yields:



36
37
38
# File 'lib/langextract.rb', line 36

def configure
  yield(config)
end

.extract(**kwargs) ⇒ Object



45
46
47
48
49
# File 'lib/langextract.rb', line 45

def extract(**kwargs)
  text = kwargs.delete(:text)
  documents = kwargs.delete(:documents)
  Extractor.new(**kwargs).extract(text: text, documents: documents)
end

.reset_configuration!Object



40
41
42
43
# File 'lib/langextract.rb', line 40

def reset_configuration!
  CONFIG_MUTEX.synchronize { @config = nil }
  Factory.reset_router!
end

.visualize(input) ⇒ Object



51
52
53
# File 'lib/langextract.rb', line 51

def visualize(input)
  Visualization.new.render(input)
end