71 lines
2.5 KiB
Rust
71 lines
2.5 KiB
Rust
use crate::AppConfig;
|
|
|
|
impl AppConfig {
|
|
pub fn channel_ai_basic_url(&self) -> anyhow::Result<String> {
|
|
if let Some(url) = self.env.get("APP_CHANNEL_AI_BASIC_URL") {
|
|
return Ok(url.to_string());
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_BASIC_URL not found"))
|
|
}
|
|
|
|
pub fn channel_ai_api_key(&self) -> anyhow::Result<String> {
|
|
if let Some(api_key) = self.env.get("APP_CHANNEL_AI_API_KEY") {
|
|
return Ok(api_key.to_string());
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_API_KEY not found"))
|
|
}
|
|
|
|
pub fn channel_ai_model(&self) -> anyhow::Result<String> {
|
|
if let Some(model) = self.env.get("APP_CHANNEL_AI_MODEL") {
|
|
return Ok(model.to_string());
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_MODEL not found"))
|
|
}
|
|
|
|
pub fn channel_ai_context_length(&self) -> anyhow::Result<usize> {
|
|
if let Some(v) = self.env.get("APP_CHANNEL_AI_CONTEXT_LENGTH") {
|
|
return Ok(v.parse::<usize>()?);
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_CONTEXT_LENGTH not found"))
|
|
}
|
|
|
|
pub fn channel_ai_max_tokens(&self) -> anyhow::Result<u32> {
|
|
if let Some(v) = self.env.get("APP_CHANNEL_AI_MAX_TOKENS") {
|
|
return Ok(v.parse::<u32>()?);
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_MAX_TOKENS not found"))
|
|
}
|
|
|
|
pub fn channel_ai_temperature(&self) -> anyhow::Result<f64> {
|
|
if let Some(v) = self.env.get("APP_CHANNEL_AI_TEMPERATURE") {
|
|
return Ok(v.parse::<f64>()?);
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_TEMPERATURE not found"))
|
|
}
|
|
|
|
pub fn channel_ai_top_p(&self) -> anyhow::Result<f64> {
|
|
if let Some(v) = self.env.get("APP_CHANNEL_AI_TOP_P") {
|
|
return Ok(v.parse::<f64>()?);
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_TOP_P not found"))
|
|
}
|
|
|
|
pub fn channel_ai_stop(&self) -> Option<String> {
|
|
self.env.get("APP_CHANNEL_AI_STOP").cloned()
|
|
}
|
|
|
|
pub fn channel_ai_max_retries(&self) -> anyhow::Result<u32> {
|
|
if let Some(v) = self.env.get("APP_CHANNEL_AI_MAX_RETRIES") {
|
|
return Ok(v.parse::<u32>()?);
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_MAX_RETRIES not found"))
|
|
}
|
|
|
|
pub fn channel_ai_retry_delay_secs(&self) -> anyhow::Result<u64> {
|
|
if let Some(v) = self.env.get("APP_CHANNEL_AI_RETRY_DELAY_SECS") {
|
|
return Ok(v.parse::<u64>()?);
|
|
}
|
|
Err(anyhow::anyhow!("APP_CHANNEL_AI_RETRY_DELAY_SECS not found"))
|
|
}
|
|
}
|