Skip to content

Commit 859099b

Browse files
authored
feat(artifact): add admin RPCs for knowledge base consolidation migration (#723)
**Because** - The KB consolidation migration (convert000070) needs to move files from legacy/duplicate KBs to the primary default KB - Files can belong to multiple KBs (many-to-many relationship via junction table) - After consolidating files, legacy KBs need to be deleted without affecting the files themselves **This commit** - Adds `AddFilesToKnowledgeBaseAdmin` RPC that accepts file resource names (`namespaces/{namespace}/files/{file}`) and adds associations to a target KB, skipping duplicates - Adds `DeleteKnowledgeBaseAdmin` RPC that force-deletes a KB even if it has file associations (files remain orphaned until re-associated) - Adds corresponding request/response message types with proper AIP annotations (`google.api.resource_reference`, `google.api.field_behavior`)
1 parent 5c8b4db commit 859099b

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

artifact/v1alpha/artifact_private_service.proto

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,18 @@ service ArtifactPrivateService {
125125

126126
// Reset knowledge base embeddings (admin only)
127127
rpc ResetKnowledgeBaseEmbeddingsAdmin(ResetKnowledgeBaseEmbeddingsAdminRequest) returns (ResetKnowledgeBaseEmbeddingsAdminResponse);
128+
129+
// Add files to knowledge base (admin only)
130+
//
131+
// Adds file associations to a target knowledge base by file UIDs.
132+
// Files can belong to multiple KBs (many-to-many relationship).
133+
// Files that already exist in the target KB are skipped (no duplicates).
134+
rpc AddFilesToKnowledgeBaseAdmin(AddFilesToKnowledgeBaseAdminRequest) returns (AddFilesToKnowledgeBaseAdminResponse);
135+
136+
// Delete knowledge base (admin only)
137+
//
138+
// Force deletes a knowledge base even if it contains files. The files remain
139+
// in the file table but lose their KB association (orphaned). Used during
140+
// KB consolidation migrations after files have been moved to another KB.
141+
rpc DeleteKnowledgeBaseAdmin(DeleteKnowledgeBaseAdminRequest) returns (DeleteKnowledgeBaseAdminResponse);
128142
}

artifact/v1alpha/knowledge_base.proto

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,46 @@ message ResetKnowledgeBaseEmbeddingsAdminResponse {
334334
// Number of files that will be re-embedded.
335335
int32 files_to_reembed = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
336336
}
337+
338+
// MoveFilesToKnowledgeBaseAdminRequest represents a request to move files from
339+
// source knowledge bases to a target knowledge base (admin only).
340+
// Adds file associations to a knowledge base (admin only).
341+
// Files can belong to multiple KBs (many-to-many relationship).
342+
message AddFilesToKnowledgeBaseAdminRequest {
343+
// The resource name of the target knowledge base to add files to.
344+
// Format: `namespaces/{namespace}/knowledge-bases/{knowledge_base}`
345+
string target_knowledge_base = 1 [
346+
(google.api.field_behavior) = REQUIRED,
347+
(google.api.resource_reference) = {type: "api.instill.tech/KnowledgeBase"}
348+
];
349+
// The resource names of files to add to the target knowledge base.
350+
// Format: `namespaces/{namespace}/files/{file}`
351+
// Files that already exist in the target KB are skipped (no duplicates).
352+
repeated string files = 2 [
353+
(google.api.field_behavior) = REQUIRED,
354+
(google.api.resource_reference) = {type: "api.instill.tech/File"}
355+
];
356+
}
357+
358+
// AddFilesToKnowledgeBaseAdminResponse represents a response for adding files.
359+
message AddFilesToKnowledgeBaseAdminResponse {
360+
// Number of files added to the target knowledge base.
361+
int32 files_added = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
362+
}
363+
364+
// DeleteKnowledgeBaseAdminRequest represents a request to delete a knowledge
365+
// base (admin only). This force deletes the KB even if it contains files.
366+
// Files are NOT deleted - they remain orphaned (no KB association).
367+
message DeleteKnowledgeBaseAdminRequest {
368+
// The resource name of the knowledge base to delete.
369+
// Format: `namespaces/{namespace}/knowledge-bases/{knowledge_base}`
370+
string name = 1 [
371+
(google.api.field_behavior) = REQUIRED,
372+
(google.api.resource_reference) = {type: "api.instill.tech/KnowledgeBase"}
373+
];
374+
}
375+
376+
// DeleteKnowledgeBaseAdminResponse represents a response for deleting a KB.
377+
message DeleteKnowledgeBaseAdminResponse {
378+
// Empty response on success.
379+
}

0 commit comments

Comments
 (0)