The personal finance app for everyone (by everyone)
Ruby
Say when the OpenAI model is required and how to reach a local one (#4408)
jaysbeekay17e9fe67ce7d
diff --git a/app/views/settings/hostings/_openai_settings.html.erb b/app/views/settings/hostings/_openai_settings.html.erbindex 789b654970..0e7ab6c8fe 100644--- a/app/views/settings/hostings/_openai_settings.html.erb+++ b/app/views/settings/hostings/_openai_settings.html.erb@@ -37,6 +37,7 @@inputmode: "url",disabled: ENV["OPENAI_URI_BASE"].present?,data: { "auto-submit-form-target": "auto" } %>+ <p class="text-xs text-secondary mt-1"><%= t(".uri_base_local_help") %></p><%= form.text_field :openai_model,label: t(".model_label"),@@ -49,6 +50,7 @@disabled: ENV["OPENAI_MODEL"].present?,data: { "auto-submit-form-target": "auto" } %><p class="text-xs text-secondary mt-1">+ <%= t(".model_required_help") %><%= t(".model_function_calling_help") %><% if Current.user&.super_admin? %><%= link_to t(".model_function_calling_link"), admin_system_health_path(tab: "ai"), class: "underline" %>diff --git a/config/locales/views/settings/hostings/ca.yml b/config/locales/views/settings/hostings/ca.ymlindex 32cb3646aa..2cb3c48b93 100644--- a/config/locales/views/settings/hostings/ca.yml+++ b/config/locales/views/settings/hostings/ca.yml@@ -144,9 +144,11 @@ ca:max_response_tokens_label: Màxim de tokens de resposta (opcional)model_label: Model (opcional)model_placeholder: gpt-4.1 (per defecte)+ model_required_help: "Obligatori quan defineixes una URL base de l'API: introdueix el nom del model que utilitza el teu servidor, com ara llama3.1 per a Ollama."title: OpenAIuri_base_label: URL base de l'API (opcional)uri_base_placeholder: https://api.openai.com/v1 (per defecte)+ uri_base_local_help: "Per a un model al teu propi ordinador, introdueix el seu endpoint compatible amb OpenAI, per exemple Ollama a http://localhost:11434/v1, o http://ollama:11434/v1 si Sure i Ollama s'executen com a serveis de Docker Compose."model_function_calling_help: L'assistent d'IA llegeix les teves dades mitjançant crides a funcions, així que tria un model que el teu proveïdor documenti com a compatible amb eines/crides a funcions. Els models que no ho admeten fan fallar el xat amb un error poc clar del proveïdor.model_function_calling_link: Comprova el model configurattimeout_heading: Temps d'esperadiff --git a/config/locales/views/settings/hostings/de.yml b/config/locales/views/settings/hostings/de.ymlindex 39433beafd..f7951eba15 100644--- a/config/locales/views/settings/hostings/de.yml+++ b/config/locales/views/settings/hostings/de.yml@@ -80,8 +80,10 @@ de:access_token_placeholder: Gib hier dein Zugriffstoken einuri_base_label: API-Basis-URL (optional)uri_base_placeholder: "https://api.openai.com/v1 (Standard)"+ uri_base_local_help: "Für ein Modell auf deinem eigenen Rechner gib dessen OpenAI-kompatiblen Endpunkt ein, zum Beispiel Ollama unter http://localhost:11434/v1, oder http://ollama:11434/v1, wenn Sure und Ollama als Docker-Compose-Dienste laufen."model_label: Modell (optional)model_placeholder: "gpt-4.1 (Standard)"+ model_required_help: "Erforderlich, wenn du eine API-Basis-URL festlegst: Gib den Modellnamen ein, den dein Server verwendet, etwa llama3.1 für Ollama."model_function_calling_help: Der KI-Assistent liest deine Daten mithilfe von Funktionsaufrufen. Wähl daher ein Modell, das laut Dokumentation deines Anbieters Tools beziehungsweise Function Calling unterstützt. Ohne diese Unterstützung schlägt der Chat mit einer wenig aussagekräftigen Fehlermeldung des Anbieters fehl.model_function_calling_link: Konfiguriertes Modell prüfenjson_mode_label: JSON-Modusdiff --git a/config/locales/views/settings/hostings/en.yml b/config/locales/views/settings/hostings/en.ymlindex 3bc6b04956..4eb5143881 100644--- a/config/locales/views/settings/hostings/en.yml+++ b/config/locales/views/settings/hostings/en.yml@@ -189,10 +189,12 @@ en:access_token_placeholder: Enter your access token hereuri_base_label: API Base URL (Optional)uri_base_placeholder: "https://api.openai.com/v1 (default)"+ uri_base_local_help: "For a model on your own machine, enter its OpenAI-compatible endpoint, for example Ollama at http://localhost:11434/v1, or http://ollama:11434/v1 when Sure and Ollama run as Docker Compose services."model_label: Model (Optional)model_placeholder: "gpt-4.1 (default)"model_function_calling_help: "The AI assistant reads your data through function calls, so pick a model your provider documents as supporting tools/function calling. Models without it fail chat with an opaque provider error."model_function_calling_link: Check the configured model+ model_required_help: "Required when you set an API base URL: enter the model name your server uses, such as llama3.1 for Ollama."json_mode_label: JSON Modejson_mode_auto: Auto (recommended)json_mode_strict: Strict (best for thinking models)diff --git a/config/locales/views/settings/hostings/es.yml b/config/locales/views/settings/hostings/es.ymlindex 3cf8adf2ca..8b25a67ee6 100644--- a/config/locales/views/settings/hostings/es.yml+++ b/config/locales/views/settings/hostings/es.yml@@ -129,8 +129,10 @@ es:access_token_placeholder: Introduce tu token de acceso aquíuri_base_label: URL Base de la API (Opcional)uri_base_placeholder: https://api.openai.com/v1 (por defecto)+ uri_base_local_help: "Para un modelo en tu propio equipo, introduce su endpoint compatible con OpenAI, por ejemplo Ollama en http://localhost:11434/v1, o http://ollama:11434/v1 si Sure y Ollama se ejecutan como servicios de Docker Compose."model_label: Modelo (Opcional)model_placeholder: gpt-4.1 (por defecto)+ model_required_help: "Obligatorio cuando defines una URL base de la API: introduce el nombre del modelo que usa tu servidor, como llama3.1 para Ollama."json_mode_label: Modo JSONjson_mode_auto: Automático (recomendado)json_mode_strict: Estricto (mejor para modelos "thinking")diff --git a/config/locales/views/settings/hostings/fr.yml b/config/locales/views/settings/hostings/fr.ymlindex e7c7440ab9..319127bc0b 100644--- a/config/locales/views/settings/hostings/fr.yml+++ b/config/locales/views/settings/hostings/fr.yml@@ -209,6 +209,7 @@ fr:model_function_calling_link: Vérifier le modèle configurémodel_label: Modèle (Optionnel)model_placeholder: gpt-4.1 (par défaut)+ model_required_help: "Obligatoire lorsque vous définissez une URL de base de l'API : saisissez le nom du modèle utilisé par votre serveur, par exemple llama3.1 pour Ollama."openai_request_timeout_help: 'Valeur par défaut : 60. S''applique à chaque requête HTTP compatible OpenAI, y compris la catégorisation automatique, la détection des marchands, le chat, le traitement des PDF et les appels au magasin de vecteurs. OPENAI_REQUEST_TIMEOUT prime sur ce champ.'openai_request_timeout_label: Délai de requête en secondes (facultatif)timeout_description: Détermine la durée maximale des appels aux modèles compatibles OpenAI avant que Sure n'abandonne. Augmentez ces valeurs si vous exécutez un modèle local sur du matériel lent.@@ -216,6 +217,7 @@ fr:title: OpenAIuri_base_label: URL de base de l'API (Optionnel)uri_base_placeholder: https://api.openai.com/v1 (par défaut)+ uri_base_local_help: "Pour un modèle sur votre propre machine, saisissez son endpoint compatible OpenAI, par exemple Ollama à http://localhost:11434/v1, ou http://ollama:11434/v1 si Sure et Ollama tournent comme services Docker Compose."provider_selection:binance_public_hint: gratuit, aucune clé API -- crypto uniquement (BTC, ETH, etc.)env_configured_message: La sélection du fournisseur est désactivée car des variables d'environnement sont définies. Pour activer la sélection ici, supprimez ces variables d'environnement de votre configuration.diff --git a/config/locales/views/settings/hostings/hu.yml b/config/locales/views/settings/hostings/hu.ymlindex fbe692aae4..9d7f87fa38 100644--- a/config/locales/views/settings/hostings/hu.yml+++ b/config/locales/views/settings/hostings/hu.yml@@ -102,8 +102,10 @@ hu:access_token_placeholder: Add meg ide a hozzáférési tokenedeturi_base_label: API alap URL (nem kötelező)uri_base_placeholder: "https://api.openai.com/v1 (alapértelmezett)"+ uri_base_local_help: "Saját gépen futó modellhez add meg az OpenAI-kompatibilis végpontját, például az Ollamát a http://localhost:11434/v1 címen, vagy a http://ollama:11434/v1 címen, ha a Sure és az Ollama Docker Compose szolgáltatásként fut."model_label: Modell (nem kötelező)model_placeholder: "gpt-4.1 (alapértelmezett)"+ model_required_help: "Kötelező, ha API alap-URL-t adsz meg: írd be a szervered által használt modell nevét, például llama3.1 az Ollamához."json_mode_label: JSON módjson_mode_auto: Automatikus (ajánlott)json_mode_strict: Szigorú (gondolkodó modellekhez a legjobb)diff --git a/config/locales/views/settings/hostings/it.yml b/config/locales/views/settings/hostings/it.ymlindex 445d3ef877..dbf7338af5 100644--- a/config/locales/views/settings/hostings/it.yml+++ b/config/locales/views/settings/hostings/it.yml@@ -124,8 +124,10 @@ it:access_token_placeholder: Inserisci il tuo token di accesso quiuri_base_label: URL base API (facoltativo)uri_base_placeholder: "https://api.openai.com/v1 (predefinito)"+ uri_base_local_help: "Per un modello sulla tua macchina, inserisci il suo endpoint compatibile con OpenAI, ad esempio Ollama su http://localhost:11434/v1, oppure http://ollama:11434/v1 se Sure e Ollama girano come servizi Docker Compose."model_label: Modello (facoltativo)model_placeholder: "gpt-4.1 (predefinito)"+ model_required_help: "Obbligatorio quando imposti un URL di base dell'API: inserisci il nome del modello usato dal tuo server, ad esempio llama3.1 per Ollama."json_mode_label: Modalità JSONjson_mode_auto: Auto (consigliato)json_mode_strict: Strict (ottimo per modelli thinking)diff --git a/config/locales/views/settings/hostings/nl.yml b/config/locales/views/settings/hostings/nl.ymlindex 7406e9a012..5f88ce2639 100644--- a/config/locales/views/settings/hostings/nl.yml+++ b/config/locales/views/settings/hostings/nl.yml@@ -46,8 +46,10 @@ nl:access_token_placeholder: Voer hier uw toegangstoken inuri_base_label: API basis-URL (optioneel)uri_base_placeholder: "https://api.openai.com/v1 (standaard)"+ uri_base_local_help: "Voor een model op uw eigen computer vult u het OpenAI-compatibele endpoint in, bijvoorbeeld Ollama op http://localhost:11434/v1, of http://ollama:11434/v1 als Sure en Ollama als Docker Compose-services draaien."model_label: Model (optioneel)model_placeholder: "gpt-4.1 (standaard)"+ model_required_help: "Verplicht als u een API-basis-URL instelt: vul de modelnaam in die uw server gebruikt, zoals llama3.1 voor Ollama."json_mode_label: JSON modusjson_mode_auto: Auto (aanbevolen)json_mode_strict: Strikt (beste voor denkende modellen)diff --git a/config/locales/views/settings/hostings/pl.yml b/config/locales/views/settings/hostings/pl.ymlindex dadb73ebb8..98dbb3a799 100644--- a/config/locales/views/settings/hostings/pl.yml+++ b/config/locales/views/settings/hostings/pl.yml@@ -222,6 +222,7 @@ pl:model_function_calling_link: Sprawdź skonfigurowany modelmodel_label: Model (opcjonalne)model_placeholder: gpt-4.1 (domyślnie)+ model_required_help: "Wymagane, gdy ustawiasz bazowy URL API: wpisz nazwę modelu używaną przez twój serwer, np. llama3.1 dla Ollamy."openai_request_timeout_help: 'Domyślnie: 60. Dotyczy każdego żądania HTTPzgodnego z OpenAI, w tym automatycznej kategoryzacji, wykrywania sprzedawcy,czatu, przetwarzania PDF oraz wywołań magazynu wektorów. OPENAI_REQUEST_TIMEOUT@@ -234,6 +235,7 @@ pl:title: OpenAIuri_base_label: Bazowy URL API (opcjonalne)uri_base_placeholder: https://api.openai.com/v1 (domyślnie)+ uri_base_local_help: "Dla modelu na własnym komputerze wpisz jego endpoint zgodny z OpenAI, na przykład Ollama pod http://localhost:11434/v1 albo http://ollama:11434/v1, gdy Sure i Ollama działają jako usługi Docker Compose."provider_selection:binance_public_hint: za darmo, bez klucza API - tylko kryptowaluty (BTC, ETHitd.)diff --git a/config/locales/views/settings/hostings/pt-BR.yml b/config/locales/views/settings/hostings/pt-BR.ymlindex c1ab36f5af..4c6cb59328 100644--- a/config/locales/views/settings/hostings/pt-BR.yml+++ b/config/locales/views/settings/hostings/pt-BR.yml@@ -46,8 +46,10 @@ pt-BR:access_token_placeholder: Insira seu token de acesso aquiuri_base_label: URL Base da API (Opcional)uri_base_placeholder: "https://api.openai.com/v1 (padrão)"+ uri_base_local_help: "Para um modelo no seu próprio computador, informe o endpoint compatível com OpenAI, por exemplo Ollama em http://localhost:11434/v1, ou http://ollama:11434/v1 quando o Sure e o Ollama rodam como serviços do Docker Compose."model_label: Modelo (Opcional)model_placeholder: "gpt-4.1 (padrão)"+ model_required_help: "Obrigatório quando você define uma URL base da API: informe o nome do modelo usado pelo seu servidor, como llama3.1 para o Ollama."title: OpenAIyahoo_finance_settings:title: Yahoo Financediff --git a/config/locales/views/settings/hostings/pt-PT.yml b/config/locales/views/settings/hostings/pt-PT.ymlindex e8413ab82d..14921ccd28 100644--- a/config/locales/views/settings/hostings/pt-PT.yml+++ b/config/locales/views/settings/hostings/pt-PT.yml@@ -127,8 +127,10 @@ pt-PT:access_token_placeholder: Introduza o seu token de acesso aquiuri_base_label: URL Base da API (Opcional)uri_base_placeholder: "https://api.openai.com/v1 (predefinição)"+ uri_base_local_help: "Para um modelo no seu próprio computador, indique o endpoint compatível com OpenAI, por exemplo Ollama em http://localhost:11434/v1, ou http://ollama:11434/v1 quando o Sure e o Ollama correm como serviços do Docker Compose."model_label: Modelo (Opcional)model_placeholder: "gpt-4.1 (predefinição)"+ model_required_help: "Obrigatório quando define um URL base da API: indique o nome do modelo usado pelo seu servidor, como llama3.1 para o Ollama."json_mode_label: Modo JSONjson_mode_auto: Automático (recomendado)json_mode_strict: Estrito (melhor para modelos de raciocínio)diff --git a/config/locales/views/settings/hostings/ro.yml b/config/locales/views/settings/hostings/ro.ymlindex 2a8eab6f77..f50b3cc16a 100644--- a/config/locales/views/settings/hostings/ro.yml+++ b/config/locales/views/settings/hostings/ro.yml@@ -36,8 +36,10 @@ ro:access_token_placeholder: Introdu tokenul tău de acces aiciuri_base_label: URL de Bază API (Opțional)uri_base_placeholder: "https://api.openai.com/v1 (implicit)"+ uri_base_local_help: "Pentru un model pe propriul calculator, introdu endpoint-ul compatibil OpenAI, de exemplu Ollama la http://localhost:11434/v1, sau http://ollama:11434/v1 când Sure și Ollama rulează ca servicii Docker Compose."model_label: Model (Opțional)model_placeholder: "gpt-4.1 (implicit)"+ model_required_help: "Obligatoriu când setezi un URL de bază API: introdu numele modelului folosit de serverul tău, de exemplu llama3.1 pentru Ollama."title: OpenAIyahoo_finance_settings:title: Yahoo Financediff --git a/config/locales/views/settings/hostings/ru.yml b/config/locales/views/settings/hostings/ru.ymlindex f5523818ea..0d3a0ddcce 100644--- a/config/locales/views/settings/hostings/ru.yml+++ b/config/locales/views/settings/hostings/ru.yml@@ -171,9 +171,11 @@ ru:max_response_tokens_label: Максимум токенов ответа (необязательно)model_label: Модель (необязательно)model_placeholder: gpt-4.1 (по умолчанию)+ model_required_help: "Обязательно, если задан базовый URL API: укажите название модели на вашем сервере, например llama3.1 для Ollama."title: OpenAIuri_base_label: Базовый URL API (необязательно)uri_base_placeholder: https://api.openai.com/v1 (по умолчанию)+ uri_base_local_help: "Для модели на вашем компьютере укажите её OpenAI-совместимый endpoint, например Ollama по адресу http://localhost:11434/v1 или http://ollama:11434/v1, если Sure и Ollama запущены как сервисы Docker Compose."model_function_calling_help: AI-ассистент читает ваши данные через вызовы функций, поэтому выберите модель, для которой ваш поставщик заявляет поддержку инструментов (tools/function calling). Модели без такой поддержки прерывают чат малопонятной ошибкой поставщика.model_function_calling_link: Проверить настроенную модельtimeout_heading: Тайм-аутыdiff --git a/config/locales/views/settings/hostings/tr.yml b/config/locales/views/settings/hostings/tr.ymlindex 01ee6d07d5..8ca30dc28a 100644--- a/config/locales/views/settings/hostings/tr.yml+++ b/config/locales/views/settings/hostings/tr.yml@@ -183,9 +183,11 @@ tr:max_response_tokens_label: Maksimum Yanıt Token'ı (İsteğe Bağlı)model_label: Model (İsteğe Bağlı)model_placeholder: gpt-4.1 (varsayılan)+ model_required_help: "Bir API temel URL'si belirlediğinizde zorunludur: sunucunuzun kullandığı model adını girin, örneğin Ollama için llama3.1."title: OpenAIuri_base_label: API Temel URL'si (İsteğe Bağlı)uri_base_placeholder: https://api.openai.com/v1 (varsayılan)+ uri_base_local_help: "Kendi makinenizdeki bir model için OpenAI uyumlu uç noktasını girin, örneğin Ollama için http://localhost:11434/v1; Sure ve Ollama Docker Compose servisleri olarak çalışıyorsa http://ollama:11434/v1."model_function_calling_help: Yapay zeka asistanı verilerinizi fonksiyon çağrılarıyla okur; bu nedenle sağlayıcınızın araç/fonksiyon çağırmayı desteklediğini belirttiği bir model seçin. Bu desteği olmayan modellerde sohbet, anlaşılması güç bir sağlayıcı hatasıyla başarısız olur.model_function_calling_link: Yapılandırılan modeli kontrol ettimeout_heading: Zaman aşımlarıdiff --git a/config/locales/views/settings/hostings/uk.yml b/config/locales/views/settings/hostings/uk.ymlindex 14f70c3f1d..2b38fb2de4 100644--- a/config/locales/views/settings/hostings/uk.yml+++ b/config/locales/views/settings/hostings/uk.yml@@ -127,8 +127,10 @@ uk:access_token_placeholder: Введіть свій токен доступу тутuri_base_label: Базова URL-адреса API (необов'язково)uri_base_placeholder: "https://api.openai.com/v1 (за замовчуванням)"+ uri_base_local_help: "Для моделі на вашому комп'ютері вкажіть її OpenAI-сумісний endpoint, наприклад Ollama за адресою http://localhost:11434/v1 або http://ollama:11434/v1, якщо Sure та Ollama запущені як сервіси Docker Compose."model_label: Модель (необов'язково)model_placeholder: "gpt-4.1 (за замовчуванням)"+ model_required_help: "Обов'язково, якщо задано базову URL-адресу API: вкажіть назву моделі на вашому сервері, наприклад llama3.1 для Ollama."json_mode_label: Режим JSONjson_mode_auto: Авто (рекомендовано)json_mode_strict: Суворий (найкраще для моделей мислення)diff --git a/config/locales/views/settings/hostings/vi.yml b/config/locales/views/settings/hostings/vi.ymlindex 65539916f4..25535315aa 100644--- a/config/locales/views/settings/hostings/vi.yml+++ b/config/locales/views/settings/hostings/vi.yml@@ -101,8 +101,10 @@ vi:access_token_placeholder: Nhập token truy cập của bạn vào đâyuri_base_label: URL cơ sở API (Tùy chọn)uri_base_placeholder: "https://api.openai.com/v1 (mặc định)"+ uri_base_local_help: "Với mô hình chạy trên máy của bạn, hãy nhập endpoint tương thích OpenAI của nó, ví dụ Ollama tại http://localhost:11434/v1, hoặc http://ollama:11434/v1 khi Sure và Ollama chạy dưới dạng dịch vụ Docker Compose."model_label: Mô hình (Tùy chọn)model_placeholder: "gpt-4.1 (mặc định)"+ model_required_help: "Bắt buộc khi bạn đặt URL cơ sở của API: nhập tên mô hình máy chủ của bạn dùng, chẳng hạn llama3.1 cho Ollama."json_mode_label: Chế độ JSONjson_mode_auto: Tự động (khuyến nghị)json_mode_strict: Nghiêm ngặt (tốt nhất cho mô hình suy nghĩ)diff --git a/config/locales/views/settings/hostings/zh-CN.yml b/config/locales/views/settings/hostings/zh-CN.ymlindex 21a44f33da..f4a4279c40 100644--- a/config/locales/views/settings/hostings/zh-CN.yml+++ b/config/locales/views/settings/hostings/zh-CN.yml@@ -44,9 +44,11 @@ zh-CN:json_mode_strict: 严格(最适合思考模型)model_label: 模型(可选)model_placeholder: gpt-4.1(默认)+ model_required_help: "设置了 API 基础 URL 时必填:填写您的服务器使用的模型名称,例如 Ollama 的 llama3.1。"title: OpenAI 设置uri_base_label: API 基础 URL(可选)uri_base_placeholder: https://api.openai.com/v1(默认)+ uri_base_local_help: "如果模型运行在您自己的机器上,请填写其兼容 OpenAI 的端点,例如 Ollama 的 http://localhost:11434/v1;如果 Sure 和 Ollama 作为 Docker Compose 服务运行,则填写 http://ollama:11434/v1。"budget_heading: Token 预算budget_description: 控制每次 AI 请求可使用的 Token 上限。context_window_label: 上下文窗口(可选)diff --git a/config/locales/views/settings/hostings/zh-TW.yml b/config/locales/views/settings/hostings/zh-TW.ymlindex 6692b7e9cf..50a3fd6b51 100644--- a/config/locales/views/settings/hostings/zh-TW.yml+++ b/config/locales/views/settings/hostings/zh-TW.yml@@ -129,8 +129,10 @@ zh-TW:access_token_placeholder: 在此輸入您的 Access Tokenuri_base_label: API 基礎 URL(選填)uri_base_placeholder: 預設為 https://api.openai.com/v1+ uri_base_local_help: "如果模型執行在您自己的電腦上,請填寫其相容 OpenAI 的端點,例如 Ollama 的 http://localhost:11434/v1;如果 Sure 和 Ollama 以 Docker Compose 服務執行,則填寫 http://ollama:11434/v1。"model_label: 模型名稱(選填)model_placeholder: 預設為 gpt-4.1+ model_required_help: "設定了 API 基礎 URL 時必填:填寫您的伺服器使用的模型名稱,例如 Ollama 的 llama3.1。"json_mode_label: JSON 模式json_mode_auto: 自動(建議)json_mode_strict: 嚴格 (Strict) - 最適合思考模型diff --git a/test/controllers/settings/hostings_controller_test.rb b/test/controllers/settings/hostings_controller_test.rbindex 7b9314ebae..e3cf42586f 100644--- a/test/controllers/settings/hostings_controller_test.rb+++ b/test/controllers/settings/hostings_controller_test.rb@@ -149,6 +149,8 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTestend%w[+ uri_base_local_help+ model_required_helpmodel_function_calling_helpmodel_function_calling_linktimeout_heading@@ -164,6 +166,41 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTestendend+ # A custom base URL needs a model, and the controller refuses one without+ # it, so the form says so rather than leaving "(Optional)" to mislead. It+ # also names both Ollama endpoints the hosting docs describe: localhost for+ # a bare-metal install, and the Compose service name, because localhost+ # inside the Sure container is not the Ollama container.+ test "the OpenAI settings explain a local model and when the model is required" do+ with_self_hosting do+ get settings_hosting_url++ assert_response :success+ assert_includes response.body, I18n.t("settings.hostings.openai_settings.uri_base_local_help")+ assert_includes response.body, I18n.t("settings.hostings.openai_settings.model_required_help")+ assert_includes I18n.t("settings.hostings.openai_settings.uri_base_local_help"), "http://localhost:11434/v1"+ assert_includes I18n.t("settings.hostings.openai_settings.uri_base_local_help"), "http://ollama:11434/v1"++ # Every locale that translates this form translates both lines, so none+ # falls back to English for them while the rest of the panel is local.+ translated = I18n.available_locales.select do |locale|+ I18n.exists?("settings.hostings.openai_settings", locale, fallback: false)+ end+ assert_operator translated.size, :>, 1, "no translated locale was checked"++ translated.each do |locale|+ %w[uri_base_local_help model_required_help].each do |key|+ assert I18n.exists?("settings.hostings.openai_settings.#{key}", locale, fallback: false),+ "#{locale} has an openai_settings block but no #{key}"+ end++ help = I18n.t("settings.hostings.openai_settings.uri_base_local_help", locale: locale)+ assert_includes help, "http://localhost:11434/v1", "#{locale} help lost the bare-metal address"+ assert_includes help, "http://ollama:11434/v1", "#{locale} help lacks the Docker Compose address"+ end+ end+ end+test "only a super admin can opt in and the selected family must own the demo email" do# The configured demo email is already used by the new_email fixture.demo_email = "[email protected]"diff --git a/test/models/provider/openai_test.rb b/test/models/provider/openai_test.rbindex 57a7fe69c0..14c232768c 100644--- a/test/models/provider/openai_test.rb+++ b/test/models/provider/openai_test.rb@@ -89,6 +89,24 @@ class Provider::OpenaiTest < ActiveSupport::TestCaseendend+ # The registry and the settings form both stop a custom base URL without a+ # model before it gets here; this is the provider's own guard behind them.+ test "a custom base URL without a model is refused" do+ error = assert_raises(Provider::Openai::Error) do+ Provider::Openai.new("ollama-local", uri_base: "http://localhost:11434/v1", model: nil)+ end++ assert_match(/Model is required/, error.message)+ end++ test "a custom base URL accepts any model name, as a local server's models are its own" do+ local = Provider::Openai.new("ollama-local", uri_base: "http://localhost:11434/v1", model: "llama3.1")++ assert local.custom_provider?+ assert local.supports_model?("llama3.1")+ assert local.supports_model?("qwen2.5:32b")+ end+test "legacy and custom PDF processing preserve the fallback output limit" dowith_env_overrides("LLM_MAX_RESPONSE_TOKENS" => nil) doSetting.stubs(:llm_max_response_tokens).returns(nil)