Class: ContextDev::Resources::Parse

Inherits:
Object
  • Object
show all
Defined in:
lib/context_dev/resources/parse.rb,
sig/context_dev/resources/parse.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Parse

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Parse.

Parameters:



58
59
60
# File 'lib/context_dev/resources/parse.rb', line 58

def initialize(client:)
  @client = client
end

Instance Method Details

#handle(body:, client: nil, extension: nil, include_images: nil, include_links: nil, ocr: nil, pdf: nil, shorten_base64_images: nil, tags: nil, use_main_content_only: nil, zdr: nil, request_options: {}) ⇒ ContextDev::Models::ParseHandleResponse

Some parameter documentations has been truncated, see Models::ParseHandleParams for more details.

Converts raw text, source code, web/data, PDF, Microsoft Office, and image bytes into LLM-usable Markdown.

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/context_dev/resources/parse.rb', line 41

def handle(params)
  parsed, options = ContextDev::ParseHandleParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed.except(:body))
  @client.request(
    method: :post,
    path: "parse",
    query: query,
    headers: {"content-type" => "application/octet-stream"},
    body: parsed[:body],
    model: ContextDev::Models::ParseHandleResponse,
    options: options
  )
end