Class: Summarize::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/summarize/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = Summarize.configuration) ⇒ Client

Returns a new instance of Client.



11
12
13
# File 'lib/summarize/client.rb', line 11

def initialize(config = Summarize.configuration)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/summarize/client.rb', line 9

def config
  @config
end

Instance Method Details

#call(input, **opts, &block) ⇒ Object

Summarize a URL or file path.

client.call("https://example.com", length: :short, model: "openai/gpt-5-mini")
client.call("/path/to/file.pdf", language: "es")

With a block, streams chunks as they arrive:

client.call("https://example.com") { |chunk| print chunk }


24
25
26
27
28
29
30
# File 'lib/summarize/client.rb', line 24

def call(input, **opts, &block)
  if block_given?
    stream(input, **opts, &block)
  else
    run_json(input, **opts)
  end
end

#extract(input, **opts) ⇒ Object

Extract content without LLM summarization.

result = client.extract("https://example.com", format: :md)
result.content  # => extracted markdown


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

def extract(input, **opts)
  run_json(input, extract: true, **opts)
end

#from_text(text, **opts, &block) ⇒ Object

Summarize text content by writing to a temp file.

client.from_text("Long article text...", length: :medium)


36
37
38
39
40
41
42
43
44
# File 'lib/summarize/client.rb', line 36

def from_text(text, **opts, &block)
  with_temp_file(text) do |path|
    if block_given?
      stream(path, **opts, &block)
    else
      run_json(path, **opts)
    end
  end
end