kimaai_embedding_pdf_max_bytes

When it fires

In a sync of the knowledge base, for each PDF, before its file is read. A PDF larger than the limit is not read: the sync records the error “PDF is larger than the limit” for it and goes on with the next post.

The whole file is read and parsed in PHP’s memory, so the limit protects the sync from running out of memory. Before you raise it, make sure PHP’s memory_limit leaves room for a file several times that size; a sync that runs out of memory stops for every post after it.

Parameters

NameTypeDescription
max_bytesintThe limit, 20 MB (20971520 bytes) by default.
attachmentWP_PostThe PDF’s attachment post.

Returns

int: The limit in bytes.

Example

add_filter(
  'kimaai_embedding_pdf_max_bytes',
  function (int $max_bytes): int {
    // The product manuals are up to 50 MB; the server has the memory for them.
    return 50 * 1024 * 1024;
  }
);
  • kimaai_embedding_pdf_extracted_text: changes the text read from a PDF.
  • kimaai_embedding_supported_sources: the sources a sync can index, PDFs among them.

What are your feelings