Download crates/forge_domain/src/model.rs from SaylorTwift/forgecode: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_domain/src/model.rs
- Command line
-
hf download hf://SaylorTwift/forgecode/crates/forge_domain/src/model.rs
-
curl -L -o model.rs https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_domain/src/model.rs
2.85 kB
| use derive_more::derive::Display; | |
| use derive_setters::Setters; | |
| use fake::Dummy; | |
| use schemars::JsonSchema; | |
| use serde::{Deserialize, Serialize}; | |
| use strum_macros::EnumString; | |
| /// Represents input modalities that a model can accept | |
| pub enum InputModality { | |
| /// Text input (all models support this) | |
| Text, | |
| /// Image input (vision-capable models) | |
| Image, | |
| } | |
| /// Default input modalities when not specified (text-only) | |
| fn default_input_modalities() -> Vec<InputModality> { | |
| vec![InputModality::Text] | |
| } | |
| pub struct Model { | |
| pub id: ModelId, | |
| pub name: Option<String>, | |
| pub description: Option<String>, | |
| pub context_length: Option<u64>, | |
| // TODO: add provider information to the model | |
| pub tools_supported: Option<bool>, | |
| /// Whether the model supports parallel tool calls | |
| pub supports_parallel_tool_calls: Option<bool>, | |
| /// Whether the model supports reasoning | |
| pub supports_reasoning: Option<bool>, | |
| /// Input modalities supported by the model (defaults to text-only) | |
| pub input_modalities: Vec<InputModality>, | |
| } | |
| pub struct Parameters { | |
| pub tool_supported: bool, | |
| } | |
| impl Parameters { | |
| pub fn new(tool_supported: bool) -> Self { | |
| Self { tool_supported } | |
| } | |
| } | |
| pub struct ModelId(String); | |
| impl ModelId { | |
| pub fn new<T: Into<String>>(id: T) -> Self { | |
| Self(id.into()) | |
| } | |
| } | |
| impl Model { | |
| /// Creates a new `Model` with the given id and default values for all other | |
| /// fields. | |
| pub fn new(id: impl Into<ModelId>) -> Self { | |
| Self { | |
| id: id.into(), | |
| name: None, | |
| description: None, | |
| context_length: None, | |
| tools_supported: None, | |
| supports_parallel_tool_calls: None, | |
| supports_reasoning: None, | |
| input_modalities: default_input_modalities(), | |
| } | |
| } | |
| } | |
| impl From<String> for ModelId { | |
| fn from(value: String) -> Self { | |
| ModelId(value) | |
| } | |
| } | |
| impl From<&str> for ModelId { | |
| fn from(value: &str) -> Self { | |
| ModelId(value.to_string()) | |
| } | |
| } | |
| impl ModelId { | |
| pub fn as_str(&self) -> &str { | |
| &self.0 | |
| } | |
| } | |
| impl std::str::FromStr for ModelId { | |
| type Err = std::convert::Infallible; | |
| fn from_str(s: &str) -> Result<Self, Self::Err> { | |
| Ok(ModelId(s.to_string())) | |
| } | |
| } | |