| 1 | //! `/modeldb` command — browse the factual model reference database. |
| 2 | //! |
| 3 | //! Opens a read-only pager listing each catalog model's stated attributes: |
| 4 | //! provider + kind, the model id verbatim, context window, max output, |
| 5 | //! modality (text vs multimodal), and price. This is labels only — it never |
| 6 | //! selects, routes, or tiers a model (#3205, #2300). Attributes the catalog |
| 7 | //! does not state render as `unknown`, never guessed. |
| 8 | |
| 9 | use codewhale_command_contract::handler::{CommandCapabilities, CommandHandler}; |
| 10 | use codewhale_command_contract::metadata::{CommandInfo, RegisterCommand}; |
| 11 | use codewhale_command_contract::outcome::CommandResult; |
| 12 | |
| 13 | const COMMAND_INFO: CommandInfo = CommandInfo { |
| 14 | name: "modeldb", |
| 15 | aliases: &["model-reference", "modelref"], |
| 16 | usage: "/modeldb", |
| 17 | description_key: "cmd_model_db_description", |
| 18 | }; |
| 19 | |
| 20 | pub struct ModelDbCmd; |
| 21 | |
| 22 | impl<A> RegisterCommand<CommandResult<A>> for ModelDbCmd { |
| 23 | fn info() -> &'static CommandInfo { |
| 24 | &COMMAND_INFO |
| 25 | } |
| 26 | |
| 27 | fn handler() -> CommandHandler<CommandResult<A>> { |
| 28 | CommandHandler::Contextual { |
| 29 | capabilities: CommandCapabilities::NAVIGATION, |
| 30 | handler: |contexts, _| { |
| 31 | let Some(navigation) = contexts.into_parts().navigation else { |
| 32 | return CommandResult::error("Command capability unavailable: navigation"); |
| 33 | }; |
| 34 | navigation.open_model_reference(); |
| 35 | CommandResult::ok() |
| 36 | }, |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 |