Generate images from the composer; the picture in its own safe composable
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
+ › Generate images (when /me services.images) marks the next message, shown as a chip under
the box; it is sent with force_tool image_generate (the server's only forceable tool) on
POST /chats/{id}/messages. The tool event's `image {id, width, height}` is drawn by
GeneratedPicture: fetched only by attachment id from GET /api/v2/attachments/{id} with the
token (no URL is ever followed), at most 24 MB, decoded to a 1600 px edge, its box sized by the
server's width/height before it loads; a tap shows it whole. Markwon stays image-free.
Chosen over /v1/images/generations (models scope, which sign-in already asks): the in-chat tool
keeps the picture in the chat as the web does. A NEW chat cannot force a tool yet (POST /chats
takes no force_tool), so the option shows in an existing chat only -- server follow-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
20 files changed
+258
-4
No files matched your search
@@ -242,12 +242,14 @@ class ApiClient(val base: String, private val token: String, val http: OkHttpCli
|
||||
},
|
||||
)
|
||||
|
||||
suspend fun sendMessage(chatId: String, text: String, attachments: List<String> = emptyList()): Turn = send(
|
||||
/** A turn. [forceTool] makes the model call that tool (the server allows `image_generate` only). */
|
||||
suspend fun sendMessage(chatId: String, text: String, attachments: List<String> = emptyList(), forceTool: String? = null): Turn = send(
|
||||
"POST",
|
||||
"/chats/$chatId/messages",
|
||||
buildJsonObject {
|
||||
put("text", text)
|
||||
put("attachments", JsonArray(attachments.map { JsonPrimitive(it) }))
|
||||
forceTool?.let { put("force_tool", it) }
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ data class Me(
|
||||
|
||||
/** The instance's text-to-speech (the assistant's voice reply, Read aloud). */
|
||||
val hasTextToSpeech: Boolean get() = services["tts"] == true
|
||||
|
||||
/** The instance makes pictures for this person (`image_generate`, in a chat). */
|
||||
val hasImages: Boolean get() = services["images"] == true
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@@ -334,9 +337,19 @@ data class ToolCall(
|
||||
val children: List<ToolCall>? = null,
|
||||
/** The `show` tool's card: a file put in front of the person. Never its text. */
|
||||
val show: ShowCard? = null,
|
||||
/** `image_generate`'s picture: the server's own attachment, by id, and its size. */
|
||||
val image: GeneratedImage? = null,
|
||||
val block: ToolBlock = ToolBlock(),
|
||||
)
|
||||
|
||||
/**
|
||||
* A picture the instance made (`event["image"]`): an attachment of the chat's owner, fetched
|
||||
* with the token from `GET /api/v2/attachments/{id}` and nowhere else. Its size is known before
|
||||
* it loads, so the space it takes does not jump.
|
||||
*/
|
||||
@Serializable
|
||||
data class GeneratedImage(val id: String = "", val width: Int = 0, val height: Int = 0)
|
||||
|
||||
/**
|
||||
* What a `show` call put in front of the person (`event["show"]`, harness spec 3.0.0): the
|
||||
* file's name and where it is, never its contents -- the viewer fetches those. A file from the
|
||||
|
||||
Reference in new issue
Block a user