feat: Enhance Kol Generation Service with web search and knowledge group support

- Added `EnableWebSearch` and `KnowledgeGroupIDs` fields to `KolGenerationSubmitRequest`.
- Updated `Submit` method in `KolGenerationService` to handle new request fields.
- Integrated web search and knowledge group validation based on card configuration.
- Introduced caching mechanisms in `KolPackageService`, `KolPromptService`, and `KolSubscriptionAdminService` to improve performance.
- Implemented knowledge context resolution in `KolGenerationWorker` to enrich prompts with relevant knowledge snippets.
- Added utility functions for handling card configuration in both backend and frontend.
- Created tests for knowledge extraction and rendering to ensure accuracy and reliability.
This commit is contained in:
2026-04-18 13:47:32 +08:00
parent 3ef0807456
commit b2605abd6a
27 changed files with 2051 additions and 171 deletions
@@ -224,3 +224,35 @@ func invalidateArticleCaches(ctx context.Context, c sharedcache.Cache, tenantID
func InvalidateArticleCaches(ctx context.Context, c sharedcache.Cache, tenantID int64, articleID *int64) {
invalidateArticleCaches(ctx, c, tenantID, articleID)
}
func kolPromptDetailCachePrefix(tenantID int64) string {
return fmt.Sprintf("kol:prompt:detail:%d:", tenantID)
}
func kolPromptListCachePrefix(tenantID int64) string {
return fmt.Sprintf("kol:prompt:list:%d:", tenantID)
}
func kolSubscriptionPromptListCachePrefix(tenantID int64) string {
return fmt.Sprintf("kol:subscription_prompt:list:%d:", tenantID)
}
func kolSubscriptionPromptSchemaCachePrefix(tenantID int64) string {
return fmt.Sprintf("kol:subscription_prompt:schema:%d:", tenantID)
}
func invalidateKolPromptCaches(ctx context.Context, c sharedcache.Cache, tenantID int64) {
deleteCachePrefix(ctx, c, kolPromptDetailCachePrefix(tenantID))
deleteCachePrefix(ctx, c, kolPromptListCachePrefix(tenantID))
deleteCachePrefix(ctx, c, kolSubscriptionPromptListCachePrefix(tenantID))
deleteCachePrefix(ctx, c, kolSubscriptionPromptSchemaCachePrefix(tenantID))
deleteCacheKey(ctx, c, workspaceKolCardsCacheKey(tenantID))
}
func InvalidateKolPromptCaches(ctx context.Context, c sharedcache.Cache) {
deleteCachePrefix(ctx, c, "kol:prompt:detail:")
deleteCachePrefix(ctx, c, "kol:prompt:list:")
deleteCachePrefix(ctx, c, "kol:subscription_prompt:list:")
deleteCachePrefix(ctx, c, "kol:subscription_prompt:schema:")
deleteCachePrefix(ctx, c, "workspace:kol_cards:")
}