diff options
| author | elvis <elvis@claros.ar> | 2026-09-26 20:20:19 -0300 |
|---|---|---|
| committer | elvis <elvis@claros.ar> | 2026-09-26 20:20:19 -0300 |
| commit | 8518a63f55153e7f45fd49ad6caff5555f4e374f (patch) | |
| tree | 636684eea3fa6f35d78282ab95eb687ef49154af /crates/asist-tools/src/vision.rs | |
| parent | 69de76dc9cbedc6092d1e5ce84094a8030de1470 (diff) | |
| download | asist-p-8518a63f55153e7f45fd49ad6caff5555f4e374f.tar.gz asist-p-8518a63f55153e7f45fd49ad6caff5555f4e374f.zip | |
Translate code, comments, logs and terminal UI to English; add English README; rename scriptsHEADmain
Diffstat (limited to 'crates/asist-tools/src/vision.rs')
| -rw-r--r-- | crates/asist-tools/src/vision.rs | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/crates/asist-tools/src/vision.rs b/crates/asist-tools/src/vision.rs index 2b91ed9..5db4aee 100644 --- a/crates/asist-tools/src/vision.rs +++ b/crates/asist-tools/src/vision.rs @@ -1,13 +1,13 @@ -//! Lo que comparten mirar por la cámara y mirar la pantalla. +//! What looking through the camera and looking at the screen have in common. //! -//! Las dos herramientas hacen lo mismo en tres pasos —conseguir un JPEG, -//! preguntarle al modelo por él, devolver texto— y sólo se diferencian en de -//! dónde salen los píxeles. Eso es lo que abstrae `FrameSource`. +//! Both tools do the same three steps (get a JPEG, ask the model about it, +//! return text) and only differ in where the pixels come from. That is what +//! `FrameSource` abstracts. //! -//! Lo que **no** comparten es la resolución, y no por descuido: una escena de -//! cámara se entiende a 640 px, pero el texto de una interfaz a esa escala el -//! modelo no lo lee mal, se lo **inventa** (ver docs/RENDIMIENTO.md). Por eso -//! cada fuente trae la suya. +//! What they do **not** share is the resolution, and not by oversight: a +//! camera scene is understood at 640 px, but at that scale the model does not +//! misread UI text, it **makes it up** (see docs/RENDIMIENTO.md). That is why +//! each source brings its own. use std::sync::Arc; use std::time::Instant; @@ -17,27 +17,27 @@ use asist_core::http::Cancel; use asist_core::proc; use asist_llm::LlmClient; -/// De dónde salen los píxeles. +/// Where the pixels come from. pub trait FrameSource: Send + Sync { - /// Para los mensajes de error y el registro: «cámara», «pantalla». + /// For error messages and logs: «cámara», «pantalla». fn label(&self) -> &str; - /// Captura un fotograma en JPEG. + /// Captures one frame as JPEG. fn capture(&self) -> Result<Vec<u8>>; - /// `false` si falta el dispositivo o la herramienta de captura. + /// `false` if the device or the capture tool is missing. /// - /// Se consulta antes de registrar: declarar una herramienta que va a - /// fallar siempre es peor que no tenerla, porque el modelo la llama, se - /// come el error y gasta el turno. + /// Checked before registering: declaring a tool that will always fail is + /// worse than not having it, because the model calls it, swallows the error + /// and wastes the turn. fn available(&self) -> Result<()>; } -/// Ejecuta un programa que escribe un JPEG por la salida estándar. +/// Runs a program that writes a JPEG to standard output. /// -/// Es el mecanismo de captura de las dos fuentes: la cámara llama a ffmpeg y -/// la pantalla a un guion que sabe de compositores. Tenerlo aquí evita que -/// cada una repita el control del plazo y la comprobación de la cabecera. +/// It is the capture mechanism of both sources: the camera calls ffmpeg and +/// the screen a script that knows about compositors. Having it here keeps +/// each one from repeating the deadline control and the header check. pub fn capture_jpeg( tool: &str, program: &std::path::Path, @@ -53,7 +53,7 @@ pub fn capture_jpeg( if !output.success() || output.stdout.is_empty() { let stderr = output.stderr.to_lowercase(); - // Los dos fallos que más se dan, traducidos a algo accionable. + // The two most common failures, translated into something actionable. let hint = if stderr.contains("permission denied") { ". Comprueba los permisos del dispositivo" } else if stderr.contains("busy") { @@ -67,8 +67,8 @@ pub fn capture_jpeg( ))); } - // Cabecera JPEG. Sin esto, una captura corrupta llega hasta el modelo y - // vuelve como un error genérico que no dice dónde mirar. + // JPEG header. Without this, a corrupt capture reaches the model and + // comes back as a generic error that does not say where to look. if output.stdout.len() < 4 || output.stdout[..2] != [0xFF, 0xD8] { return Err(fail(format!( "{} no devolvió un JPEG ({} bytes)", @@ -79,7 +79,7 @@ pub fn capture_jpeg( tracing::debug!( target: "vision", - programa = %program.display(), + program = %program.display(), kb = output.stdout.len() / 1024, ms = output.took.as_millis(), "captura" @@ -87,7 +87,7 @@ pub fn capture_jpeg( Ok(output.stdout) } -/// La herramienta que ve: captura y le pregunta al modelo. +/// The tool that sees: it captures and asks the model. pub struct VisionTool { source: Box<dyn FrameSource>, llm: Arc<LlmClient>, @@ -96,10 +96,10 @@ pub struct VisionTool { parameter_hint: &'static str, default_question: &'static str, acknowledgement: &'static str, - /// Se añade a la pregunta del usuario antes de mandarla con la imagen. + /// Appended to the user's question before sending it with the image. /// - /// Hace falta porque esta petición va fuera del historial y no le llega la - /// instrucción de voz del asistente. + /// It is needed because this request goes outside the history and does not + /// get the assistant's voice prompt. style: &'static str, } @@ -135,9 +135,9 @@ impl VisionTool { en pantalla, pon: ¿Qué se ve en la pantalla?", default_question: "¿Qué se ve en esta captura de pantalla?", acknowledgement: "Miro la pantalla.", - // El aviso de no inventar es lo más importante de toda la - // instrucción: cuando el texto queda pequeño, este modelo no dice - // que no lo lee, se saca un contenido plausible de la manga. + // The warning about not making things up is the most important part of + // the whole instruction: when the text is small, this model does not say + // it cannot read it, it pulls plausible content out of thin air. style: "Responde en una o dos frases cortas en español, en texto plano. Lee sólo \ lo que de verdad pone en la imagen y no completes lo que no se distinga: \ si el texto está borroso o no se lee, dilo en vez de suponerlo.", @@ -168,8 +168,8 @@ impl asist_core::tools::Tool for VisionTool { }) } - /// Enciende la cámara o fotografía lo que haya en pantalla; en ambos casos - /// conviene que se anuncie. + /// It turns the camera on or photographs whatever is on screen; in both + /// cases it should be announced. fn is_side_effecting(&self) -> bool { true } @@ -196,7 +196,7 @@ impl asist_core::tools::Tool for VisionTool { tracing::info!( target: "vision", - fuente = self.source.label(), + source = self.source.label(), kb = frame.len() / 1024, ms = started.elapsed().as_millis(), "descrito" |