kimaai_embedding_supported_sources

When it fires

Each time KimaAI needs the list of sources: for the sources of the Sync tab and its list of posts per source, for the post types of the automatic sync setting, when a post is published, updated, unpublished or deleted (only a post of a source type is synced automatically, and only its chunks are removed then) and for the count in the diagnostics.

By default the sources are every post type that has an admin screen (show_ui) and is publicly viewable, and attachment for PDF files. A source of kind post_type needs slug, label and post_type; query_args are added to the query of its list in the Sync tab. Only published posts are synced.

Removing a source takes it out of these places, but not out of a sync without a post type (wp kimaai vectors sync without --post_type), and its chunks already indexed stay, even when their posts are unpublished later. To keep a post type out of the index and every answer, deny its posts with kimaai_content_access_tokens.

Parameters

NameTypeDescription
sourcesarraySource definitions keyed by slug, each with slug, label, post_type, kind (post_type or attachment), mime_types for attachments and optional query_args.

Returns

array: The sources.

Example

add_filter(
  'kimaai_embedding_supported_sources',
  function (array $sources): array {
    // The FAQ entries are edited inside another screen and have no admin screen of their own.
    $sources['faq'] = [
      'slug' => 'faq',
      'label' => 'FAQ',
      'post_type' => 'faq',
      'kind' => 'post_type',
    ];

    return $sources;
  }
);
  • kimaai_embedding_fetch_query_args: the query a sync fetches its posts with.
  • kimaai_embedding_source_title: the title a source shows under answers.

What are your feelings