Skip to content

Commit

Permalink
add use stored generated image lower threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
timwangmusic committed Dec 22, 2024
1 parent 666d468 commit f7f76a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion planner/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

const (
locationImagePromptTemplate = "generate an image for this location on a sunny day: %s, %s, %s"
UseGeneratedImagesThreshold = 5
)

// provision an image for the given location in the form of URL.
Expand All @@ -41,7 +42,7 @@ func (p *MyPlanner) getLocationImage(ctx *gin.Context) {

blobBucket := p.BlobBucket

if err == nil && len(photos) > 0 {
if err == nil && len(photos) >= UseGeneratedImagesThreshold {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
selected := photos[r.Intn(len(photos))]
blobKey := strings.Join([]string{locationToBlobKey(location), selected}, "/")
Expand Down

0 comments on commit f7f76a6

Please sign in to comment.