自动选择合适的单位
(size int64)
| 113 | |
| 114 | // 自动选择合适的单位 |
| 115 | func humanReadableSize(size int64) string { |
| 116 | const ( |
| 117 | KB = 1000 |
| 118 | MB = 1000 * KB |
| 119 | GB = 1000 * MB |
| 120 | ) |
| 121 | |
| 122 | switch { |
| 123 | case size >= GB: |
| 124 | return fmt.Sprintf("%.1f GB", math.Round(float64(size)/float64(GB)*10)/10) |
| 125 | case size >= MB: |
| 126 | return fmt.Sprintf("%.1f MB", math.Round(float64(size)/float64(MB)*10)/10) |
| 127 | case size >= KB: |
| 128 | return fmt.Sprintf("%.1f KB", math.Round(float64(size)/float64(KB)*10)/10) |
| 129 | default: |
| 130 | return fmt.Sprintf("%d B", size) |
| 131 | } |
| 132 | } |
| 133 | func (i *imlLocalModelController) Deploy(ctx *gin.Context) { |
| 134 | |
| 135 | var input ai_local_dto.DeployInput |