Enhance company service with AI recommendation caching and onboarding improvements
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Updated the `companyService` to include Redis caching for AI recommendations, improving performance and reducing redundant AI calls. - Introduced asynchronous AI onboarding triggered after company profile updates, enhancing user experience by offloading processing. - Added configuration for recommendation cache TTL in the `AISummarizerConfig`, allowing for flexible cache management. - Implemented methods for caching, retrieving, and invalidating AI recommendations in the `companyService`, ensuring efficient data handling. This update enhances the company's AI recommendation capabilities, providing faster responses and a more efficient onboarding process.
This commit is contained in:
@@ -3,12 +3,13 @@ package company
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"mime/multipart"
|
||||
"time"
|
||||
|
||||
"tm/internal/company_category"
|
||||
"tm/pkg/filestore"
|
||||
"tm/pkg/logger"
|
||||
"tm/pkg/redis"
|
||||
"tm/pkg/response"
|
||||
)
|
||||
|
||||
@@ -47,11 +48,13 @@ type Service interface {
|
||||
|
||||
// companyService implements the Service interface
|
||||
type companyService struct {
|
||||
repository Repository
|
||||
categoryService company_category.Service
|
||||
fileStore filestore.FileStoreService
|
||||
aiRecommendationClient AIRecommendationClient
|
||||
logger logger.Logger
|
||||
repository Repository
|
||||
categoryService company_category.Service
|
||||
fileStore filestore.FileStoreService
|
||||
aiRecommendationClient AIRecommendationClient
|
||||
redisClient redis.Client
|
||||
recommendationCacheTTL time.Duration
|
||||
logger logger.Logger
|
||||
}
|
||||
|
||||
// NewService creates a new company service
|
||||
@@ -60,13 +63,17 @@ func NewService(
|
||||
categoryService company_category.Service,
|
||||
fileStore filestore.FileStoreService,
|
||||
aiRecommendationClient AIRecommendationClient,
|
||||
redisClient redis.Client,
|
||||
recommendationCacheTTL time.Duration,
|
||||
logger logger.Logger,
|
||||
) Service {
|
||||
return &companyService{
|
||||
repository: repository,
|
||||
repository: repository,
|
||||
categoryService: categoryService,
|
||||
fileStore: fileStore,
|
||||
aiRecommendationClient: aiRecommendationClient,
|
||||
redisClient: redisClient,
|
||||
recommendationCacheTTL: recommendationCacheTTL,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
@@ -150,6 +157,8 @@ func (s *companyService) Create(ctx context.Context, form *CompanyForm) (*Compan
|
||||
"type": company.Type,
|
||||
})
|
||||
|
||||
s.triggerAIOnboardingAsync(company.GetID())
|
||||
|
||||
return company.ToResponse(nil), nil
|
||||
}
|
||||
|
||||
@@ -323,6 +332,8 @@ func (s *companyService) Update(ctx context.Context, id string, form *CompanyFor
|
||||
"name": company.Name,
|
||||
})
|
||||
|
||||
s.triggerAIOnboardingAsync(company.GetID())
|
||||
|
||||
return company.ToResponse(nil), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user