Let a llama session be shown a picture where the model reads one
A multimodal model is loaded with the `mmproj` found beside its weights -- which is how a repository publishes the pair -- and an attached image rides in the request as an `image_url` data URI, so it reaches a model on another machine without the file going there. Nothing is done for a model without a projector: no captioning, no OCR, no second model. Whether a session takes pictures is measured rather than assumed: `/props`'s `modalities.vision` from the server that loaded the model, in three states, because a model still coming off disk has genuinely not said. Unknown is offered rather than refused -- a control withheld because nobody could ask goes missing from sessions that would have taken it. The answer reaches the phone twice per model as `Event::Images`, so the photo button is withdrawn the moment a model with vision is left rather than at whatever later point the session row is fetched again. A message carrying an image a model cannot read is stopped rather than stripped: `llama-server` refuses the whole request over one image part, and a message sent without its picture would be answered as though the picture had never been mentioned. The phone will not attach one, and the driver refuses it again at the three moments the answer can first exist -- at the door, when a message queued behind a loading model is read, and at the tool boundary a steer enters by. An earlier turn's image folds into a line of words for a model without vision, so switching a conversation onto one does not end it. A projector is filtered out of the models a provider *offers*, since a session started on one is a server that cannot load it; it stays in the machine's own model list, where a file on a disk is managed. Verified against ggml-org/SmolVLM-256M-Instruct-GGUF, local and over ssh: "In this picture there is a red circle." Switching that session to Qwen3-0.6B reports `refused`, refuses the next picture with the reason, and still answers an ordinary message.
This commit is contained in:
1 parent
b7fd18b195
commit
bd9596d782
17 files changed
+835
-97
No files matched your search
@@ -306,6 +306,16 @@ fun SessionScreen(
|
||||
// reads as a rename that did not take.
|
||||
var title by remember(summary.id) { mutableStateOf(summary.title) }
|
||||
var model by remember { mutableStateOf(summary.model) }
|
||||
// Whether this session takes pictures. Held here rather than read from the row that opened the
|
||||
// screen for the reason [model] is, and it moves with the model: a llama.cpp session changed
|
||||
// onto a model without vision stops offering the photo button at that moment, not at whatever
|
||||
// later point the session list is fetched again.
|
||||
var images by remember { mutableStateOf(summary.images) }
|
||||
// Pictures attached to a message this session can no longer be sent -- the model was changed
|
||||
// under them. The message is stopped here as well as at the server, which refuses it whichever
|
||||
// device sent it: a picture stripped out on the way would be answered as though it had never
|
||||
// been mentioned.
|
||||
val strandedImages = images == ImageSupport.REFUSED && pendingAttachments.any(::isImageRef)
|
||||
// The thinking level, held here for the same reason [title] is: the settings dialog can change
|
||||
// it, and the row this screen was opened from is a snapshot taken before that. Read straight
|
||||
// from the summary, a level set here was drawn as the old one again the next time the dialog
|
||||
@@ -517,6 +527,7 @@ fun SessionScreen(
|
||||
event.model?.let { model = it }
|
||||
event.permissionMode?.let { permissionMode = it }
|
||||
}
|
||||
if (event is SessionEvent.Images) images = event.images
|
||||
if (event is SessionEvent.Status) {
|
||||
// The event's own timestamp, so a compaction that began before this screen
|
||||
// opened is timed from when it actually began -- and a compaction worth asking
|
||||
@@ -853,6 +864,7 @@ fun SessionScreen(
|
||||
if (!isSubagent) {
|
||||
model = summary.model
|
||||
permissionMode = summary.permissionMode ?: "auto"
|
||||
images = summary.images
|
||||
}
|
||||
if (status != "compacting") compactingSince = null
|
||||
// Nothing to put back, so these rows are the screen and the probe can return under
|
||||
@@ -1397,7 +1409,14 @@ fun SessionScreen(
|
||||
// An image is shrunk to what this session's provider takes before it is
|
||||
// uploaded, so a twelve-megapixel photo does not cross the tunnel to be
|
||||
// rejected at the far end; a file goes whole.
|
||||
uploadPicked(context, settings, summary.id, uri, summary.maxImageEdge)
|
||||
uploadPicked(
|
||||
context,
|
||||
settings,
|
||||
summary.id,
|
||||
uri,
|
||||
summary.maxImageEdge,
|
||||
images,
|
||||
)
|
||||
}
|
||||
pendingAttachments = pendingAttachments + id
|
||||
actionError = null
|
||||
@@ -2058,6 +2077,18 @@ fun SessionScreen(
|
||||
refs = pendingAttachments,
|
||||
onRemove = { pendingAttachments = pendingAttachments - it },
|
||||
)
|
||||
// Only reachable by the model changing under something already attached, since
|
||||
// attaching is refused where the answer is already known. Said beside the
|
||||
// pictures it is about and above the button it disables, which is where
|
||||
// somebody can act on it: removing them is what makes this sendable.
|
||||
if (strandedImages) {
|
||||
Text(
|
||||
"This model can't read pictures. Remove them to send this.",
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(bottom = 4.dp),
|
||||
)
|
||||
}
|
||||
OutlinedTextField(
|
||||
value = input,
|
||||
onValueChange = {
|
||||
@@ -2091,8 +2122,23 @@ fun SessionScreen(
|
||||
properties = PopupProperties(clippingEnabled = false),
|
||||
shape = BubbleMenuShape,
|
||||
) {
|
||||
// Disabled rather than dropped: an item that comes and goes
|
||||
// makes its own absence the message, and the reason belongs on
|
||||
// the item, where somebody wondering why is looking.
|
||||
val takesPictures = images != ImageSupport.REFUSED
|
||||
DropdownMenuItem(
|
||||
text = { Text("Photo") },
|
||||
text = {
|
||||
Column {
|
||||
Text("Photo")
|
||||
if (!takesPictures) {
|
||||
Text(
|
||||
"this model can't read them",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled = takesPictures,
|
||||
onClick = {
|
||||
attaching = false
|
||||
pickImage.launch(
|
||||
@@ -2200,7 +2246,9 @@ fun SessionScreen(
|
||||
// reason above.
|
||||
CircleButton(
|
||||
onClick = { send() },
|
||||
enabled = input.text.isNotBlank() || pendingAttachments.isNotEmpty(),
|
||||
enabled =
|
||||
(input.text.isNotBlank() || pendingAttachments.isNotEmpty()) &&
|
||||
!strandedImages,
|
||||
fill = if (running) queueColor else sendColor,
|
||||
) {
|
||||
Glyph(
|
||||
|
||||
Reference in new issue
Block a user