forked from vhaudiquet/rhema-together
feat: add providers without a default model
The add-provider form asked for a model even though the room owns that choice. It now asks for a name, kind, base URL, and key. New providers store no default, and New room requires a model before it can submit. Existing providers keep their model as an optional default. The model picker hides the Provider default row when there is none, and a room with no usable model gets a clear error instead of an empty model reaching the provider.
This commit is contained in:
1 parent
2216f37422
commit
369075a842
10 files changed
+48
-33
No files matched your search
@@ -227,6 +227,9 @@ pub async fn create(
|
||||
.map(|model| model.trim().to_owned())
|
||||
.filter(|model| !model.is_empty())
|
||||
.unwrap_or_else(|| provider_model.clone());
|
||||
if model.trim().is_empty() {
|
||||
return Err(AppError::bad_request("pick a model for the room"));
|
||||
}
|
||||
let now = now_ms();
|
||||
{
|
||||
let conn = state.db.conn();
|
||||
|
||||
+4
-4
@@ -55,6 +55,9 @@ pub async fn list_providers(user: AuthUser, State(state): State<Shared>) -> AppR
|
||||
pub struct CreateProvider {
|
||||
pub name: String,
|
||||
pub kind: String,
|
||||
/// An optional default for older clients. The room picks the model
|
||||
/// it uses, so the add-provider form leaves this empty.
|
||||
#[serde(default)]
|
||||
pub model: String,
|
||||
#[serde(default)]
|
||||
pub base_url: Option<String>,
|
||||
@@ -79,10 +82,7 @@ pub async fn create_provider(
|
||||
if !KINDS.contains(&body.kind.as_str()) {
|
||||
return Err(AppError::bad_request("unknown provider kind"));
|
||||
}
|
||||
let model = body.model.trim();
|
||||
if model.is_empty() {
|
||||
return Err(AppError::bad_request("a model id is required"));
|
||||
}
|
||||
let model = body.model.trim().to_owned();
|
||||
let base_url = body
|
||||
.base_url
|
||||
.map(|url| url.trim().to_owned())
|
||||
|
||||
+7
-1
@@ -129,12 +129,18 @@ pub fn load_turn_config(state: &Shared, room_id: &str) -> AppResult<TurnConfig>
|
||||
let members = stmt
|
||||
.query_map(rusqlite::params![room_id], |row| row.get::<_, String>(0))?
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let model = room_model
|
||||
.filter(|model| !model.trim().is_empty())
|
||||
.unwrap_or(provider_model);
|
||||
if model.trim().is_empty() {
|
||||
return Err(AppError::bad_request("room has no model selected"));
|
||||
}
|
||||
Ok(TurnConfig {
|
||||
room_id: room_id.to_owned(),
|
||||
room_name: name,
|
||||
workspace,
|
||||
repo_url,
|
||||
model: room_model.unwrap_or_else(|| provider_model.clone()),
|
||||
model,
|
||||
max_turn_steps: max_steps.max(1) as u32,
|
||||
absorbed_seq: absorbed,
|
||||
seeded: seeded != 0,
|
||||
|
||||
Reference in new issue
Block a user