| 52 | #[async_trait] |
| 53 | impl TextGenerator for Gemma3 { |
| 54 | fn add_message(&mut self, message: Message) -> Result<()> { |
| 55 | // Gemma 3 IT has no dedicated system role — the system prompt is injected into |
| 56 | // the first user turn. Small models (1B) degrade badly when a system prompt is |
| 57 | // present. Warn users so they know to pass --system-prompt "". |
| 58 | if message.role == crate::models::chat::MessageRole::System && !message.content.trim().is_empty() { |
| 59 | log::warn!( |
| 60 | "gemma3: system prompt is injected into the first user turn. \ |
| 61 | The 1B model may generate incoherent output — pass --system-prompt \"\" \ |
| 62 | for reliable results." |
| 63 | ); |
| 64 | } |
| 65 | self.history.push(message); |
| 66 | Ok(()) |
| 67 | } |
| 68 | |
| 69 | fn reset(&mut self) -> Result<()> { |
| 70 | self.history.clear(); |