File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
Applications/MLXChatExample Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ class ChatViewModel {
49
49
generateCompletionInfo? . tokensPerSecond ?? 0
50
50
}
51
51
52
+ /// Time to generate the first token in seconds
53
+ var timeToFirstToken : Double {
54
+ generateCompletionInfo? . promptTime ?? 0
55
+ }
56
+
52
57
/// Progress of the current model download, if any
53
58
var modelDownloadProgress : Progress ? {
54
59
mlxService. modelDownloadProgress
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ struct ChatToolbarView: View {
29
29
vm. clear ( [ . chat, . meta] )
30
30
} label: {
31
31
GenerationInfoView (
32
- tokensPerSecond: vm. tokensPerSecond
32
+ tokensPerSecond: vm. tokensPerSecond,
33
+ timeToFirstToken: vm. timeToFirstToken
33
34
)
34
35
}
35
36
Original file line number Diff line number Diff line change @@ -9,12 +9,23 @@ import SwiftUI
9
9
10
10
struct GenerationInfoView : View {
11
11
let tokensPerSecond : Double
12
+ let timeToFirstToken : Double
12
13
13
14
var body : some View {
14
- Text ( " \( tokensPerSecond, format: . number. precision ( . fractionLength( 2 ) ) ) tokens/s " )
15
+ HStack {
16
+ if timeToFirstToken > 0 {
17
+ Text ( String ( format: " TTFT: %.2f s " , timeToFirstToken) )
18
+ }
19
+ if tokensPerSecond > 0 {
20
+ Text ( String ( format: " TPS: %.2f " , tokensPerSecond) )
21
+ }
22
+ }
23
+ . lineLimit ( 1 )
24
+ . frame ( minWidth: 150 , alignment: . leading)
15
25
}
16
26
}
17
27
18
28
#Preview {
19
- GenerationInfoView ( tokensPerSecond: 58.5834 )
29
+ GenerationInfoView ( tokensPerSecond: 58.5834 , timeToFirstToken: 1.234 )
30
+ . padding ( )
20
31
}
You can’t perform that action at this time.
0 commit comments