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:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"github.com/geo-platform/tenant-api/internal/shared/auditlog"
|
||||
sharedcache "github.com/geo-platform/tenant-api/internal/shared/cache"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/middleware"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/response"
|
||||
"github.com/geo-platform/tenant-api/internal/tenant/repository"
|
||||
@@ -25,6 +26,7 @@ type KolSubscriptionAdminService struct {
|
||||
marketplaceRepo repository.KolMarketplaceRepository
|
||||
subRepo repository.KolSubscriptionRepository
|
||||
promptRepo repository.KolPromptRepository
|
||||
cache sharedcache.Cache
|
||||
}
|
||||
|
||||
func NewKolSubscriptionAdminService(
|
||||
@@ -43,6 +45,11 @@ func NewKolSubscriptionAdminService(
|
||||
}
|
||||
}
|
||||
|
||||
func (s *KolSubscriptionAdminService) WithCache(c sharedcache.Cache) *KolSubscriptionAdminService {
|
||||
s.cache = c
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *KolSubscriptionAdminService) Approve(ctx context.Context, id int64, endAt *time.Time, operatorID int64) (*KolSubscriptionResponse, error) {
|
||||
tx, err := s.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
@@ -89,6 +96,7 @@ func (s *KolSubscriptionAdminService) Approve(ctx context.Context, id int64, end
|
||||
return nil, response.ErrInternal(50098, "kol_subscription_approve_commit_failed", "failed to commit subscription approval")
|
||||
}
|
||||
|
||||
InvalidateKolPromptCaches(ctx, s.cache)
|
||||
s.logAdminAction(ctx, "approve", operatorID, updated.TenantID, updated.ID, map[string]interface{}{
|
||||
"id": updated.ID,
|
||||
"tenant_id": updated.TenantID,
|
||||
@@ -157,6 +165,7 @@ func (s *KolSubscriptionAdminService) ManualBind(ctx context.Context, input Manu
|
||||
return nil, response.ErrInternal(50101, "kol_subscription_bind_commit_failed", "failed to commit manual bind")
|
||||
}
|
||||
|
||||
InvalidateKolPromptCaches(ctx, s.cache)
|
||||
s.logAdminAction(ctx, "manual_bind", operatorID, updated.TenantID, updated.ID, map[string]interface{}{
|
||||
"id": updated.ID,
|
||||
"tenant_id": updated.TenantID,
|
||||
@@ -194,6 +203,7 @@ func (s *KolSubscriptionAdminService) Revoke(ctx context.Context, id int64, oper
|
||||
return response.ErrInternal(50105, "kol_subscription_revoke_commit_failed", "failed to commit subscription revoke")
|
||||
}
|
||||
|
||||
InvalidateKolPromptCaches(ctx, s.cache)
|
||||
s.logAdminAction(ctx, "revoke", operatorID, sub.TenantID, sub.ID, map[string]interface{}{
|
||||
"id": sub.ID,
|
||||
"tenant_id": sub.TenantID,
|
||||
|
||||
Reference in New Issue
Block a user