feat(saas): 接通 embedding 模型管理全栈
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
数据库 migration 已有 is_embedding/model_type 列但全栈未使用。 打通 4 层: ModelRow → ModelInfo/CRUD → CachedModel → Admin 前端。 relay/models 端点也返回 is_embedding 字段,前端可按类型过滤。
This commit is contained in:
@@ -21,6 +21,8 @@ pub struct CachedModel {
|
||||
pub supports_streaming: bool,
|
||||
pub supports_vision: bool,
|
||||
pub enabled: bool,
|
||||
pub is_embedding: bool,
|
||||
pub model_type: String,
|
||||
pub pricing_input: f64,
|
||||
pub pricing_output: f64,
|
||||
}
|
||||
@@ -111,15 +113,15 @@ impl AppCache {
|
||||
self.providers.retain(|k, _| provider_keys.contains(k));
|
||||
|
||||
// Load models (key = model_id for relay lookup) — insert-then-retain
|
||||
let model_rows: Vec<(String, String, String, String, i64, i64, bool, bool, bool, f64, f64)> = sqlx::query_as(
|
||||
let model_rows: Vec<(String, String, String, String, i64, i64, bool, bool, bool, bool, String, f64, f64)> = sqlx::query_as(
|
||||
"SELECT id, provider_id, model_id, alias, context_window, max_output_tokens,
|
||||
supports_streaming, supports_vision, enabled, pricing_input, pricing_output
|
||||
supports_streaming, supports_vision, enabled, is_embedding, model_type, pricing_input, pricing_output
|
||||
FROM models"
|
||||
).fetch_all(db).await?;
|
||||
|
||||
let model_keys: HashSet<String> = model_rows.iter().map(|(_, _, mid, ..)| mid.clone()).collect();
|
||||
for (id, provider_id, model_id, alias, context_window, max_output_tokens,
|
||||
supports_streaming, supports_vision, enabled, pricing_input, pricing_output) in &model_rows
|
||||
supports_streaming, supports_vision, enabled, is_embedding, model_type, pricing_input, pricing_output) in &model_rows
|
||||
{
|
||||
self.models.insert(model_id.clone(), CachedModel {
|
||||
id: id.clone(),
|
||||
@@ -131,6 +133,8 @@ impl AppCache {
|
||||
supports_streaming: *supports_streaming,
|
||||
supports_vision: *supports_vision,
|
||||
enabled: *enabled,
|
||||
is_embedding: *is_embedding,
|
||||
model_type: model_type.clone(),
|
||||
pricing_input: *pricing_input,
|
||||
pricing_output: *pricing_output,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user