بنقرة واحدة
koan-vector-migration
Vector export/import, embedding caching, provider migration
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Vector export/import, embedding caching, provider migration
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Auto-registration via KoanAutoRegistrar, minimal Program.cs, "Reference = Intent" pattern
Chat endpoints, embeddings, RAG workflows, vector search
Aggregate boundaries, relationships, lifecycle hooks, value objects
Entity<T> patterns, GUID v7 auto-generation, static methods vs manual repositories
Transparent L1/L2 caching for Entity<T>, [Cacheable] attribute, cross-node coherence, per-request opt-out
Run a mandatory pre-implementation exploration workflow before writing production code in Koan (.NET/C#). Use when a task requires code changes and Codex must first map concerns/layers, read relevant files and docs, check existing constants and types, identify the closest existing pattern, plan exact code placement, and confirm architectural guardrails.
| name | koan-vector-migration |
| description | Vector export/import, embedding caching, provider migration |
Export vectors without regenerating via AI. Cache embeddings to enable zero-cost vector database migration.
var vectorRepo = serviceProvider.GetRequiredService<IVectorSearchRepository<Media, string>>();
await foreach (var batch in vectorRepo.ExportAllAsync(batchSize: 100, ct))
{
// batch.Id: Entity identifier
// batch.Embedding: float[] vector
// batch.Metadata: Optional metadata
// Cache the embedding
var contentHash = EmbeddingCache.ComputeContentHash(embeddingText);
await cache.SetAsync(contentHash, modelId, batch.Embedding, ct);
}
1. Export vectors from Provider A → Cache
2. Switch configuration to Provider B
3. Import vectors from Cache → Provider B
Result: Zero AI API calls for migration
// Step 1: Export from Weaviate
using (EntityContext.Adapter("weaviate"))
{
var vectorRepo = sp.GetRequiredService<IVectorSearchRepository<Media, string>>();
await foreach (var batch in vectorRepo.ExportAllAsync(batchSize: 100, ct))
{
await cache.SetAsync(batch.Id, "ada-002", batch.Embedding, ct);
}
}
// Step 2: Switch to ElasticSearch in appsettings.json
{
"Koan": {
"Data": {
"Sources": {
"Vectors": {
"Adapter": "elasticsearch",
"ConnectionString": "http://localhost:9200"
}
}
}
}
}
// Step 3: Import to ElasticSearch
foreach (var mediaId in allMediaIds)
{
var embedding = await cache.GetAsync(mediaId, "ada-002", ct);
if (embedding != null)
{
var media = new Media { Id = mediaId, Embedding = embedding };
await media.Save();
}
}
docs/guides/ai-vector-howto.md