Documentation
¶
Index ¶
- Variables
- type BlockedError
- type GeminiLimiter
- type Service
- func (s *Service) ConsumeQuota(ctx context.Context) error
- func (s *Service) Exhausted(ctx context.Context) bool
- func (s *Service) GenerateContent(ctx context.Context, video *models.Post, contents []*genai.Content, ...) (*models.GenaiResponse, error)
- func (s *Service) MakeTextContents(video *models.Post) []*genai.Content
- func (s *Service) MakeVideoContents(video *models.Post) ([]*genai.Content, error)
Constants ¶
This section is empty.
Variables ¶
var ErrDailyLimitReached, ErrMinuteLimitReached error
Functions ¶
This section is empty.
Types ¶
type BlockedError ¶
type BlockedError struct {
Feedback *genai.GenerateContentResponsePromptFeedback
}
type GeminiLimiter ¶
type GeminiLimiter struct {
// contains filtered or unexported fields
}
func NewLimiter ¶
NewLimiter creates new Gemini limiter
func (*GeminiLimiter) ConsumeQuota ¶
func (gl *GeminiLimiter) ConsumeQuota(ctx context.Context) error
ConsumeQuota attempts to consume 1 request from the daily and minute buckets. It returns a sentinel error if any of the quotas are full.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Gemini service
func New ¶
func New( ctx context.Context, cfg *config.Config, redisService *rdb.Service, catsRepo *categories.Repository) (*Service, error)
Create new Gemini service
func (*Service) ConsumeQuota ¶
ConsumeQuota attempts to consume 1 request from the daily and minute buckets. It returns a sentinel error if any of the quotas are full.
func (*Service) GenerateContent ¶
func (s *Service) GenerateContent( ctx context.Context, video *models.Post, contents []*genai.Content, rc *utils.RetryConfig, ) (*models.GenaiResponse, error)
GenerateContent generates content using Gemini. Retries number of times depending on the retry config passed. Unmarshals the result if any and returns a genai response object.
func (*Service) MakeTextContents ¶
MakeTextContents creates Genai contents containing just text
func (*Service) MakeVideoContents ¶
MakeVideoContents creates Genai contents containing video file/URL https://ai.google.dev/gemini-api/docs/video-understanding#clipping-intervals