Image input: send photos to pi (ask about + file into notes) #2
Labels
No labels
epic
in-review
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
weiwen/evie#2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Let the Telegram bot accept photos and pass them to
pi, covering two use cases:picreate/update a markdown note referencing it.Key finding — no pi blocker
The note's premise ("
PiCommand::Promptonly carriesmessage: String, no multimodal path") is stale as of pi 0.80.3:promptcommand already acceptsmessage: stringplus optionalimages?: ImageContent[](dist/modes/rpc/rpc-types.d.ts).ImageContent={ type: "image", data: string /* base64 */, mimeType: string }(pi-ai/dist/types.d.ts:236).No pi tools or
@-file hack needed — images ride along as content on the existing prompt.Scope
images: Vec<ImageContent>toPiCommand::Promptinsrc/pi.rs(serdecamelCase,skip_serializing_if = "Vec::is_empty"); struct{ type: "image", data, mime_type }.msg.photo(), pick the largestPhotoSize,getFile-> download bytes -> base64. Telegramphotois always JPEG, somimeType = "image/jpeg". Use the photo caption as the message text; empty caption -> empty message, let pi decide.imagesthroughSessionManager::send_message->PiProcess::send_message.notes_dir) and include that path in the prompt. pi looks at the image viaImageContent; if the user's intent is to file it, pi uses its ownwrite/bashtools to copy the temp file into<notes_dir>/attachments/...and reference it from a note. For read-only asks pi never touches the vault. evie deletes the temp file after the turn completes (pi's promoted copy, if any, survives). (Design decision: option (b) — temp + pi-promotes.)Constraints / notes
provider/modelis text-only, pi/the provider errors. Document this; consider a startup warning.pialready hasedit/write/bashtools (evie passes no--no-tools). Intent detection stays in pi (natural language), not Rust — no new command surface. The stale "read-only" framing was removed from README/CONTEXT/DESIGN.phototype (not uncompresseddocument). Media groups / multiple images can be a follow-up.Acceptance
save this to Recipes-> pi copies the image intoattachments/and a note is created/updated linking it.Implemented image input via base64 ImageContent in pi's RPC protocol.
Changes:
ImageContentstruct (pi.rs) withjpeg()\ constructor; serialises to{type: "image", data: "", mimeType: "image/jpeg"}`.PiCommand::Promptwithimages: Vec<ImageContent>(skip_serializing_if = "Vec::is_empty"so text-only turns are unchanged).PiProcess::send_messageandSessionManager::send_message; HTTP handler passes an empty vec.msg.photo(): picks the largest PhotoSize (by pixel area), downloads bytes viateloxide::net::Download, base64-encodes them for pi, and saves atempfile::NamedTempFilethat auto-deletes when the turn completes. The caption is used as the message text; the temp path is appended so pi can copy the file into the vault for the write case.base64 = "0.22"andtempfile = "3"to Cargo.toml.Commit: d28ee2c