Move preferences from the database to a YAML config file
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,18 +79,13 @@ impl App {
|
||||
if prompt.is_empty() {
|
||||
return;
|
||||
}
|
||||
let model = match ModelChoice::from_id(&self.preferences.selected_model) {
|
||||
Some(model) => model,
|
||||
None => {
|
||||
self.error = Some("The selected model is not supported.".into());
|
||||
return;
|
||||
}
|
||||
};
|
||||
let effective = self.preferences.generation().and_then(|generation| {
|
||||
self.preferences.runtime().and_then(|runtime| {
|
||||
crate::settings::effective_settings(model, &generation, &runtime, &models_path())
|
||||
})
|
||||
});
|
||||
let model = self.config.model;
|
||||
let effective = crate::settings::effective_settings(
|
||||
model,
|
||||
&self.config.generation,
|
||||
&self.config.runtime,
|
||||
&models_path(),
|
||||
);
|
||||
let mut effective = match effective {
|
||||
Ok(settings) => settings,
|
||||
Err(error) => {
|
||||
@@ -158,7 +153,7 @@ impl App {
|
||||
}
|
||||
};
|
||||
let idle_timeout =
|
||||
Duration::from_secs(self.preferences.idle_timeout_minutes.max(1) as u64 * 60);
|
||||
Duration::from_secs(self.config.idle_timeout_minutes.max(1) as u64 * 60);
|
||||
self.active_generation = match service.generate(
|
||||
effective.engine,
|
||||
effective.turn,
|
||||
@@ -255,8 +250,7 @@ impl App {
|
||||
Ok(GenerationEvent::Finished(result)) => {
|
||||
match result {
|
||||
Ok(_) => {
|
||||
let model = ModelChoice::from_id(&self.preferences.selected_model)
|
||||
.unwrap_or_default();
|
||||
let model = self.config.model;
|
||||
let content = self
|
||||
.conversation
|
||||
.last()
|
||||
@@ -356,7 +350,7 @@ impl App {
|
||||
.find(|project| project.project.id == project_id)
|
||||
.map(|project| PathBuf::from(&project.project.path))
|
||||
.ok_or_else(|| "The active project is unavailable.".to_owned())?;
|
||||
let tools = crate::agent::Tools::new(&root, self.preferences.context_tokens)?;
|
||||
let tools = crate::agent::Tools::new(&root, self.config.generation.context_tokens)?;
|
||||
self.agent_tools = Some((session_id, Arc::new(Mutex::new(tools))));
|
||||
}
|
||||
let tools = Arc::clone(&self.agent_tools.as_ref().unwrap().1);
|
||||
@@ -369,12 +363,13 @@ impl App {
|
||||
let session_id = self
|
||||
.selected_session
|
||||
.ok_or_else(|| "The active session is unavailable.".to_owned())?;
|
||||
let model = ModelChoice::from_id(&self.preferences.selected_model)
|
||||
.ok_or_else(|| "The selected model is not supported.".to_owned())?;
|
||||
let generation = self.preferences.generation()?;
|
||||
let runtime = self.preferences.runtime()?;
|
||||
let mut effective =
|
||||
crate::settings::effective_settings(model, &generation, &runtime, &models_path())?;
|
||||
let model = self.config.model;
|
||||
let mut effective = crate::settings::effective_settings(
|
||||
model,
|
||||
&self.config.generation,
|
||||
&self.config.runtime,
|
||||
&models_path(),
|
||||
)?;
|
||||
effective.turn.system_prompt =
|
||||
crate::agent::system_prompt(model, &effective.turn.system_prompt);
|
||||
let assistant_reasoning = effective.turn.reasoning_mode != ReasoningMode::Direct;
|
||||
@@ -400,8 +395,7 @@ impl App {
|
||||
let mut assistant = ChatMessage::from(saved.1);
|
||||
assistant.reasoning_open = assistant_reasoning;
|
||||
self.conversation.push(assistant);
|
||||
let idle_timeout =
|
||||
Duration::from_secs(self.preferences.idle_timeout_minutes.max(1) as u64 * 60);
|
||||
let idle_timeout = Duration::from_secs(self.config.idle_timeout_minutes.max(1) as u64 * 60);
|
||||
self.active_generation = Some(
|
||||
self.generation_service
|
||||
.as_ref()
|
||||
@@ -428,13 +422,13 @@ impl App {
|
||||
if self.active_titling.is_some() {
|
||||
return Err("A title is already being generated.".into());
|
||||
}
|
||||
let model = ModelChoice::from_id(&self.preferences.selected_model)
|
||||
.ok_or_else(|| "The selected model is not supported.".to_owned())?;
|
||||
let mut effective = self.preferences.generation().and_then(|generation| {
|
||||
self.preferences.runtime().and_then(|runtime| {
|
||||
crate::settings::effective_settings(model, &generation, &runtime, &models_path())
|
||||
})
|
||||
})?;
|
||||
let model = self.config.model;
|
||||
let mut effective = crate::settings::effective_settings(
|
||||
model,
|
||||
&self.config.generation,
|
||||
&self.config.runtime,
|
||||
&models_path(),
|
||||
)?;
|
||||
let database = self
|
||||
.database
|
||||
.as_mut()
|
||||
@@ -475,8 +469,7 @@ impl App {
|
||||
.generation_service
|
||||
.as_ref()
|
||||
.ok_or_else(|| "The model runtime is unavailable.".to_owned())?;
|
||||
let idle_timeout =
|
||||
Duration::from_secs(self.preferences.idle_timeout_minutes.max(1) as u64 * 60);
|
||||
let idle_timeout = Duration::from_secs(self.config.idle_timeout_minutes.max(1) as u64 * 60);
|
||||
match service.generate(
|
||||
effective.engine,
|
||||
effective.turn,
|
||||
|
||||
Reference in New Issue
Block a user