Add check for vision capabilities
This commit is contained in:
@@ -3,7 +3,7 @@ use opentelemetry::KeyValue;
|
||||
use opentelemetry::trace::{Span, Status, Tracer};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::ai::{InsightGenerator, OllamaClient};
|
||||
use crate::ai::{InsightGenerator, ModelCapabilities, OllamaClient};
|
||||
use crate::data::Claims;
|
||||
use crate::database::InsightDao;
|
||||
use crate::otel::{extract_context_from_request, global_tracer};
|
||||
@@ -45,7 +45,7 @@ pub struct AvailableModelsResponse {
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct ServerModels {
|
||||
pub url: String,
|
||||
pub models: Vec<String>,
|
||||
pub models: Vec<ModelCapabilities>,
|
||||
pub default_model: String,
|
||||
}
|
||||
|
||||
@@ -211,18 +211,18 @@ pub async fn get_all_insights_handler(
|
||||
}
|
||||
}
|
||||
|
||||
/// GET /insights/models - List available models from both servers
|
||||
/// GET /insights/models - List available models from both servers with capabilities
|
||||
#[get("/insights/models")]
|
||||
pub async fn get_available_models_handler(
|
||||
_claims: Claims,
|
||||
app_state: web::Data<crate::state::AppState>,
|
||||
) -> impl Responder {
|
||||
log::debug!("Fetching available models");
|
||||
log::debug!("Fetching available models with capabilities");
|
||||
|
||||
let ollama_client = &app_state.ollama;
|
||||
|
||||
// Fetch models from primary server
|
||||
let primary_models = match OllamaClient::list_models(&ollama_client.primary_url).await {
|
||||
// Fetch models with capabilities from primary server
|
||||
let primary_models = match OllamaClient::list_models_with_capabilities(&ollama_client.primary_url).await {
|
||||
Ok(models) => models,
|
||||
Err(e) => {
|
||||
log::warn!("Failed to fetch models from primary server: {:?}", e);
|
||||
@@ -236,9 +236,9 @@ pub async fn get_available_models_handler(
|
||||
default_model: ollama_client.primary_model.clone(),
|
||||
};
|
||||
|
||||
// Fetch models from fallback server if configured
|
||||
// Fetch models with capabilities from fallback server if configured
|
||||
let fallback = if let Some(fallback_url) = &ollama_client.fallback_url {
|
||||
match OllamaClient::list_models(fallback_url).await {
|
||||
match OllamaClient::list_models_with_capabilities(fallback_url).await {
|
||||
Ok(models) => Some(ServerModels {
|
||||
url: fallback_url.clone(),
|
||||
models,
|
||||
|
||||
Reference in New Issue
Block a user