MCPcopy
hub / github.com/mudler/LocalAI / DisplayDownloadFunction

Function DisplayDownloadFunction

pkg/utils/logging.go:17–37  ·  view source on GitHub ↗
(fileName string, current string, total string, percentage float64)

Source from the content-addressed store, hash-verified

15}
16
17func DisplayDownloadFunction(fileName string, current string, total string, percentage float64) {
18 currentTime := time.Now()
19
20 if currentTime.Sub(lastProgress) >= 5*time.Second {
21
22 lastProgress = currentTime
23
24 // calculate ETA based on percentage and elapsed time
25 var eta time.Duration
26 if percentage > 0 {
27 elapsed := currentTime.Sub(startTime)
28 eta = time.Duration(float64(elapsed)*(100/percentage) - float64(elapsed))
29 }
30
31 if total != "" {
32 xlog.Info("Downloading", "fileName", fileName, "current", current, "total", total, "percentage", percentage, "eta", eta)
33 } else {
34 xlog.Info("Downloading", "current", current)
35 }
36 }
37}

Callers 3

backendHandlerMethod · 0.92
modelHandlerMethod · 0.92
PreloadMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected