pub struct ModelRaw {
pub name: String,
pub api_name: String,
pub can_read_images: bool,
pub api_provider: String,
pub api_url: Option<String>,
pub input_price: f64,
pub output_price: f64,
pub api_timeout: Option<u64>,
pub explanation: Option<String>,
pub api_key: Option<String>,
pub api_env_var: Option<String>,
}
Expand description
There are 2 types for models: Model
and ModelRaw
. I know it’s confusing, I’m sorry.
Model
is the type ragit internally uses and ModelRaw
is only for json serialization.
Long time ago, there was only Model
type. But then I implemented models.json
interface.
I wanted people to directly edit the json file and found that Model
isn’t intuitive to
edit directly. So I added this struct.
Fields§
§name: String
Model name shown to user.
rag config --set model
also
uses this name.
api_name: String
Model name used for api requests.
can_read_images: bool
§api_provider: String
openai | cohere | anthropic | google
If you’re using an openai-compatible
api, set this to openai
.
api_url: Option<String>
It’s necessary if you’re using an openai-compatible api. If it’s not set, ragit uses the default url of each api provider.
input_price: f64
Dollars per 1 million input tokens.
output_price: f64
Dollars per 1 million output tokens.
api_timeout: Option<u64>
The number is in seconds. If not set, it’s default to 180 seconds.
explanation: Option<String>
§api_key: Option<String>
If you don’t want to use an env var, you can hard-code your api key in this field.
api_env_var: Option<String>
If you’ve hard-coded your api key,
you don’t have to set this. If neither
api_key
, nor api_env_var
is set,
it assumes that the model doesn’t require
an api key.
Implementations§
Source§impl ModelRaw
impl ModelRaw
pub fn llama_70b() -> Self
pub fn llama_8b() -> Self
pub fn gpt_4o() -> Self
pub fn gpt_4o_mini() -> Self
pub fn gemini_2_flash() -> Self
pub fn sonnet() -> Self
pub fn phi_4_14b() -> Self
pub fn command_r() -> Self
pub fn command_r_plus() -> Self
pub fn default_models() -> Vec<ModelRaw>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ModelRaw
impl<'de> Deserialize<'de> for ModelRaw
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ModelRaw
impl RefUnwindSafe for ModelRaw
impl Send for ModelRaw
impl Sync for ModelRaw
impl Unpin for ModelRaw
impl UnwindSafe for ModelRaw
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more