TUI: Enter on the Models screen chats with the model; answers start under the model's name
Models: Enter opens the Chat screen with the selected model, under its declared name when there is one (so the config's defaults and locks apply), else its Hugging Face id; embedding models are refused. A model chosen there stays current when the server's list arrives. Chat: the model's name has a line of its own and the answer follows at the full width, instead of being indented by a long repository id. Docs EN+FR updated (reference, how-to, tutorial). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2c18fab parent: 802366e modified
Sources/RazorbillTUI/ChatRenderer.swift +5 -4 | @@ -57,18 +57,19 @@ public struct ChatRenderer: Sendable { | ||
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | + /// The model's name on a line of its own, then the answer at the full width: a long | |
| 61 | + /// repository id would otherwise push every line of the answer to the right. | |
| 60 | 62 | func answer( |
| 61 | 63 | _ entry: ChatEntry, display: ChatScreen.ReasoningDisplay, streaming: Bool, width: Int |
| 62 | 64 | ) -> [String] { |
| 63 | - let name = "\(entry.model ?? "model") › " | |
| 64 | - var lines: [String] = [] | |
| 65 | + var lines = [style.bold(TextLayout.truncate(entry.model ?? "model", width: width))] | |
| 65 | 66 | if !entry.reasoning.isEmpty { |
| 66 | 67 | lines += reasoning(entry.reasoning, display: display, width: width) |
| 67 | 68 | } else if streaming && entry.content.isEmpty { |
| 68 | 69 | lines.append(style.dim(" ⋯ waiting for the model…")) |
| 69 | 70 | } |
| 70 | - if !entry.content.isEmpty || !streaming { | |
| 71 | - lines += labelled(style.bold(name), plainLabel: name, entry.content, width: width) | |
| 71 | + if !entry.content.isEmpty { | |
| 72 | + lines += TextLayout.wrap(entry.content, width: width) | |
| 72 | 73 | } |
| 73 | 74 | if entry.stopped { lines.append(style.dim(" (stopped)")) } |
| 74 | 75 | if let failure = entry.failure { |
| @@ -57,18 +57,19 @@ public struct ChatRenderer: Sendable { | |||
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | + /// The model's name on a line of its own, then the answer at the full width: a long | ||
| 61 | + /// repository id would otherwise push every line of the answer to the right. | ||
| 60 | func answer( | 62 | func answer( |
| 61 | _ entry: ChatEntry, display: ChatScreen.ReasoningDisplay, streaming: Bool, width: Int | 63 | _ entry: ChatEntry, display: ChatScreen.ReasoningDisplay, streaming: Bool, width: Int |
| 62 | ) -> [String] { | 64 | ) -> [String] { |
| 63 | - let name = "\(entry.model ?? "model") › " | 65 | + var lines = [style.bold(TextLayout.truncate(entry.model ?? "model", width: width))] |
| 64 | - var lines: [String] = [] | ||
| 65 | if !entry.reasoning.isEmpty { | 66 | if !entry.reasoning.isEmpty { |
| 66 | lines += reasoning(entry.reasoning, display: display, width: width) | 67 | lines += reasoning(entry.reasoning, display: display, width: width) |
| 67 | } else if streaming && entry.content.isEmpty { | 68 | } else if streaming && entry.content.isEmpty { |
| 68 | lines.append(style.dim(" ⋯ waiting for the model…")) | 69 | lines.append(style.dim(" ⋯ waiting for the model…")) |
| 69 | } | 70 | } |
| 70 | - if !entry.content.isEmpty || !streaming { | 71 | + if !entry.content.isEmpty { |
| 71 | - lines += labelled(style.bold(name), plainLabel: name, entry.content, width: width) | 72 | + lines += TextLayout.wrap(entry.content, width: width) |
| 72 | } | 73 | } |
| 73 | if entry.stopped { lines.append(style.dim(" (stopped)")) } | 74 | if entry.stopped { lines.append(style.dim(" (stopped)")) } |
| 74 | if let failure = entry.failure { | 75 | if let failure = entry.failure { |
modified
Sources/RazorbillTUI/ChatScreen.swift +16 -1 | @@ -68,6 +68,8 @@ public struct ChatScreen: Sendable, Equatable { | ||
| 68 | 68 | public private(set) var input = TextField() |
| 69 | 69 | /// The model the next message goes to. |
| 70 | 70 | public private(set) var model: String? |
| 71 | + /// `model` was chosen explicitly, not picked as the default. | |
| 72 | + private var chosen = false | |
| 71 | 73 | /// The chat models the server offers. |
| 72 | 74 | public private(set) var models: [String] = [] |
| 73 | 75 | /// The model list is open (Ctrl-P). |
| @@ -93,10 +95,12 @@ public struct ChatScreen: Sendable, Equatable { | ||
| 93 | 95 | |
| 94 | 96 | public init() {} |
| 95 | 97 | |
| 96 | - /// The server's chat models. The first loaded one becomes current when none is chosen. | |
| 98 | + /// The server's chat models. The first loaded one becomes current when none is chosen; a | |
| 99 | + /// model chosen from the Models screen stays current even if the list does not name it. | |
| 97 | 100 | public mutating func setModels(_ served: [ServedModel]) { |
| 98 | 101 | let chatModels = served.filter { ($0.kind ?? "chat") == "chat" } |
| 99 | 102 | models = chatModels.map(\.id) |
| 103 | + if let model, chosen, !models.contains(model) { models.append(model) } | |
| 100 | 104 | if model == nil || !models.contains(model ?? "") { |
| 101 | 105 | model = chatModels.first { $0.loaded == true }?.id ?? models.first |
| 102 | 106 | } |
| @@ -117,6 +121,16 @@ public struct ChatScreen: Sendable, Equatable { | ||
| 117 | 121 | options = ChatOptions(preferences.chat) |
| 118 | 122 | } |
| 119 | 123 | |
| 124 | + /// Makes `name` the current model (from the Models screen's Enter). | |
| 125 | + public mutating func choose(_ name: String) { | |
| 126 | + model = name | |
| 127 | + chosen = true | |
| 128 | + if !models.contains(name) { models.append(name) } | |
| 129 | + picker.resize(to: models.count) | |
| 130 | + if let index = models.firstIndex(of: name) { picker.select(index) } | |
| 131 | + note("model: \(name)") | |
| 132 | + } | |
| 133 | + | |
| 120 | 134 | // MARK: Keys |
| 121 | 135 | |
| 122 | 136 | public mutating func handle(_ key: Key) -> Action { |
| @@ -152,6 +166,7 @@ public struct ChatScreen: Sendable, Equatable { | ||
| 152 | 166 | picking = false |
| 153 | 167 | if picker.selected < models.count { |
| 154 | 168 | model = models[picker.selected] |
| 169 | + chosen = true | |
| 155 | 170 | note("model: \(models[picker.selected])") |
| 156 | 171 | } |
| 157 | 172 | default: |
| @@ -68,6 +68,8 @@ public struct ChatScreen: Sendable, Equatable { | |||
| 68 | public private(set) var input = TextField() | 68 | public private(set) var input = TextField() |
| 69 | /// The model the next message goes to. | 69 | /// The model the next message goes to. |
| 70 | public private(set) var model: String? | 70 | public private(set) var model: String? |
| 71 | + /// `model` was chosen explicitly, not picked as the default. | ||
| 72 | + private var chosen = false | ||
| 71 | /// The chat models the server offers. | 73 | /// The chat models the server offers. |
| 72 | public private(set) var models: [String] = [] | 74 | public private(set) var models: [String] = [] |
| 73 | /// The model list is open (Ctrl-P). | 75 | /// The model list is open (Ctrl-P). |
| @@ -93,10 +95,12 @@ public struct ChatScreen: Sendable, Equatable { | |||
| 93 | 95 | ||
| 94 | public init() {} | 96 | public init() {} |
| 95 | 97 | ||
| 96 | - /// The server's chat models. The first loaded one becomes current when none is chosen. | 98 | + /// The server's chat models. The first loaded one becomes current when none is chosen; a |
| 99 | + /// model chosen from the Models screen stays current even if the list does not name it. | ||
| 97 | public mutating func setModels(_ served: [ServedModel]) { | 100 | public mutating func setModels(_ served: [ServedModel]) { |
| 98 | let chatModels = served.filter { ($0.kind ?? "chat") == "chat" } | 101 | let chatModels = served.filter { ($0.kind ?? "chat") == "chat" } |
| 99 | models = chatModels.map(\.id) | 102 | models = chatModels.map(\.id) |
| 103 | + if let model, chosen, !models.contains(model) { models.append(model) } | ||
| 100 | if model == nil || !models.contains(model ?? "") { | 104 | if model == nil || !models.contains(model ?? "") { |
| 101 | model = chatModels.first { $0.loaded == true }?.id ?? models.first | 105 | model = chatModels.first { $0.loaded == true }?.id ?? models.first |
| 102 | } | 106 | } |
| @@ -117,6 +121,16 @@ public struct ChatScreen: Sendable, Equatable { | |||
| 117 | options = ChatOptions(preferences.chat) | 121 | options = ChatOptions(preferences.chat) |
| 118 | } | 122 | } |
| 119 | 123 | ||
| 124 | + /// Makes `name` the current model (from the Models screen's Enter). | ||
| 125 | + public mutating func choose(_ name: String) { | ||
| 126 | + model = name | ||
| 127 | + chosen = true | ||
| 128 | + if !models.contains(name) { models.append(name) } | ||
| 129 | + picker.resize(to: models.count) | ||
| 130 | + if let index = models.firstIndex(of: name) { picker.select(index) } | ||
| 131 | + note("model: \(name)") | ||
| 132 | + } | ||
| 133 | + | ||
| 120 | // MARK: Keys | 134 | // MARK: Keys |
| 121 | 135 | ||
| 122 | public mutating func handle(_ key: Key) -> Action { | 136 | public mutating func handle(_ key: Key) -> Action { |
| @@ -152,6 +166,7 @@ public struct ChatScreen: Sendable, Equatable { | |||
| 152 | picking = false | 166 | picking = false |
| 153 | if picker.selected < models.count { | 167 | if picker.selected < models.count { |
| 154 | model = models[picker.selected] | 168 | model = models[picker.selected] |
| 169 | + chosen = true | ||
| 155 | note("model: \(models[picker.selected])") | 170 | note("model: \(models[picker.selected])") |
| 156 | } | 171 | } |
| 157 | default: | 172 | default: |
modified
Sources/RazorbillTUI/ModelsRenderer.swift +1 -1 | @@ -22,7 +22,7 @@ public struct ModelsRenderer: Sendable { | ||
| 22 | 22 | var lines = [ |
| 23 | 23 | "", |
| 24 | 24 | style.bold(" Models in the Hugging Face cache") |
| 25 | - + style.dim(" ↑↓ select · p download · d remove · r refresh"), | |
| 25 | + + style.dim(" ↑↓ select · Enter chat with it · p download · d remove · r refresh"), | |
| 26 | 26 | style.dim(" " + Self.header), |
| 27 | 27 | ] |
| 28 | 28 | let footer = footerLines(screen, memory: memory) |
| @@ -22,7 +22,7 @@ public struct ModelsRenderer: Sendable { | |||
| 22 | var lines = [ | 22 | var lines = [ |
| 23 | "", | 23 | "", |
| 24 | style.bold(" Models in the Hugging Face cache") | 24 | style.bold(" Models in the Hugging Face cache") |
| 25 | - + style.dim(" ↑↓ select · p download · d remove · r refresh"), | 25 | + + style.dim(" ↑↓ select · Enter chat with it · p download · d remove · r refresh"), |
| 26 | style.dim(" " + Self.header), | 26 | style.dim(" " + Self.header), |
| 27 | ] | 27 | ] |
| 28 | let footer = footerLines(screen, memory: memory) | 28 | let footer = footerLines(screen, memory: memory) |
modified
Sources/RazorbillTUI/ModelsScreen.swift +10 -0 | @@ -63,6 +63,8 @@ public struct ModelsScreen: Sendable, Equatable { | ||
| 63 | 63 | case refresh |
| 64 | 64 | case pull(String) |
| 65 | 65 | case remove(String) |
| 66 | + /// Open the Chat screen with this model (the name to put in `"model"`). | |
| 67 | + case chat(String) | |
| 66 | 68 | } |
| 67 | 69 | |
| 68 | 70 | public private(set) var rows: [ModelRow] = [] |
| @@ -107,6 +109,14 @@ public struct ModelsScreen: Sendable, Equatable { | ||
| 107 | 109 | return .redraw |
| 108 | 110 | case .character("r"): |
| 109 | 111 | return .refresh |
| 112 | + case .enter: | |
| 113 | + guard let selected else { return .none } | |
| 114 | + guard selected.kind != "embedding" else { | |
| 115 | + notice = "\(selected.id) is an embedding model: it cannot chat" | |
| 116 | + return .redraw | |
| 117 | + } | |
| 118 | + // The declared name, when there is one, gets the configuration's defaults and locks. | |
| 119 | + return .chat(selected.declaredAs.first ?? selected.id) | |
| 110 | 120 | default: |
| 111 | 121 | return .none |
| 112 | 122 | } |
| @@ -63,6 +63,8 @@ public struct ModelsScreen: Sendable, Equatable { | |||
| 63 | case refresh | 63 | case refresh |
| 64 | case pull(String) | 64 | case pull(String) |
| 65 | case remove(String) | 65 | case remove(String) |
| 66 | + /// Open the Chat screen with this model (the name to put in `"model"`). | ||
| 67 | + case chat(String) | ||
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | public private(set) var rows: [ModelRow] = [] | 70 | public private(set) var rows: [ModelRow] = [] |
| @@ -107,6 +109,14 @@ public struct ModelsScreen: Sendable, Equatable { | |||
| 107 | return .redraw | 109 | return .redraw |
| 108 | case .character("r"): | 110 | case .character("r"): |
| 109 | return .refresh | 111 | return .refresh |
| 112 | + case .enter: | ||
| 113 | + guard let selected else { return .none } | ||
| 114 | + guard selected.kind != "embedding" else { | ||
| 115 | + notice = "\(selected.id) is an embedding model: it cannot chat" | ||
| 116 | + return .redraw | ||
| 117 | + } | ||
| 118 | + // The declared name, when there is one, gets the configuration's defaults and locks. | ||
| 119 | + return .chat(selected.declaredAs.first ?? selected.id) | ||
| 110 | default: | 120 | default: |
| 111 | return .none | 121 | return .none |
| 112 | } | 122 | } |
modified
Sources/RazorbillTUI/TUIApp+Models.swift +4 -0 | @@ -11,6 +11,10 @@ extension TUIApp { | ||
| 11 | 11 | case .refresh: refreshModels() |
| 12 | 12 | case .pull(let id): Task { await pull(id) } |
| 13 | 13 | case .remove(let id): Task { await remove(id) } |
| 14 | + case .chat(let name): | |
| 15 | + chat.choose(name) | |
| 16 | + state.screen = .chat | |
| 17 | + if !modelsRequested { loadModels() } | |
| 14 | 18 | } |
| 15 | 19 | } |
| 16 | 20 | |
| @@ -11,6 +11,10 @@ extension TUIApp { | |||
| 11 | case .refresh: refreshModels() | 11 | case .refresh: refreshModels() |
| 12 | case .pull(let id): Task { await pull(id) } | 12 | case .pull(let id): Task { await pull(id) } |
| 13 | case .remove(let id): Task { await remove(id) } | 13 | case .remove(let id): Task { await remove(id) } |
| 14 | + case .chat(let name): | ||
| 15 | + chat.choose(name) | ||
| 16 | + state.screen = .chat | ||
| 17 | + if !modelsRequested { loadModels() } | ||
| 14 | } | 18 | } |
| 15 | } | 19 | } |
| 16 | 20 | ||
modified
Sources/RazorbillTUI/TUIApp.swift +3 -3 | @@ -31,14 +31,14 @@ public actor TUIApp { | ||
| 31 | 31 | var pollInterval: Duration |
| 32 | 32 | private let startCommand: String |
| 33 | 33 | private let now: @Sendable () -> Date |
| 34 | - private var state: AppState | |
| 34 | + var state: AppState | |
| 35 | 35 | var snapshot: StatusSnapshot? |
| 36 | 36 | private var dashboard = DashboardScreen() |
| 37 | 37 | var chat = ChatScreen() |
| 38 | 38 | var models = ModelsScreen() |
| 39 | 39 | var settings: SettingsScreen |
| 40 | 40 | private var answer: Task<Void, Never>? |
| 41 | - private var modelsRequested = false | |
| 41 | + var modelsRequested = false | |
| 42 | 42 | /// False once `run` returns: work still in flight must not draw on the restored terminal. |
| 43 | 43 | private var running = false |
| 44 | 44 | |
| @@ -145,7 +145,7 @@ public actor TUIApp { | ||
| 145 | 145 | |
| 146 | 146 | // MARK: Chat screen |
| 147 | 147 | |
| 148 | - private func loadModels() { | |
| 148 | + func loadModels() { | |
| 149 | 149 | modelsRequested = true |
| 150 | 150 | Task { await fetchModels() } |
| 151 | 151 | } |
| @@ -31,14 +31,14 @@ public actor TUIApp { | |||
| 31 | var pollInterval: Duration | 31 | var pollInterval: Duration |
| 32 | private let startCommand: String | 32 | private let startCommand: String |
| 33 | private let now: @Sendable () -> Date | 33 | private let now: @Sendable () -> Date |
| 34 | - private var state: AppState | 34 | + var state: AppState |
| 35 | var snapshot: StatusSnapshot? | 35 | var snapshot: StatusSnapshot? |
| 36 | private var dashboard = DashboardScreen() | 36 | private var dashboard = DashboardScreen() |
| 37 | var chat = ChatScreen() | 37 | var chat = ChatScreen() |
| 38 | var models = ModelsScreen() | 38 | var models = ModelsScreen() |
| 39 | var settings: SettingsScreen | 39 | var settings: SettingsScreen |
| 40 | private var answer: Task<Void, Never>? | 40 | private var answer: Task<Void, Never>? |
| 41 | - private var modelsRequested = false | 41 | + var modelsRequested = false |
| 42 | /// False once `run` returns: work still in flight must not draw on the restored terminal. | 42 | /// False once `run` returns: work still in flight must not draw on the restored terminal. |
| 43 | private var running = false | 43 | private var running = false |
| 44 | 44 | ||
| @@ -145,7 +145,7 @@ public actor TUIApp { | |||
| 145 | 145 | ||
| 146 | // MARK: Chat screen | 146 | // MARK: Chat screen |
| 147 | 147 | ||
| 148 | - private func loadModels() { | 148 | + func loadModels() { |
| 149 | modelsRequested = true | 149 | modelsRequested = true |
| 150 | Task { await fetchModels() } | 150 | Task { await fetchModels() } |
| 151 | } | 151 | } |
modified
Tests/RazorbillTUITests/DashboardAndChatTests.swift +26 -4 | @@ -215,6 +215,14 @@ let plain = Style(colors: false) | ||
| 215 | 215 | #expect(chat.turns().isEmpty) |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | + @Test func aChosenModelSurvivesTheServersList() { | |
| 219 | + var chat = ChatScreen() | |
| 220 | + chat.choose("org/picked") | |
| 221 | + chat.setModels([ServedModel(id: "qwen", loaded: true, kind: "chat")]) | |
| 222 | + #expect(chat.model == "org/picked" && chat.models == ["qwen", "org/picked"]) | |
| 223 | + #expect(chat.entries.last?.content == "model: org/picked") | |
| 224 | + } | |
| 225 | + | |
| 218 | 226 | @Test func failedAnswersAreNotResent() { |
| 219 | 227 | var chat = ChatScreen() |
| 220 | 228 | chat.setModels(["qwen"]) |
| @@ -250,12 +258,13 @@ let plain = Style(colors: false) | ||
| 250 | 258 | return chat |
| 251 | 259 | } |
| 252 | 260 | |
| 253 | - @Test func conversationWithFoldedReasoning() { | |
| 261 | + @Test func conversationWithFoldedReasoning() throws { | |
| 254 | 262 | let (lines, cursor) = renderer.render(answered(), width: 60, height: 10) |
| 255 | 263 | #expect(lines.count == 10) |
| 256 | 264 | #expect(lines.contains("you › hello")) |
| 257 | 265 | #expect(lines.contains(" ⋯ thinking (3 words) · Ctrl-R to show")) |
| 258 | - #expect(lines.contains("qwen › Hi there")) | |
| 266 | + let name = try #require(lines.firstIndex(of: "qwen")) | |
| 267 | + #expect(lines[name + 2] == "Hi there") | |
| 259 | 268 | #expect(lines[9] == "› " && cursor.row == 9 && cursor.column == 2) |
| 260 | 269 | #expect(lines[8].contains("Enter send")) |
| 261 | 270 | } |
| @@ -283,6 +292,19 @@ let plain = Style(colors: false) | ||
| 283 | 292 | #expect(lines[6].contains("Esc stop")) |
| 284 | 293 | } |
| 285 | 294 | |
| 295 | + @Test func longModelIdsDoNotShiftTheAnswer() { | |
| 296 | + var chat = ChatScreen() | |
| 297 | + chat.setModels(["mlx-community/Qwen3-4B-4bit"]) | |
| 298 | + _ = chat.handle(.character("x")) | |
| 299 | + _ = chat.handle(.enter) | |
| 300 | + chat.receive(.content(String(repeating: "word ", count: 12))) | |
| 301 | + chat.finish(generationSeconds: nil) | |
| 302 | + let lines = renderer.render(chat, width: 30, height: 12).lines | |
| 303 | + let name = lines.firstIndex(of: "mlx-community/Qwen3-4B-4bit") | |
| 304 | + #expect(name != nil) | |
| 305 | + #expect(lines[(name ?? 0) + 1].hasPrefix("word word word word word")) | |
| 306 | + } | |
| 307 | + | |
| 286 | 308 | @Test func longInputShowsItsEnd() { |
| 287 | 309 | var chat = ChatScreen() |
| 288 | 310 | for character in String(repeating: "a", count: 50) + "XYZ" { |
| @@ -319,7 +341,7 @@ let plain = Style(colors: false) | ||
| 319 | 341 | try await waitForScreen(terminal, containing: "Ctrl-P model: qwen") |
| 320 | 342 | terminal.type("hello") |
| 321 | 343 | terminal.press(.enter) |
| 322 | - try await waitForScreen(terminal, containing: "qwen › Hi!") | |
| 344 | + try await waitForScreen(terminal, containing: "qwen\nHi!") | |
| 323 | 345 | try await waitForScreen(terminal, containing: "5+2 tokens · 3 cached") |
| 324 | 346 | #expect(server.conversations == [[ChatTurn(role: "user", content: "hello")]]) |
| 325 | 347 | terminal.press(.control("q")) |
| @@ -337,7 +359,7 @@ let plain = Style(colors: false) | ||
| 337 | 359 | try await waitForScreen(terminal, containing: "Ctrl-P model: qwen") |
| 338 | 360 | terminal.type("hi") |
| 339 | 361 | terminal.press(.enter) |
| 340 | - try await waitForScreen(terminal, containing: "qwen › partial") | |
| 362 | + try await waitForScreen(terminal, containing: "qwen\npartial") | |
| 341 | 363 | terminal.press(.control("c")) |
| 342 | 364 | try await waitForScreen(terminal, containing: "(stopped)") |
| 343 | 365 | #expect(server.cancellations == 1) |
| @@ -215,6 +215,14 @@ let plain = Style(colors: false) | |||
| 215 | #expect(chat.turns().isEmpty) | 215 | #expect(chat.turns().isEmpty) |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | + @Test func aChosenModelSurvivesTheServersList() { | ||
| 219 | + var chat = ChatScreen() | ||
| 220 | + chat.choose("org/picked") | ||
| 221 | + chat.setModels([ServedModel(id: "qwen", loaded: true, kind: "chat")]) | ||
| 222 | + #expect(chat.model == "org/picked" && chat.models == ["qwen", "org/picked"]) | ||
| 223 | + #expect(chat.entries.last?.content == "model: org/picked") | ||
| 224 | + } | ||
| 225 | + | ||
| 218 | @Test func failedAnswersAreNotResent() { | 226 | @Test func failedAnswersAreNotResent() { |
| 219 | var chat = ChatScreen() | 227 | var chat = ChatScreen() |
| 220 | chat.setModels(["qwen"]) | 228 | chat.setModels(["qwen"]) |
| @@ -250,12 +258,13 @@ let plain = Style(colors: false) | |||
| 250 | return chat | 258 | return chat |
| 251 | } | 259 | } |
| 252 | 260 | ||
| 253 | - @Test func conversationWithFoldedReasoning() { | 261 | + @Test func conversationWithFoldedReasoning() throws { |
| 254 | let (lines, cursor) = renderer.render(answered(), width: 60, height: 10) | 262 | let (lines, cursor) = renderer.render(answered(), width: 60, height: 10) |
| 255 | #expect(lines.count == 10) | 263 | #expect(lines.count == 10) |
| 256 | #expect(lines.contains("you › hello")) | 264 | #expect(lines.contains("you › hello")) |
| 257 | #expect(lines.contains(" ⋯ thinking (3 words) · Ctrl-R to show")) | 265 | #expect(lines.contains(" ⋯ thinking (3 words) · Ctrl-R to show")) |
| 258 | - #expect(lines.contains("qwen › Hi there")) | 266 | + let name = try #require(lines.firstIndex(of: "qwen")) |
| 267 | + #expect(lines[name + 2] == "Hi there") | ||
| 259 | #expect(lines[9] == "› " && cursor.row == 9 && cursor.column == 2) | 268 | #expect(lines[9] == "› " && cursor.row == 9 && cursor.column == 2) |
| 260 | #expect(lines[8].contains("Enter send")) | 269 | #expect(lines[8].contains("Enter send")) |
| 261 | } | 270 | } |
| @@ -283,6 +292,19 @@ let plain = Style(colors: false) | |||
| 283 | #expect(lines[6].contains("Esc stop")) | 292 | #expect(lines[6].contains("Esc stop")) |
| 284 | } | 293 | } |
| 285 | 294 | ||
| 295 | + @Test func longModelIdsDoNotShiftTheAnswer() { | ||
| 296 | + var chat = ChatScreen() | ||
| 297 | + chat.setModels(["mlx-community/Qwen3-4B-4bit"]) | ||
| 298 | + _ = chat.handle(.character("x")) | ||
| 299 | + _ = chat.handle(.enter) | ||
| 300 | + chat.receive(.content(String(repeating: "word ", count: 12))) | ||
| 301 | + chat.finish(generationSeconds: nil) | ||
| 302 | + let lines = renderer.render(chat, width: 30, height: 12).lines | ||
| 303 | + let name = lines.firstIndex(of: "mlx-community/Qwen3-4B-4bit") | ||
| 304 | + #expect(name != nil) | ||
| 305 | + #expect(lines[(name ?? 0) + 1].hasPrefix("word word word word word")) | ||
| 306 | + } | ||
| 307 | + | ||
| 286 | @Test func longInputShowsItsEnd() { | 308 | @Test func longInputShowsItsEnd() { |
| 287 | var chat = ChatScreen() | 309 | var chat = ChatScreen() |
| 288 | for character in String(repeating: "a", count: 50) + "XYZ" { | 310 | for character in String(repeating: "a", count: 50) + "XYZ" { |
| @@ -319,7 +341,7 @@ let plain = Style(colors: false) | |||
| 319 | try await waitForScreen(terminal, containing: "Ctrl-P model: qwen") | 341 | try await waitForScreen(terminal, containing: "Ctrl-P model: qwen") |
| 320 | terminal.type("hello") | 342 | terminal.type("hello") |
| 321 | terminal.press(.enter) | 343 | terminal.press(.enter) |
| 322 | - try await waitForScreen(terminal, containing: "qwen › Hi!") | 344 | + try await waitForScreen(terminal, containing: "qwen\nHi!") |
| 323 | try await waitForScreen(terminal, containing: "5+2 tokens · 3 cached") | 345 | try await waitForScreen(terminal, containing: "5+2 tokens · 3 cached") |
| 324 | #expect(server.conversations == [[ChatTurn(role: "user", content: "hello")]]) | 346 | #expect(server.conversations == [[ChatTurn(role: "user", content: "hello")]]) |
| 325 | terminal.press(.control("q")) | 347 | terminal.press(.control("q")) |
| @@ -337,7 +359,7 @@ let plain = Style(colors: false) | |||
| 337 | try await waitForScreen(terminal, containing: "Ctrl-P model: qwen") | 359 | try await waitForScreen(terminal, containing: "Ctrl-P model: qwen") |
| 338 | terminal.type("hi") | 360 | terminal.type("hi") |
| 339 | terminal.press(.enter) | 361 | terminal.press(.enter) |
| 340 | - try await waitForScreen(terminal, containing: "qwen › partial") | 362 | + try await waitForScreen(terminal, containing: "qwen\npartial") |
| 341 | terminal.press(.control("c")) | 363 | terminal.press(.control("c")) |
| 342 | try await waitForScreen(terminal, containing: "(stopped)") | 364 | try await waitForScreen(terminal, containing: "(stopped)") |
| 343 | #expect(server.cancellations == 1) | 365 | #expect(server.cancellations == 1) |
modified
Tests/RazorbillTUITests/ModelsAndSettingsTests.swift +37 -0 | @@ -84,6 +84,24 @@ func stored(_ id: String, size: Int64 = 1 << 30, loadable: Bool = true) -> Store | ||
| 84 | 84 | #expect(empty.handle(.character("d")) == .none) |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | + @Test func enterChatsWithTheDeclaredNameElseTheId() { | |
| 88 | + let config = ServerConfig(models: [ | |
| 89 | + ModelEntry(id: "q", source: .huggingFace(id: "org/a", revision: "main")), | |
| 90 | + ModelEntry( | |
| 91 | + id: "e", source: .huggingFace(id: "org/e", revision: "main"), kind: .embedding), | |
| 92 | + ]) | |
| 93 | + var screen = ModelsScreen() | |
| 94 | + screen.setRows( | |
| 95 | + ModelRow.rows( | |
| 96 | + [stored("org/a"), stored("org/b"), stored("org/e")], status: nil, config: config)) | |
| 97 | + #expect(screen.handle(.enter) == .chat("q")) | |
| 98 | + _ = screen.handle(.arrowDown) | |
| 99 | + #expect(screen.handle(.enter) == .chat("org/b")) | |
| 100 | + _ = screen.handle(.arrowDown) | |
| 101 | + #expect(screen.handle(.enter) == .redraw) | |
| 102 | + #expect(screen.notice == "org/e is an embedding model: it cannot chat") | |
| 103 | + } | |
| 104 | + | |
| 87 | 105 | @Test func rendersColumnsDownloadsHintAndPrompt() { |
| 88 | 106 | var screen = screen(["org/big"]) |
| 89 | 107 | screen.downloads["org/new"] = 0.42 |
| @@ -211,6 +229,25 @@ func stored(_ id: String, size: Int64 = 1 << 30, loadable: Bool = true) -> Store | ||
| 211 | 229 | await running.value |
| 212 | 230 | } |
| 213 | 231 | |
| 232 | + @Test func enterOnAModelOpensTheChatWithIt() async throws { | |
| 233 | + let terminal = FakeTerminal(rows: 24, columns: 120) | |
| 234 | + let environment = testEnvironment() | |
| 235 | + try cache("org/other", size: 1024, in: environment.store) | |
| 236 | + let server = ScriptedServer(.success(snapshot())) | |
| 237 | + let app = app(terminal, server, environment) | |
| 238 | + let running = Task { await app.run() } | |
| 239 | + terminal.press(.function(3)) | |
| 240 | + try await waitForScreen(terminal, containing: "org/other") | |
| 241 | + terminal.press(.enter) | |
| 242 | + try await waitForScreen(terminal, containing: "Ctrl-P model: org/other") | |
| 243 | + #expect(await app.currentState.screen == .chat) | |
| 244 | + terminal.type("hi") | |
| 245 | + terminal.press(.enter) | |
| 246 | + try await waitForScreen(terminal, containing: "org/other\nHi!") | |
| 247 | + terminal.press(.control("q")) | |
| 248 | + await running.value | |
| 249 | + } | |
| 250 | + | |
| 214 | 251 | @Test func removingALoadedModelUnloadsItFirst() async throws { |
| 215 | 252 | let terminal = FakeTerminal(rows: 24, columns: 120) |
| 216 | 253 | let environment = testEnvironment() |
| @@ -84,6 +84,24 @@ func stored(_ id: String, size: Int64 = 1 << 30, loadable: Bool = true) -> Store | |||
| 84 | #expect(empty.handle(.character("d")) == .none) | 84 | #expect(empty.handle(.character("d")) == .none) |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | + @Test func enterChatsWithTheDeclaredNameElseTheId() { | ||
| 88 | + let config = ServerConfig(models: [ | ||
| 89 | + ModelEntry(id: "q", source: .huggingFace(id: "org/a", revision: "main")), | ||
| 90 | + ModelEntry( | ||
| 91 | + id: "e", source: .huggingFace(id: "org/e", revision: "main"), kind: .embedding), | ||
| 92 | + ]) | ||
| 93 | + var screen = ModelsScreen() | ||
| 94 | + screen.setRows( | ||
| 95 | + ModelRow.rows( | ||
| 96 | + [stored("org/a"), stored("org/b"), stored("org/e")], status: nil, config: config)) | ||
| 97 | + #expect(screen.handle(.enter) == .chat("q")) | ||
| 98 | + _ = screen.handle(.arrowDown) | ||
| 99 | + #expect(screen.handle(.enter) == .chat("org/b")) | ||
| 100 | + _ = screen.handle(.arrowDown) | ||
| 101 | + #expect(screen.handle(.enter) == .redraw) | ||
| 102 | + #expect(screen.notice == "org/e is an embedding model: it cannot chat") | ||
| 103 | + } | ||
| 104 | + | ||
| 87 | @Test func rendersColumnsDownloadsHintAndPrompt() { | 105 | @Test func rendersColumnsDownloadsHintAndPrompt() { |
| 88 | var screen = screen(["org/big"]) | 106 | var screen = screen(["org/big"]) |
| 89 | screen.downloads["org/new"] = 0.42 | 107 | screen.downloads["org/new"] = 0.42 |
| @@ -211,6 +229,25 @@ func stored(_ id: String, size: Int64 = 1 << 30, loadable: Bool = true) -> Store | |||
| 211 | await running.value | 229 | await running.value |
| 212 | } | 230 | } |
| 213 | 231 | ||
| 232 | + @Test func enterOnAModelOpensTheChatWithIt() async throws { | ||
| 233 | + let terminal = FakeTerminal(rows: 24, columns: 120) | ||
| 234 | + let environment = testEnvironment() | ||
| 235 | + try cache("org/other", size: 1024, in: environment.store) | ||
| 236 | + let server = ScriptedServer(.success(snapshot())) | ||
| 237 | + let app = app(terminal, server, environment) | ||
| 238 | + let running = Task { await app.run() } | ||
| 239 | + terminal.press(.function(3)) | ||
| 240 | + try await waitForScreen(terminal, containing: "org/other") | ||
| 241 | + terminal.press(.enter) | ||
| 242 | + try await waitForScreen(terminal, containing: "Ctrl-P model: org/other") | ||
| 243 | + #expect(await app.currentState.screen == .chat) | ||
| 244 | + terminal.type("hi") | ||
| 245 | + terminal.press(.enter) | ||
| 246 | + try await waitForScreen(terminal, containing: "org/other\nHi!") | ||
| 247 | + terminal.press(.control("q")) | ||
| 248 | + await running.value | ||
| 249 | + } | ||
| 250 | + | ||
| 214 | @Test func removingALoadedModelUnloadsItFirst() async throws { | 251 | @Test func removingALoadedModelUnloadsItFirst() async throws { |
| 215 | let terminal = FakeTerminal(rows: 24, columns: 120) | 252 | let terminal = FakeTerminal(rows: 24, columns: 120) |
| 216 | let environment = testEnvironment() | 253 | let environment = testEnvironment() |
modified
Tests/RazorbillTUITests/ServerClientTests.swift +1 -1 | @@ -203,7 +203,7 @@ extension ServerClientError { | ||
| 203 | 203 | terminal.press(.enter) |
| 204 | 204 | terminal.type("ping") |
| 205 | 205 | terminal.press(.enter) |
| 206 | - try await waitForScreen(terminal, containing: "echo › echo: ping") | |
| 206 | + try await waitForScreen(terminal, containing: "echo\necho: ping") | |
| 207 | 207 | try await waitForScreen(terminal, containing: "tokens") |
| 208 | 208 | terminal.press(.control("q")) |
| 209 | 209 | await running.value |
| @@ -203,7 +203,7 @@ extension ServerClientError { | |||
| 203 | terminal.press(.enter) | 203 | terminal.press(.enter) |
| 204 | terminal.type("ping") | 204 | terminal.type("ping") |
| 205 | terminal.press(.enter) | 205 | terminal.press(.enter) |
| 206 | - try await waitForScreen(terminal, containing: "echo › echo: ping") | 206 | + try await waitForScreen(terminal, containing: "echo\necho: ping") |
| 207 | try await waitForScreen(terminal, containing: "tokens") | 207 | try await waitForScreen(terminal, containing: "tokens") |
| 208 | terminal.press(.control("q")) | 208 | terminal.press(.control("q")) |
| 209 | await running.value | 209 | await running.value |
modified
docs/en/how-to/manage-models-from-the-tui.md +4 -0 | @@ -17,6 +17,10 @@ The download is the one `rzb models pull` makes, with the same rule: only models | ||
| 17 | 17 | |
| 18 | 18 | When the server has the model loaded, it is unloaded first. If a request is using it, nothing is removed and the screen says why: try again once the Dashboard shows it idle. |
| 19 | 19 | |
| 20 | +## Chat with a model | |
| 21 | + | |
| 22 | +Select it and press `Enter`: the Chat screen opens with that model. A model the configuration declares is used under its declared name, so the configuration's defaults and locks apply. | |
| 23 | + | |
| 20 | 24 | ## Check that a model fits before loading it |
| 21 | 25 | |
| 22 | 26 | Select it: the line under the list gives its size and the server's memory in use over its limit, and says `more than is free now` when it would not fit beside the models already loaded. The server then unloads idle models to make room, or answers 503 when it cannot. |
| @@ -17,6 +17,10 @@ The download is the one `rzb models pull` makes, with the same rule: only models | |||
| 17 | 17 | ||
| 18 | When the server has the model loaded, it is unloaded first. If a request is using it, nothing is removed and the screen says why: try again once the Dashboard shows it idle. | 18 | When the server has the model loaded, it is unloaded first. If a request is using it, nothing is removed and the screen says why: try again once the Dashboard shows it idle. |
| 19 | 19 | ||
| 20 | +## Chat with a model | ||
| 21 | + | ||
| 22 | +Select it and press `Enter`: the Chat screen opens with that model. A model the configuration declares is used under its declared name, so the configuration's defaults and locks apply. | ||
| 23 | + | ||
| 20 | ## Check that a model fits before loading it | 24 | ## Check that a model fits before loading it |
| 21 | 25 | ||
| 22 | Select it: the line under the list gives its size and the server's memory in use over its limit, and says `more than is free now` when it would not fit beside the models already loaded. The server then unloads idle models to make room, or answers 503 when it cannot. | 26 | Select it: the line under the list gives its size and the server's memory in use over its limit, and says `more than is free now` when it would not fit beside the models already loaded. The server then unloads idle models to make room, or answers 503 when it cannot. |
modified
docs/en/reference/tui.md +2 -1 | @@ -52,7 +52,7 @@ The server's version, uptime and address; the engine's memory as a gauge of acti | ||
| 52 | 52 | |
| 53 | 53 | ## Chat (F1) |
| 54 | 54 | |
| 55 | -A streamed conversation with a chat model of the server. The conversation is kept by `rzb tui` and resent whole with each message; the server's prompt cache makes that cheap. The model is the first loaded chat model of `/v1/models`, else the first chat model listed. After each answer: prompt+completion tokens, cached prompt tokens, tokens per second from the first piece to the last. | |
| 55 | +A streamed conversation with a chat model of the server. Each answer starts with the model's name on a line of its own; the answer follows at the full width. The conversation is kept by `rzb tui` and resent whole with each message; the server's prompt cache makes that cheap. The model is the first loaded chat model of `/v1/models`, else the first chat model listed. After each answer: prompt+completion tokens, cached prompt tokens, tokens per second from the first piece to the last. | |
| 56 | 56 | |
| 57 | 57 | | Key | Effect | |
| 58 | 58 | | --- | --- | |
| @@ -91,6 +91,7 @@ The hint gives the selected model's size and the server's memory in use over its | ||
| 91 | 91 | | Key | Effect | |
| 92 | 92 | | --- | --- | |
| 93 | 93 | | `↑` `↓` `PgUp` `PgDn` `Home` `End` | Select a model | |
| 94 | +| `Enter` | Open the Chat screen with the selected model, under its declared name when it has one, else its Hugging Face id (embedding models are refused) | | |
| 94 | 95 | | `p` | Type a Hugging Face id (`org/name`), `Enter` downloads it with the engine of the build (progress shown), `Esc` cancels | |
| 95 | 96 | | `d`, `Delete` | Remove the selected model from the disk after `y` (any other key keeps it). A loaded model is unloaded first; while the server is using it, nothing is removed | |
| 96 | 97 | | `r` | Read the cache again | |
| @@ -52,7 +52,7 @@ The server's version, uptime and address; the engine's memory as a gauge of acti | |||
| 52 | 52 | ||
| 53 | ## Chat (F1) | 53 | ## Chat (F1) |
| 54 | 54 | ||
| 55 | -A streamed conversation with a chat model of the server. The conversation is kept by `rzb tui` and resent whole with each message; the server's prompt cache makes that cheap. The model is the first loaded chat model of `/v1/models`, else the first chat model listed. After each answer: prompt+completion tokens, cached prompt tokens, tokens per second from the first piece to the last. | 55 | +A streamed conversation with a chat model of the server. Each answer starts with the model's name on a line of its own; the answer follows at the full width. The conversation is kept by `rzb tui` and resent whole with each message; the server's prompt cache makes that cheap. The model is the first loaded chat model of `/v1/models`, else the first chat model listed. After each answer: prompt+completion tokens, cached prompt tokens, tokens per second from the first piece to the last. |
| 56 | 56 | ||
| 57 | | Key | Effect | | 57 | | Key | Effect | |
| 58 | | --- | --- | | 58 | | --- | --- | |
| @@ -91,6 +91,7 @@ The hint gives the selected model's size and the server's memory in use over its | |||
| 91 | | Key | Effect | | 91 | | Key | Effect | |
| 92 | | --- | --- | | 92 | | --- | --- | |
| 93 | | `↑` `↓` `PgUp` `PgDn` `Home` `End` | Select a model | | 93 | | `↑` `↓` `PgUp` `PgDn` `Home` `End` | Select a model | |
| 94 | +| `Enter` | Open the Chat screen with the selected model, under its declared name when it has one, else its Hugging Face id (embedding models are refused) | | ||
| 94 | | `p` | Type a Hugging Face id (`org/name`), `Enter` downloads it with the engine of the build (progress shown), `Esc` cancels | | 95 | | `p` | Type a Hugging Face id (`org/name`), `Enter` downloads it with the engine of the build (progress shown), `Esc` cancels | |
| 95 | | `d`, `Delete` | Remove the selected model from the disk after `y` (any other key keeps it). A loaded model is unloaded first; while the server is using it, nothing is removed | | 96 | | `d`, `Delete` | Remove the selected model from the disk after `y` (any other key keeps it). A loaded model is unloaded first; while the server is using it, nothing is removed | |
| 96 | | `r` | Read the cache again | | 97 | | `r` | Read the cache again | |
modified
docs/en/tutorials/chat-from-the-terminal.md +1 -1 | @@ -65,7 +65,7 @@ In the first terminal, press `F1`. The Chat screen says `Model: qwen`. Type: | ||
| 65 | 65 | Say hi in five words. |
| 66 | 66 | ``` |
| 67 | 67 | |
| 68 | -and press `Enter`. The first answer takes a few seconds while the server loads the model: you see `⋯ waiting for the model…`. Then Qwen3 thinks before answering: a line `⋯ thinking (… words) · Ctrl-R to show` appears, then the answer after `qwen ›`, then a dim line such as `23+41 tokens · 85.3 tok/s`. The exact words and numbers differ on your Mac. | |
| 68 | +and press `Enter`. The first answer takes a few seconds while the server loads the model: you see `⋯ waiting for the model…`. Then Qwen3 thinks before answering: a line `⋯ thinking (… words) · Ctrl-R to show` appears, then the answer, under the model's name `qwen`, then a dim line such as `23+41 tokens · 85.3 tok/s`. The exact words and numbers differ on your Mac. | |
| 69 | 69 | |
| 70 | 70 | We have chatted with a model on the GPU, through the server's OpenAI API. |
| 71 | 71 | |
| @@ -65,7 +65,7 @@ In the first terminal, press `F1`. The Chat screen says `Model: qwen`. Type: | |||
| 65 | Say hi in five words. | 65 | Say hi in five words. |
| 66 | ``` | 66 | ``` |
| 67 | 67 | ||
| 68 | -and press `Enter`. The first answer takes a few seconds while the server loads the model: you see `⋯ waiting for the model…`. Then Qwen3 thinks before answering: a line `⋯ thinking (… words) · Ctrl-R to show` appears, then the answer after `qwen ›`, then a dim line such as `23+41 tokens · 85.3 tok/s`. The exact words and numbers differ on your Mac. | 68 | +and press `Enter`. The first answer takes a few seconds while the server loads the model: you see `⋯ waiting for the model…`. Then Qwen3 thinks before answering: a line `⋯ thinking (… words) · Ctrl-R to show` appears, then the answer, under the model's name `qwen`, then a dim line such as `23+41 tokens · 85.3 tok/s`. The exact words and numbers differ on your Mac. |
| 69 | 69 | ||
| 70 | We have chatted with a model on the GPU, through the server's OpenAI API. | 70 | We have chatted with a model on the GPU, through the server's OpenAI API. |
| 71 | 71 | ||
modified
docs/fr/how-to/gerer-les-modeles-depuis-la-tui.md +4 -0 | @@ -17,6 +17,10 @@ Le téléchargement est celui que fait `rzb models pull`, avec la même règle : | ||
| 17 | 17 | |
| 18 | 18 | Quand le serveur a ce modèle chargé, il est d'abord déchargé. Si une requête l'utilise, rien n'est supprimé et l'écran dit pourquoi : réessaie quand le Dashboard le montre au repos. |
| 19 | 19 | |
| 20 | +## Discuter avec un modèle | |
| 21 | + | |
| 22 | +Choisis-le et appuie sur `Entrée` : l'écran Chat s'ouvre avec ce modèle. Un modèle que la configuration déclare est utilisé sous son nom déclaré, pour que les valeurs par défaut et les verrous de la configuration s'appliquent. | |
| 23 | + | |
| 20 | 24 | ## Vérifier qu'un modèle tient avant de le charger |
| 21 | 25 | |
| 22 | 26 | Choisis-le : la ligne sous la liste donne sa taille et la mémoire du serveur utilisée sur sa limite, et indique `more than is free now` quand il ne tiendrait pas à côté des modèles déjà chargés. Le serveur décharge alors les modèles au repos pour faire de la place, ou répond 503 quand il ne peut pas. |
| @@ -17,6 +17,10 @@ Le téléchargement est celui que fait `rzb models pull`, avec la même règle : | |||
| 17 | 17 | ||
| 18 | Quand le serveur a ce modèle chargé, il est d'abord déchargé. Si une requête l'utilise, rien n'est supprimé et l'écran dit pourquoi : réessaie quand le Dashboard le montre au repos. | 18 | Quand le serveur a ce modèle chargé, il est d'abord déchargé. Si une requête l'utilise, rien n'est supprimé et l'écran dit pourquoi : réessaie quand le Dashboard le montre au repos. |
| 19 | 19 | ||
| 20 | +## Discuter avec un modèle | ||
| 21 | + | ||
| 22 | +Choisis-le et appuie sur `Entrée` : l'écran Chat s'ouvre avec ce modèle. Un modèle que la configuration déclare est utilisé sous son nom déclaré, pour que les valeurs par défaut et les verrous de la configuration s'appliquent. | ||
| 23 | + | ||
| 20 | ## Vérifier qu'un modèle tient avant de le charger | 24 | ## Vérifier qu'un modèle tient avant de le charger |
| 21 | 25 | ||
| 22 | Choisis-le : la ligne sous la liste donne sa taille et la mémoire du serveur utilisée sur sa limite, et indique `more than is free now` quand il ne tiendrait pas à côté des modèles déjà chargés. Le serveur décharge alors les modèles au repos pour faire de la place, ou répond 503 quand il ne peut pas. | 26 | Choisis-le : la ligne sous la liste donne sa taille et la mémoire du serveur utilisée sur sa limite, et indique `more than is free now` quand il ne tiendrait pas à côté des modèles déjà chargés. Le serveur décharge alors les modèles au repos pour faire de la place, ou répond 503 quand il ne peut pas. |
modified
docs/fr/reference/tui.md +2 -1 | @@ -52,7 +52,7 @@ La version, la durée de fonctionnement et l'adresse du serveur ; la mémoire du | ||
| 52 | 52 | |
| 53 | 53 | ## Chat (F1) |
| 54 | 54 | |
| 55 | -Une conversation en flux avec un modèle de chat du serveur. La conversation est gardée par `rzb tui` et renvoyée entière à chaque message ; le cache de prompt du serveur rend cela peu coûteux. Le modèle est le premier modèle de chat chargé de `/v1/models`, sinon le premier modèle de chat listé. Après chaque réponse : tokens prompt+complétion, tokens du prompt repris du cache, tokens par seconde du premier morceau au dernier. | |
| 55 | +Une conversation en flux avec un modèle de chat du serveur. Chaque réponse commence par le nom du modèle sur une ligne à lui ; la réponse suit sur toute la largeur. La conversation est gardée par `rzb tui` et renvoyée entière à chaque message ; le cache de prompt du serveur rend cela peu coûteux. Le modèle est le premier modèle de chat chargé de `/v1/models`, sinon le premier modèle de chat listé. Après chaque réponse : tokens prompt+complétion, tokens du prompt repris du cache, tokens par seconde du premier morceau au dernier. | |
| 56 | 56 | |
| 57 | 57 | | Touche | Effet | |
| 58 | 58 | | --- | --- | |
| @@ -91,6 +91,7 @@ L'indication donne la taille du modèle choisi et la mémoire du serveur utilis | ||
| 91 | 91 | | Touche | Effet | |
| 92 | 92 | | --- | --- | |
| 93 | 93 | | `↑` `↓` `PgUp` `PgDn` `Home` `End` | Choisir un modèle | |
| 94 | +| `Entrée` | Ouvrir l'écran Chat avec le modèle choisi, sous son nom déclaré s'il en a un, sinon sous son id Hugging Face (les modèles d'embedding sont refusés) | | |
| 94 | 95 | | `p` | Taper un id Hugging Face (`org/nom`) ; `Entrée` le télécharge avec le moteur de la compilation (progression affichée), `Échap` annule | |
| 95 | 96 | | `d`, `Suppr` | Supprimer du disque le modèle choisi après `y` (toute autre touche le garde). Un modèle chargé est d'abord déchargé ; tant que le serveur l'utilise, rien n'est supprimé | |
| 96 | 97 | | `r` | Relire le cache | |
| @@ -52,7 +52,7 @@ La version, la durée de fonctionnement et l'adresse du serveur ; la mémoire du | |||
| 52 | 52 | ||
| 53 | ## Chat (F1) | 53 | ## Chat (F1) |
| 54 | 54 | ||
| 55 | -Une conversation en flux avec un modèle de chat du serveur. La conversation est gardée par `rzb tui` et renvoyée entière à chaque message ; le cache de prompt du serveur rend cela peu coûteux. Le modèle est le premier modèle de chat chargé de `/v1/models`, sinon le premier modèle de chat listé. Après chaque réponse : tokens prompt+complétion, tokens du prompt repris du cache, tokens par seconde du premier morceau au dernier. | 55 | +Une conversation en flux avec un modèle de chat du serveur. Chaque réponse commence par le nom du modèle sur une ligne à lui ; la réponse suit sur toute la largeur. La conversation est gardée par `rzb tui` et renvoyée entière à chaque message ; le cache de prompt du serveur rend cela peu coûteux. Le modèle est le premier modèle de chat chargé de `/v1/models`, sinon le premier modèle de chat listé. Après chaque réponse : tokens prompt+complétion, tokens du prompt repris du cache, tokens par seconde du premier morceau au dernier. |
| 56 | 56 | ||
| 57 | | Touche | Effet | | 57 | | Touche | Effet | |
| 58 | | --- | --- | | 58 | | --- | --- | |
| @@ -91,6 +91,7 @@ L'indication donne la taille du modèle choisi et la mémoire du serveur utilis | |||
| 91 | | Touche | Effet | | 91 | | Touche | Effet | |
| 92 | | --- | --- | | 92 | | --- | --- | |
| 93 | | `↑` `↓` `PgUp` `PgDn` `Home` `End` | Choisir un modèle | | 93 | | `↑` `↓` `PgUp` `PgDn` `Home` `End` | Choisir un modèle | |
| 94 | +| `Entrée` | Ouvrir l'écran Chat avec le modèle choisi, sous son nom déclaré s'il en a un, sinon sous son id Hugging Face (les modèles d'embedding sont refusés) | | ||
| 94 | | `p` | Taper un id Hugging Face (`org/nom`) ; `Entrée` le télécharge avec le moteur de la compilation (progression affichée), `Échap` annule | | 95 | | `p` | Taper un id Hugging Face (`org/nom`) ; `Entrée` le télécharge avec le moteur de la compilation (progression affichée), `Échap` annule | |
| 95 | | `d`, `Suppr` | Supprimer du disque le modèle choisi après `y` (toute autre touche le garde). Un modèle chargé est d'abord déchargé ; tant que le serveur l'utilise, rien n'est supprimé | | 96 | | `d`, `Suppr` | Supprimer du disque le modèle choisi après `y` (toute autre touche le garde). Un modèle chargé est d'abord déchargé ; tant que le serveur l'utilise, rien n'est supprimé | |
| 96 | | `r` | Relire le cache | | 97 | | `r` | Relire le cache | |
modified
docs/fr/tutorials/discuter-depuis-le-terminal.md +1 -1 | @@ -65,7 +65,7 @@ Dans le premier terminal, appuie sur `F1`. L'écran Chat indique `Model: qwen`. | ||
| 65 | 65 | Say hi in five words. |
| 66 | 66 | ``` |
| 67 | 67 | |
| 68 | -et appuie sur `Entrée`. La première réponse prend quelques secondes, le temps que le serveur charge le modèle : tu vois `⋯ waiting for the model…`. Puis Qwen3 réfléchit avant de répondre : une ligne `⋯ thinking (… words) · Ctrl-R to show` apparaît, puis la réponse après `qwen ›`, puis une ligne atténuée comme `23+41 tokens · 85.3 tok/s`. Les mots et les chiffres exacts diffèrent sur ton Mac. | |
| 68 | +et appuie sur `Entrée`. La première réponse prend quelques secondes, le temps que le serveur charge le modèle : tu vois `⋯ waiting for the model…`. Puis Qwen3 réfléchit avant de répondre : une ligne `⋯ thinking (… words) · Ctrl-R to show` apparaît, puis la réponse, sous le nom du modèle `qwen`, puis une ligne atténuée comme `23+41 tokens · 85.3 tok/s`. Les mots et les chiffres exacts diffèrent sur ton Mac. | |
| 69 | 69 | |
| 70 | 70 | Nous avons discuté avec un modèle sur le GPU, à travers l'API OpenAI du serveur. |
| 71 | 71 | |
| @@ -65,7 +65,7 @@ Dans le premier terminal, appuie sur `F1`. L'écran Chat indique `Model: qwen`. | |||
| 65 | Say hi in five words. | 65 | Say hi in five words. |
| 66 | ``` | 66 | ``` |
| 67 | 67 | ||
| 68 | -et appuie sur `Entrée`. La première réponse prend quelques secondes, le temps que le serveur charge le modèle : tu vois `⋯ waiting for the model…`. Puis Qwen3 réfléchit avant de répondre : une ligne `⋯ thinking (… words) · Ctrl-R to show` apparaît, puis la réponse après `qwen ›`, puis une ligne atténuée comme `23+41 tokens · 85.3 tok/s`. Les mots et les chiffres exacts diffèrent sur ton Mac. | 68 | +et appuie sur `Entrée`. La première réponse prend quelques secondes, le temps que le serveur charge le modèle : tu vois `⋯ waiting for the model…`. Puis Qwen3 réfléchit avant de répondre : une ligne `⋯ thinking (… words) · Ctrl-R to show` apparaît, puis la réponse, sous le nom du modèle `qwen`, puis une ligne atténuée comme `23+41 tokens · 85.3 tok/s`. Les mots et les chiffres exacts diffèrent sur ton Mac. |
| 69 | 69 | ||
| 70 | Nous avons discuté avec un modèle sur le GPU, à travers l'API OpenAI du serveur. | 70 | Nous avons discuté avec un modèle sur le GPU, à travers l'API OpenAI du serveur. |
| 71 | 71 | ||