Crestapps core data sources

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core data sources is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for CrestApps.Core 2.0 AI data sources and search-backed RAG in any ASP.NET Core host. Covers the AIDataSource source and knowledge-base model, the SearchIndexProfile, Elasticsearch, AzureAISearch, PostgreSQL, Web and File source types, AddAIDataSources and AddCoreAIDataSourceRag, the asynchro

How to use this skill

Skill file

CrestApps.Core Data Sources

An AIDataSource connects a source (where raw documents come from) to a knowledge base (a vector index profile holding chunked, embedded rows). AI profiles and chat interactions attach a data source for preemptive RAG and the search_data_sources tool, and tool instances can expose several data sources side by side.

Pick a backend skill for the vector store: crestapps-core-elasticsearch, crestapps-core-azure-ai-search or crestapps-core-postgresql. For uploads see crestapps-core-document-processing. For the record types that fill Web and File data sources see crestapps-core-web-crawlers and crestapps-core-file-sources.

Source Types

AIDataSourceSourceTypes (namespace CrestApps.Core.AI.Models):

| Constant | Reads | Kept in step by |

|---|---|---|

| SearchIndexProfile | a CrestApps-managed source index profile | automatic, when writes go through ISearchDocumentManager |

| Elasticsearch | an external Elasticsearch index with per-data-source credentials | IAIDataSourceChangeNotifier |

| AzureAISearch | an external Azure AI Search index | IAIDataSourceChangeNotifier |

| PostgreSQL | an external PostgreSQL table | IAIDataSourceChangeNotifier |

| Web | pages from web crawler records (AddCoreWebCrawlers()) | scheduled re-crawl |

| File | typed knowledge objects from file source records (AddCoreFileSources()) | scheduled runs |

AIDataSource stores Source, AIKnowledgeBaseIndexProfileName, SourceIndexProfileName and the field mapping KeyFieldName, TitleFieldName, ContentFieldName. Web and File data sources need no field mapping because every row already carries its key, title and content. Source credentials go on AIDataSource.Properties, protected with AIDataSourceProtectionConstants.SourceSecretPurpose.

Registration

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddOpenAI()
        .AddChatInteractions(chatInteractions => chatInteractions
            .AddYesSqlStores())
        .AddToolInstances(toolInstances => toolInstances
            .AddDataSourceSearchSource()
            .AddYesSqlStores()))
    .AddIndexingServices(indexing => indexing
        .AddYesSqlStores()
        .AddPostgreSQL(
            builder.Configuration.GetSection("CrestApps:PostgreSQL"),
            postgreSQL => postgreSQL.AddAIDataSources())));

builder.Services.AddCoreAIDataSourceStoresYesSql(); // or AddCoreAIDataSourceStoresEntityCore()

Synchronization

  1. Creating, editing or deleting an AIDataSource queues a full rebuild or cleanup through AIDataSourceCatalogHandler.
  2. SearchIndexProfile sources sync automatically from ISearchDocumentHandler notifications.
  3. External and custom sources must notify the framework.
await changeNotifier.QueueDocumentsAddedOrUpdatedAsync(dataSourceId, [recordId], cancellationToken);
await changeNotifier.QueueDocumentsDeletedAsync(dataSourceId, [recordId], cancellationToken);
await changeNotifier.QueueFullSyncAsync(dataSourceId, cancellationToken);

Replace IAIDataSourceIndexingQueue for a durable or multi-node queue. Set Trace logging on CrestApps.Core.AI categories to follow queue and alignment activity.

Custom Sources

Register a keyed IAIDataSourceSourceHandler and a descriptor in AIDataSourceSourceOptions. See references/custom-source-examples.md for a complete, compiling handler and sync bridge.

builder.Services
    .AddCoreAIDataSourceRag()
    .Configure<AIDataSourceSourceOptions>(options => options.AddOrUpdate(
        "CustomCatalog",
        new LocalizedString("CustomCatalog", "Custom Catalog"),
        new LocalizedString("CustomCatalog Description", "Reads documents from the catalog service.")))
    .AddKeyedScoped<IAIDataSourceSourceHandler, CustomCatalogAIDataSourceSourceHandler>("CustomCatalog");

IAIDataSourceSourceHandler.ProducesTypedKnowledge defaults to false; only the File handler returns typed knowledge objects.

Typed Knowledge Columns

Every knowledge-base row now carries contentType (document, article, text, figure, chart, table), rootId, parentId and page. Rows from non-File sources carry contentType = "text", and every reader treats a missing value as text, so older indexes keep working.

Retrieval Settings

AIDataSourceRagMetadata on an AI profile or chat interaction: Strictness, TopNDocuments, IsInScope, Filter (OData) and ObjectTypes (for example ["figure", "chart"]). Preemptive RAG and search_data_sources read it through one shared resolver, so both apply the same filter, strictness and top N. ObjectTypes becomes part of the filter. Asking for text also admits rows with no contentType.

When a filter is set and no keyed IODataFilterTranslator exists for the knowledge base provider, both paths log a warning and search without it. The chat interaction hub validates filters with IODataValidator.

Data Source Search Tool Instances

AddDataSourceSearchSource() (source name data-source-search, category Knowledgebase) turns one data source into its own model-callable function, so several knowledge bases can be offered at once.

using CrestApps.Core.AI.Models;
using CrestApps.Core.AI.Tooling.Instances.DataSources;

instance.Put(new DataSourceSearchToolSettings
{
    DataSourceId = dataSource.ItemId,
    RetrievalMode = DataSourceRetrievalMode.Hierarchical, // default Chunk
    TopNDocuments = 5,
    Strictness = 3,
    Filter = "category eq 'support'",
    ContentTypes = ["text", "table"],
});

Figures in Answers

Retrieval over a File data source renders figures and tables in their own blocks with short labels such as [fig:1] and [tbl:1]. The model writes the label, and the chat client replaces it with the picture registered under that marker (AICompletionReference.IsImage). The address comes from IAIReferenceLinkResolver (RetrievedFigure.Link), and MCP clients read RetrievedFigure.Uri (crestapps://datasource/{dataSourceId}/figure/{canonicalId}). Register AddCoreAIDocumentReferenceDownloads() and map AddDownloadKnowledgeFigureEndpoint() so figures have a servable address. Citations that print the same line and link are merged into one.

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.