Skip to content

Commit

Permalink
fix: set generated kube lol
Browse files Browse the repository at this point in the history
  • Loading branch information
djpiper28 committed Mar 15, 2024
1 parent 769b683 commit a254410
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion kube_cache/aiStuff/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ func (ai *KubeAi) GenerateKubeRecipe(kubeName1, kubeName2 string) (string, error
ai.Lock.Unlock()
break
}

ai.Lock.Unlock()
time.Sleep(apiRestTime - time.Since(ai.LastAccess))
sleepTime := apiRestTime - time.Since(ai.LastAccess)

log.Printf("Rate limited, going to bed for %dms...", sleepTime / time.Millisecond)
time.Sleep(sleepTime)
}

res, err := ai.generateKubeRecipe(kubeName1, kubeName2)
Expand Down
9 changes: 4 additions & 5 deletions kube_cache/server/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ func (s *Server) craft(c *gin.Context, id1, id2 string) (model.KubeRecipe, error
return model.KubeRecipe{}, errors.New("Cannot generate kube recipe")
}

recipe, err = s.Database.GetKubeRecipe(id1, id2)
if err != nil {
log.Printf("Cannot get kube recipe: %s", err)
}
log.Printf("Generated new kube: %s, generating image in new thread", newKubeId)
go func() {
image, err := s.Ai.GenerateDalleForKube(newKubeId)
Expand All @@ -154,11 +158,6 @@ func (s *Server) craft(c *gin.Context, id1, id2 string) (model.KubeRecipe, error
if err != nil {
log.Printf("Cannot save kube recipe: %s", err)
}

recipe, err = s.Database.GetKubeRecipe(id1, id2)
if err != nil {
log.Printf("Cannot get kube recipe: %s", err)
}
}()

} else {
Expand Down

0 comments on commit a254410

Please sign in to comment.