gemini

package
v0.0.0-...-ae3df83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDailyLimitReached, ErrMinuteLimitReached error

Functions

This section is empty.

Types

type BlockedError

type BlockedError struct {
	Feedback *genai.GenerateContentResponsePromptFeedback
}

func (*BlockedError) Error

func (b *BlockedError) Error() string

Implement error interface

type GeminiLimiter

type GeminiLimiter struct {
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter(cfg *config.Config, rdb *rdb.Service) (*GeminiLimiter, error)

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.

func (*GeminiLimiter) Exhausted

func (gl *GeminiLimiter) Exhausted(ctx context.Context) bool

Exhausted returns true if the daily limit has already been hit.

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

func (s *Service) 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.

func (*Service) Exhausted

func (s *Service) Exhausted(ctx context.Context) bool

Exhausted returns true if the daily limit has already been hit

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

func (s *Service) MakeTextContents(video *models.Post) []*genai.Content

MakeTextContents creates Genai contents containing just text

func (*Service) MakeVideoContents

func (s *Service) MakeVideoContents(video *models.Post) ([]*genai.Content, error)

MakeVideoContents creates Genai contents containing video file/URL https://ai.google.dev/gemini-api/docs/video-understanding#clipping-intervals

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL