MAESTRO: i18n: extract hard-coded strings from internal/server/ollama.go

Replace 37 hard-coded error/log strings with i18n.T() calls and add
translations for all 10 supported languages (en, de, es, fa, fr, it,
ja, pt-BR, pt-PT, zh). Keys use ollama_ prefix following project
conventions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kayvan Sylvan
2026-02-13 20:49:08 -08:00
parent 66621c5fb2
commit 020656ccdc
11 changed files with 421 additions and 60 deletions

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (leer lassen zum Überspringen):",
"plugin_invalid_boolean_value": "Ungültiger Boolescher Wert: %v",
"plugin_setting_not_valid": "%v=%v ist nicht gültig",
"plugin_invalid_bool": "Ungültiger boolescher Wert: %q"
"plugin_invalid_bool": "Ungültiger boolescher Wert: %q",
"ollama_num_ctx_must_be_finite": "num_ctx muss eine endliche Zahl sein",
"ollama_num_ctx_must_be_integer": "num_ctx muss eine Ganzzahl sein, erhielt Float mit Nachkommastellen",
"ollama_num_ctx_value_out_of_range": "num_ctx Wert außerhalb des Bereichs",
"ollama_num_ctx_must_be_positive": "num_ctx muss positiv sein, erhalten: %d",
"ollama_num_ctx_value_too_large": "num_ctx Wert zu groß: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx muss eine gültige Zahl sein",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx muss eine gültige Zahl sein, erhalten: %s",
"ollama_num_ctx_invalid_type": "num_ctx muss eine Zahl sein, ungültiger Typ erhalten",
"ollama_num_ctx_exceeds_maximum": "num_ctx überschreitet den maximal zulässigen Wert von %d",
"ollama_error_reading_body": "Fehler beim Lesen des Bodys: %v",
"ollama_error_endpoint": "Endpunkt wird getestet",
"ollama_error_unmarshalling_body": "Fehler beim Unmarshalling des Bodys: %v",
"ollama_invalid_num_ctx_in_request": "Ungültiger num_ctx in Anfrage: %v",
"ollama_warning_parse_variables": "Warnung: Fehler beim Parsen von options.variables als JSON: %v",
"ollama_error_marshalling_body": "Fehler beim Marshalling des Bodys: %v",
"ollama_error_building_chat_url": "Fehler beim Erstellen der /chat URL: %v",
"ollama_error_creating_chat_request": "Fehler beim Erstellen der /chat Anfrage: %v",
"ollama_failed_create_request": "Fehler beim Erstellen der Anfrage",
"ollama_error_getting_chat_body": "Fehler beim Abrufen des /chat Bodys: %v",
"ollama_upstream_non_2xx_body_unreadable": "Upstream Fabric Server hat nicht-2xx Status %d zurückgegeben und Body konnte nicht gelesen werden: %v",
"ollama_upstream_non_2xx": "Upstream Fabric Server hat nicht-2xx Status %d zurückgegeben: %s",
"ollama_upstream_returned_status": "Upstream Fabric Server hat Status %d zurückgegeben",
"ollama_error_prefix": "Fehler: %s",
"ollama_error_parse_upstream_response": "Fehler: Upstream-Antwort konnte nicht geparst werden",
"ollama_failed_unmarshal_fabric_response": "Fehler beim Unmarshalling der Fabric Antwort",
"ollama_error_writing_response": "Fehler beim Schreiben der Antwort: %v",
"ollama_error_scanning_body": "Fehler beim Scannen des Bodys: %v",
"ollama_failed_scan_sse_stream": "Fehler beim Scannen des SSE Response Streams: %v",
"ollama_sse_buffer_limit": "SSE Zeile überschreitet 1MB Puffer-Limit - Datenzeile zu groß",
"ollama_warning_no_content": "Warnung: Kein Inhalt vom Upstream Fabric Server erhalten",
"ollama_no_content_from_upstream": "Kein Inhalt vom Upstream Fabric Server erhalten",
"ollama_empty_address": "Leere Adresse",
"ollama_invalid_address": "Ungültige Adresse: %w",
"ollama_invalid_address_missing_host": "Ungültige Adresse: Host fehlt",
"ollama_invalid_address_missing_hostname": "Ungültige Adresse: Hostname fehlt",
"ollama_invalid_address_path_not_allowed": "Ungültige Adresse: Pfadkomponente in bloßer Adresse nicht zulässig"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (leave empty to skip):",
"plugin_invalid_boolean_value": "invalid boolean value: %v",
"plugin_setting_not_valid": "%v=%v, is not valid",
"plugin_invalid_bool": "invalid bool: %q"
"plugin_invalid_bool": "invalid bool: %q",
"ollama_num_ctx_must_be_finite": "num_ctx must be a finite number",
"ollama_num_ctx_must_be_integer": "num_ctx must be an integer, got float with fractional part",
"ollama_num_ctx_value_out_of_range": "num_ctx value out of range",
"ollama_num_ctx_must_be_positive": "num_ctx must be positive, got: %d",
"ollama_num_ctx_value_too_large": "num_ctx value too large: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx must be a valid number",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx must be a valid number, got: %s",
"ollama_num_ctx_invalid_type": "num_ctx must be a number, got invalid type",
"ollama_num_ctx_exceeds_maximum": "num_ctx exceeds maximum allowed value of %d",
"ollama_error_reading_body": "Error reading body: %v",
"ollama_error_endpoint": "testing endpoint",
"ollama_error_unmarshalling_body": "Error unmarshalling body: %v",
"ollama_invalid_num_ctx_in_request": "Invalid num_ctx in request: %v",
"ollama_warning_parse_variables": "Warning: failed to parse options.variables as JSON: %v",
"ollama_error_marshalling_body": "Error marshalling body: %v",
"ollama_error_building_chat_url": "Error building /chat URL: %v",
"ollama_error_creating_chat_request": "Error creating /chat request: %v",
"ollama_failed_create_request": "failed to create request",
"ollama_error_getting_chat_body": "Error getting /chat body: %v",
"ollama_upstream_non_2xx_body_unreadable": "Upstream Fabric server returned non-2xx status %d and body could not be read: %v",
"ollama_upstream_non_2xx": "Upstream Fabric server returned non-2xx status %d: %s",
"ollama_upstream_returned_status": "upstream Fabric server returned status %d",
"ollama_error_prefix": "Error: %s",
"ollama_error_parse_upstream_response": "Error: failed to parse upstream response",
"ollama_failed_unmarshal_fabric_response": "failed to unmarshal Fabric response",
"ollama_error_writing_response": "Error writing response: %v",
"ollama_error_scanning_body": "Error scanning body: %v",
"ollama_failed_scan_sse_stream": "failed to scan SSE response stream: %v",
"ollama_sse_buffer_limit": "SSE line exceeds 1MB buffer limit - data line too large",
"ollama_warning_no_content": "Warning: no content received from upstream Fabric server",
"ollama_no_content_from_upstream": "no content received from upstream Fabric server",
"ollama_empty_address": "empty address",
"ollama_invalid_address": "invalid address: %w",
"ollama_invalid_address_missing_host": "invalid address: missing host",
"ollama_invalid_address_missing_hostname": "invalid address: missing hostname",
"ollama_invalid_address_path_not_allowed": "invalid address: path component not allowed in bare address"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (deja vacío para omitir):",
"plugin_invalid_boolean_value": "valor booleano no válido: %v",
"plugin_setting_not_valid": "%v=%v no es válido",
"plugin_invalid_bool": "bool no válido: %q"
"plugin_invalid_bool": "bool no válido: %q",
"ollama_num_ctx_must_be_finite": "num_ctx debe ser un número finito",
"ollama_num_ctx_must_be_integer": "num_ctx debe ser un entero, se obtuvo float con parte fraccionaria",
"ollama_num_ctx_value_out_of_range": "valor num_ctx fuera de rango",
"ollama_num_ctx_must_be_positive": "num_ctx debe ser positivo, se obtuvo: %d",
"ollama_num_ctx_value_too_large": "valor num_ctx demasiado grande: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx debe ser un número válido",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx debe ser un número válido, se obtuvo: %s",
"ollama_num_ctx_invalid_type": "num_ctx debe ser un número, se obtuvo tipo inválido",
"ollama_num_ctx_exceeds_maximum": "num_ctx excede el valor máximo permitido de %d",
"ollama_error_reading_body": "Error al leer el cuerpo: %v",
"ollama_error_endpoint": "probando endpoint",
"ollama_error_unmarshalling_body": "Error al deserializar el cuerpo: %v",
"ollama_invalid_num_ctx_in_request": "num_ctx inválido en la solicitud: %v",
"ollama_warning_parse_variables": "Advertencia: error al analizar options.variables como JSON: %v",
"ollama_error_marshalling_body": "Error al serializar el cuerpo: %v",
"ollama_error_building_chat_url": "Error al construir la URL /chat: %v",
"ollama_error_creating_chat_request": "Error al crear la solicitud /chat: %v",
"ollama_failed_create_request": "error al crear la solicitud",
"ollama_error_getting_chat_body": "Error al obtener el cuerpo /chat: %v",
"ollama_upstream_non_2xx_body_unreadable": "El servidor Fabric upstream devolvió estado no-2xx %d y el cuerpo no se pudo leer: %v",
"ollama_upstream_non_2xx": "El servidor Fabric upstream devolvió estado no-2xx %d: %s",
"ollama_upstream_returned_status": "el servidor Fabric upstream devolvió estado %d",
"ollama_error_prefix": "Error: %s",
"ollama_error_parse_upstream_response": "Error: no se pudo analizar la respuesta upstream",
"ollama_failed_unmarshal_fabric_response": "error al deserializar la respuesta Fabric",
"ollama_error_writing_response": "Error al escribir la respuesta: %v",
"ollama_error_scanning_body": "Error al escanear el cuerpo: %v",
"ollama_failed_scan_sse_stream": "error al escanear el flujo de respuesta SSE: %v",
"ollama_sse_buffer_limit": "Línea SSE excede el límite de búfer de 1MB - línea de datos demasiado grande",
"ollama_warning_no_content": "Advertencia: no se recibió contenido del servidor Fabric upstream",
"ollama_no_content_from_upstream": "no se recibió contenido del servidor Fabric upstream",
"ollama_empty_address": "dirección vacía",
"ollama_invalid_address": "dirección inválida: %w",
"ollama_invalid_address_missing_host": "dirección inválida: falta el host",
"ollama_invalid_address_missing_hostname": "dirección inválida: falta el nombre de host",
"ollama_invalid_address_path_not_allowed": "dirección inválida: componente de ruta no permitido en dirección simple"
}

View File

@@ -285,5 +285,41 @@
"plugin_question_optional": "%v%v (برای رد کردن خالی بگذارید):",
"plugin_invalid_boolean_value": "مقدار بولی نامعتبر: %v",
"plugin_setting_not_valid": "%v=%v معتبر نیست",
"plugin_invalid_bool": "مقدار bool نامعتبر: %q"
"plugin_invalid_bool": "مقدار bool نامعتبر: %q",
"ollama_num_ctx_must_be_finite": "num_ctx باید یک عدد محدود باشد",
"ollama_num_ctx_must_be_integer": "num_ctx باید یک عدد صحیح باشد، عدد اعشاری با قسمت کسری دریافت شد",
"ollama_num_ctx_value_out_of_range": "مقدار num_ctx خارج از محدوده است",
"ollama_num_ctx_must_be_positive": "num_ctx باید مثبت باشد، دریافت شده: %d",
"ollama_num_ctx_value_too_large": "مقدار num_ctx بیش از حد بزرگ است: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx باید یک عدد معتبر باشد",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx باید یک عدد معتبر باشد، دریافت شده: %s",
"ollama_num_ctx_invalid_type": "num_ctx باید یک عدد باشد، نوع نامعتبر دریافت شد",
"ollama_num_ctx_exceeds_maximum": "num_ctx از حداکثر مقدار مجاز %d فراتر رفته است",
"ollama_error_reading_body": "خطا در خواندن بدنه: %v",
"ollama_error_endpoint": "در حال آزمایش نقطه پایانی",
"ollama_error_unmarshalling_body": "خطا در تجزیه بدنه: %v",
"ollama_invalid_num_ctx_in_request": "num_ctx نامعتبر در درخواست: %v",
"ollama_warning_parse_variables": "هشدار: شکست در تجزیه options.variables به عنوان JSON: %v",
"ollama_error_marshalling_body": "خطا در سریال‌سازی بدنه: %v",
"ollama_error_building_chat_url": "خطا در ساخت URL چت /: %v",
"ollama_error_creating_chat_request": "خطا در ایجاد درخواست /chat: %v",
"ollama_failed_create_request": "ایجاد درخواست ناموفق بود",
"ollama_error_getting_chat_body": "خطا در دریافت بدنه /chat: %v",
"ollama_upstream_non_2xx_body_unreadable": "سرور Fabric بالادستی وضعیت غیر-2xx %d را برگرداند و بدنه قابل خواندن نبود: %v",
"ollama_upstream_non_2xx": "سرور Fabric بالادستی وضعیت غیر-2xx %d را برگرداند: %s",
"ollama_upstream_returned_status": "سرور Fabric بالادستی وضعیت %d را برگرداند",
"ollama_error_prefix": "خطا: %s",
"ollama_error_parse_upstream_response": "خطا: شکست در تجزیه پاسخ بالادستی",
"ollama_failed_unmarshal_fabric_response": "شکست در تجزیه پاسخ Fabric",
"ollama_error_writing_response": "خطا در نوشتن پاسخ: %v",
"ollama_error_scanning_body": "خطا در اسکن بدنه: %v",
"ollama_failed_scan_sse_stream": "شکست در اسکن جریان پاسخ SSE: %v",
"ollama_sse_buffer_limit": "خط SSE از حد بافر 1MB فراتر رفت - خط داده بیش از حد بزرگ است",
"ollama_warning_no_content": "هشدار: هیچ محتوایی از سرور Fabric بالادستی دریافت نشد",
"ollama_no_content_from_upstream": "هیچ محتوایی از سرور Fabric بالادستی دریافت نشد",
"ollama_empty_address": "آدرس خالی",
"ollama_invalid_address": "آدرس نامعتبر: %w",
"ollama_invalid_address_missing_host": "آدرس نامعتبر: میزبان وجود ندارد",
"ollama_invalid_address_missing_hostname": "آدرس نامعتبر: نام میزبان وجود ندارد",
"ollama_invalid_address_path_not_allowed": "آدرس نامعتبر: مؤلفه مسیر در آدرس ساده مجاز نیست"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (laissez vide pour passer) :",
"plugin_invalid_boolean_value": "valeur booléenne invalide : %v",
"plugin_setting_not_valid": "%v=%v n'est pas valide",
"plugin_invalid_bool": "booléen invalide : %q"
"plugin_invalid_bool": "booléen invalide : %q",
"ollama_num_ctx_must_be_finite": "num_ctx doit être un nombre fini",
"ollama_num_ctx_must_be_integer": "num_ctx doit être un entier, float avec partie fractionnaire reçu",
"ollama_num_ctx_value_out_of_range": "valeur num_ctx hors limites",
"ollama_num_ctx_must_be_positive": "num_ctx doit être positif, reçu : %d",
"ollama_num_ctx_value_too_large": "valeur num_ctx trop grande : %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx doit être un nombre valide",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx doit être un nombre valide, reçu : %s",
"ollama_num_ctx_invalid_type": "num_ctx doit être un nombre, type invalide reçu",
"ollama_num_ctx_exceeds_maximum": "num_ctx dépasse la valeur maximale autorisée de %d",
"ollama_error_reading_body": "Erreur lors de la lecture du corps : %v",
"ollama_error_endpoint": "test du point de terminaison",
"ollama_error_unmarshalling_body": "Erreur lors du décodage du corps : %v",
"ollama_invalid_num_ctx_in_request": "num_ctx invalide dans la requête : %v",
"ollama_warning_parse_variables": "Attention : échec de l'analyse de options.variables en JSON : %v",
"ollama_error_marshalling_body": "Erreur lors de l'encodage du corps : %v",
"ollama_error_building_chat_url": "Erreur lors de la construction de l'URL /chat : %v",
"ollama_error_creating_chat_request": "Erreur lors de la création de la requête /chat : %v",
"ollama_failed_create_request": "échec de création de la requête",
"ollama_error_getting_chat_body": "Erreur lors de l'obtention du corps /chat : %v",
"ollama_upstream_non_2xx_body_unreadable": "Le serveur Fabric en amont a renvoyé un statut non-2xx %d et le corps n'a pas pu être lu : %v",
"ollama_upstream_non_2xx": "Le serveur Fabric en amont a renvoyé un statut non-2xx %d : %s",
"ollama_upstream_returned_status": "le serveur Fabric en amont a renvoyé le statut %d",
"ollama_error_prefix": "Erreur : %s",
"ollama_error_parse_upstream_response": "Erreur : échec de l'analyse de la réponse en amont",
"ollama_failed_unmarshal_fabric_response": "échec du décodage de la réponse Fabric",
"ollama_error_writing_response": "Erreur lors de l'écriture de la réponse : %v",
"ollama_error_scanning_body": "Erreur lors de l'analyse du corps : %v",
"ollama_failed_scan_sse_stream": "échec de l'analyse du flux de réponse SSE : %v",
"ollama_sse_buffer_limit": "La ligne SSE dépasse la limite de tampon de 1 Mo - ligne de données trop grande",
"ollama_warning_no_content": "Attention : aucun contenu reçu du serveur Fabric en amont",
"ollama_no_content_from_upstream": "aucun contenu reçu du serveur Fabric en amont",
"ollama_empty_address": "adresse vide",
"ollama_invalid_address": "adresse invalide : %w",
"ollama_invalid_address_missing_host": "adresse invalide : hôte manquant",
"ollama_invalid_address_missing_hostname": "adresse invalide : nom d'hôte manquant",
"ollama_invalid_address_path_not_allowed": "adresse invalide : composant de chemin non autorisé dans l'adresse simple"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (lascia vuoto per saltare):",
"plugin_invalid_boolean_value": "valore booleano non valido: %v",
"plugin_setting_not_valid": "%v=%v non è valido",
"plugin_invalid_bool": "bool non valido: %q"
"plugin_invalid_bool": "bool non valido: %q",
"ollama_num_ctx_must_be_finite": "num_ctx deve essere un numero finito",
"ollama_num_ctx_must_be_integer": "num_ctx deve essere un intero, ricevuto float con parte frazionaria",
"ollama_num_ctx_value_out_of_range": "valore num_ctx fuori intervallo",
"ollama_num_ctx_must_be_positive": "num_ctx deve essere positivo, ricevuto: %d",
"ollama_num_ctx_value_too_large": "valore num_ctx troppo grande: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx deve essere un numero valido",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx deve essere un numero valido, ricevuto: %s",
"ollama_num_ctx_invalid_type": "num_ctx deve essere un numero, ricevuto tipo non valido",
"ollama_num_ctx_exceeds_maximum": "num_ctx supera il valore massimo consentito di %d",
"ollama_error_reading_body": "Errore nella lettura del corpo: %v",
"ollama_error_endpoint": "test dell'endpoint",
"ollama_error_unmarshalling_body": "Errore nella deserializzazione del corpo: %v",
"ollama_invalid_num_ctx_in_request": "num_ctx non valido nella richiesta: %v",
"ollama_warning_parse_variables": "Avviso: impossibile analizzare options.variables come JSON: %v",
"ollama_error_marshalling_body": "Errore nella serializzazione del corpo: %v",
"ollama_error_building_chat_url": "Errore nella costruzione dell'URL /chat: %v",
"ollama_error_creating_chat_request": "Errore nella creazione della richiesta /chat: %v",
"ollama_failed_create_request": "impossibile creare la richiesta",
"ollama_error_getting_chat_body": "Errore nell'ottenere il corpo /chat: %v",
"ollama_upstream_non_2xx_body_unreadable": "Il server Fabric upstream ha restituito stato non-2xx %d e il corpo non è stato leggibile: %v",
"ollama_upstream_non_2xx": "Il server Fabric upstream ha restituito stato non-2xx %d: %s",
"ollama_upstream_returned_status": "il server Fabric upstream ha restituito stato %d",
"ollama_error_prefix": "Errore: %s",
"ollama_error_parse_upstream_response": "Errore: impossibile analizzare la risposta upstream",
"ollama_failed_unmarshal_fabric_response": "impossibile deserializzare la risposta Fabric",
"ollama_error_writing_response": "Errore nella scrittura della risposta: %v",
"ollama_error_scanning_body": "Errore nella scansione del corpo: %v",
"ollama_failed_scan_sse_stream": "impossibile scansionare il flusso di risposta SSE: %v",
"ollama_sse_buffer_limit": "La riga SSE supera il limite del buffer di 1MB - riga di dati troppo grande",
"ollama_warning_no_content": "Avviso: nessun contenuto ricevuto dal server Fabric upstream",
"ollama_no_content_from_upstream": "nessun contenuto ricevuto dal server Fabric upstream",
"ollama_empty_address": "indirizzo vuoto",
"ollama_invalid_address": "indirizzo non valido: %w",
"ollama_invalid_address_missing_host": "indirizzo non valido: host mancante",
"ollama_invalid_address_missing_hostname": "indirizzo non valido: nome host mancante",
"ollama_invalid_address_path_not_allowed": "indirizzo non valido: componente percorso non consentito nell'indirizzo semplice"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (スキップするには空欄のまま):",
"plugin_invalid_boolean_value": "無効なブール値です: %v",
"plugin_setting_not_valid": "%v=%v は無効です",
"plugin_invalid_bool": "無効な bool です: %q"
"plugin_invalid_bool": "無効な bool です: %q",
"ollama_num_ctx_must_be_finite": "num_ctx は有限数である必要があります",
"ollama_num_ctx_must_be_integer": "num_ctx は整数である必要があります。小数部分を持つ浮動小数点数を受け取りました",
"ollama_num_ctx_value_out_of_range": "num_ctx の値が範囲外です",
"ollama_num_ctx_must_be_positive": "num_ctx は正の値である必要があります。受け取った値: %d",
"ollama_num_ctx_value_too_large": "num_ctx の値が大きすぎます: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx は有効な数値である必要があります",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx は有効な数値である必要があります。受け取った値: %s",
"ollama_num_ctx_invalid_type": "num_ctx は数値である必要があります。無効な型を受け取りました",
"ollama_num_ctx_exceeds_maximum": "num_ctx が許可される最大値 %d を超えています",
"ollama_error_reading_body": "ボディの読み取りエラー: %v",
"ollama_error_endpoint": "エンドポイントをテスト中",
"ollama_error_unmarshalling_body": "ボディのアンマーシャリングエラー: %v",
"ollama_invalid_num_ctx_in_request": "リクエストに無効な num_ctx があります: %v",
"ollama_warning_parse_variables": "警告: options.variables を JSON として解析できませんでした: %v",
"ollama_error_marshalling_body": "ボディのマーシャリングエラー: %v",
"ollama_error_building_chat_url": "/chat URL の構築エラー: %v",
"ollama_error_creating_chat_request": "/chat リクエストの作成エラー: %v",
"ollama_failed_create_request": "リクエストの作成に失敗しました",
"ollama_error_getting_chat_body": "/chat ボディの取得エラー: %v",
"ollama_upstream_non_2xx_body_unreadable": "アップストリームの Fabric サーバーが非 2xx ステータス %d を返し、ボディを読み取れませんでした: %v",
"ollama_upstream_non_2xx": "アップストリームの Fabric サーバーが非 2xx ステータス %d を返しました: %s",
"ollama_upstream_returned_status": "アップストリームの Fabric サーバーがステータス %d を返しました",
"ollama_error_prefix": "エラー: %s",
"ollama_error_parse_upstream_response": "エラー: アップストリームのレスポンスを解析できませんでした",
"ollama_failed_unmarshal_fabric_response": "Fabric レスポンスのアンマーシャルに失敗しました",
"ollama_error_writing_response": "レスポンスの書き込みエラー: %v",
"ollama_error_scanning_body": "ボディのスキャンエラー: %v",
"ollama_failed_scan_sse_stream": "SSE レスポンスストリームのスキャンに失敗しました: %v",
"ollama_sse_buffer_limit": "SSE 行が 1MB バッファー制限を超えています - データ行が大きすぎます",
"ollama_warning_no_content": "警告: アップストリームの Fabric サーバーからコンテンツを受信しませんでした",
"ollama_no_content_from_upstream": "アップストリームの Fabric サーバーからコンテンツを受信しませんでした",
"ollama_empty_address": "空のアドレス",
"ollama_invalid_address": "無効なアドレス: %w",
"ollama_invalid_address_missing_host": "無効なアドレス: ホストが不足しています",
"ollama_invalid_address_missing_hostname": "無効なアドレス: ホスト名が不足しています",
"ollama_invalid_address_path_not_allowed": "無効なアドレス: 単純なアドレスにパスコンポーネントは許可されていません"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (deixe em branco para pular):",
"plugin_invalid_boolean_value": "valor booleano inválido: %v",
"plugin_setting_not_valid": "%v=%v não é válido",
"plugin_invalid_bool": "bool inválido: %q"
"plugin_invalid_bool": "bool inválido: %q",
"ollama_num_ctx_must_be_finite": "num_ctx deve ser um número finito",
"ollama_num_ctx_must_be_integer": "num_ctx deve ser um inteiro, recebeu float com parte fracionária",
"ollama_num_ctx_value_out_of_range": "valor num_ctx fora do intervalo",
"ollama_num_ctx_must_be_positive": "num_ctx deve ser positivo, recebeu: %d",
"ollama_num_ctx_value_too_large": "valor num_ctx muito grande: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx deve ser um número válido",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx deve ser um número válido, recebeu: %s",
"ollama_num_ctx_invalid_type": "num_ctx deve ser um número, recebeu tipo inválido",
"ollama_num_ctx_exceeds_maximum": "num_ctx excede o valor máximo permitido de %d",
"ollama_error_reading_body": "Erro ao ler o corpo: %v",
"ollama_error_endpoint": "testando endpoint",
"ollama_error_unmarshalling_body": "Erro ao desserializar o corpo: %v",
"ollama_invalid_num_ctx_in_request": "num_ctx inválido na requisição: %v",
"ollama_warning_parse_variables": "Aviso: falha ao analisar options.variables como JSON: %v",
"ollama_error_marshalling_body": "Erro ao serializar o corpo: %v",
"ollama_error_building_chat_url": "Erro ao construir a URL /chat: %v",
"ollama_error_creating_chat_request": "Erro ao criar a requisição /chat: %v",
"ollama_failed_create_request": "falha ao criar a requisição",
"ollama_error_getting_chat_body": "Erro ao obter o corpo /chat: %v",
"ollama_upstream_non_2xx_body_unreadable": "Servidor Fabric upstream retornou status não-2xx %d e o corpo não pôde ser lido: %v",
"ollama_upstream_non_2xx": "Servidor Fabric upstream retornou status não-2xx %d: %s",
"ollama_upstream_returned_status": "servidor Fabric upstream retornou status %d",
"ollama_error_prefix": "Erro: %s",
"ollama_error_parse_upstream_response": "Erro: falha ao analisar resposta upstream",
"ollama_failed_unmarshal_fabric_response": "falha ao desserializar resposta Fabric",
"ollama_error_writing_response": "Erro ao escrever resposta: %v",
"ollama_error_scanning_body": "Erro ao escanear o corpo: %v",
"ollama_failed_scan_sse_stream": "falha ao escanear fluxo de resposta SSE: %v",
"ollama_sse_buffer_limit": "Linha SSE excede limite de buffer de 1MB - linha de dados muito grande",
"ollama_warning_no_content": "Aviso: nenhum conteúdo recebido do servidor Fabric upstream",
"ollama_no_content_from_upstream": "nenhum conteúdo recebido do servidor Fabric upstream",
"ollama_empty_address": "endereço vazio",
"ollama_invalid_address": "endereço inválido: %w",
"ollama_invalid_address_missing_host": "endereço inválido: host ausente",
"ollama_invalid_address_missing_hostname": "endereço inválido: nome do host ausente",
"ollama_invalid_address_path_not_allowed": "endereço inválido: componente de caminho não permitido em endereço simples"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v (deixe em branco para ignorar):",
"plugin_invalid_boolean_value": "valor booleano inválido: %v",
"plugin_setting_not_valid": "%v=%v não é válido",
"plugin_invalid_bool": "bool inválido: %q"
"plugin_invalid_bool": "bool inválido: %q",
"ollama_num_ctx_must_be_finite": "num_ctx deve ser um número finito",
"ollama_num_ctx_must_be_integer": "num_ctx deve ser um inteiro, recebeu float com parte fracionária",
"ollama_num_ctx_value_out_of_range": "valor num_ctx fora do intervalo",
"ollama_num_ctx_must_be_positive": "num_ctx deve ser positivo, recebeu: %d",
"ollama_num_ctx_value_too_large": "valor num_ctx demasiado grande: %d",
"ollama_num_ctx_must_be_valid_number": "num_ctx deve ser um número válido",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx deve ser um número válido, recebeu: %s",
"ollama_num_ctx_invalid_type": "num_ctx deve ser um número, recebeu tipo inválido",
"ollama_num_ctx_exceeds_maximum": "num_ctx excede o valor máximo permitido de %d",
"ollama_error_reading_body": "Erro ao ler o corpo: %v",
"ollama_error_endpoint": "a testar endpoint",
"ollama_error_unmarshalling_body": "Erro ao desserializar o corpo: %v",
"ollama_invalid_num_ctx_in_request": "num_ctx inválido no pedido: %v",
"ollama_warning_parse_variables": "Aviso: falha ao analisar options.variables como JSON: %v",
"ollama_error_marshalling_body": "Erro ao serializar o corpo: %v",
"ollama_error_building_chat_url": "Erro ao construir a URL /chat: %v",
"ollama_error_creating_chat_request": "Erro ao criar o pedido /chat: %v",
"ollama_failed_create_request": "falha ao criar o pedido",
"ollama_error_getting_chat_body": "Erro ao obter o corpo /chat: %v",
"ollama_upstream_non_2xx_body_unreadable": "Servidor Fabric upstream retornou estado não-2xx %d e o corpo não pôde ser lido: %v",
"ollama_upstream_non_2xx": "Servidor Fabric upstream retornou estado não-2xx %d: %s",
"ollama_upstream_returned_status": "servidor Fabric upstream retornou estado %d",
"ollama_error_prefix": "Erro: %s",
"ollama_error_parse_upstream_response": "Erro: falha ao analisar resposta upstream",
"ollama_failed_unmarshal_fabric_response": "falha ao desserializar resposta Fabric",
"ollama_error_writing_response": "Erro ao escrever resposta: %v",
"ollama_error_scanning_body": "Erro ao analisar o corpo: %v",
"ollama_failed_scan_sse_stream": "falha ao analisar fluxo de resposta SSE: %v",
"ollama_sse_buffer_limit": "Linha SSE excede limite de buffer de 1MB - linha de dados demasiado grande",
"ollama_warning_no_content": "Aviso: nenhum conteúdo recebido do servidor Fabric upstream",
"ollama_no_content_from_upstream": "nenhum conteúdo recebido do servidor Fabric upstream",
"ollama_empty_address": "endereço vazio",
"ollama_invalid_address": "endereço inválido: %w",
"ollama_invalid_address_missing_host": "endereço inválido: host ausente",
"ollama_invalid_address_missing_hostname": "endereço inválido: nome do host ausente",
"ollama_invalid_address_path_not_allowed": "endereço inválido: componente de caminho não permitido em endereço simples"
}

View File

@@ -293,5 +293,41 @@
"plugin_question_optional": "%v%v留空以跳过",
"plugin_invalid_boolean_value": "无效的布尔值:%v",
"plugin_setting_not_valid": "%v=%v 无效",
"plugin_invalid_bool": "无效的 bool%q"
"plugin_invalid_bool": "无效的 bool%q",
"ollama_num_ctx_must_be_finite": "num_ctx 必须是有限数",
"ollama_num_ctx_must_be_integer": "num_ctx 必须是整数,收到带小数部分的浮点数",
"ollama_num_ctx_value_out_of_range": "num_ctx 值超出范围",
"ollama_num_ctx_must_be_positive": "num_ctx 必须为正数,收到:%d",
"ollama_num_ctx_value_too_large": "num_ctx 值过大:%d",
"ollama_num_ctx_must_be_valid_number": "num_ctx 必须是有效的数字",
"ollama_num_ctx_must_be_valid_number_got": "num_ctx 必须是有效的数字,收到:%s",
"ollama_num_ctx_invalid_type": "num_ctx 必须是数字,收到无效类型",
"ollama_num_ctx_exceeds_maximum": "num_ctx 超过允许的最大值 %d",
"ollama_error_reading_body": "读取正文时出错:%v",
"ollama_error_endpoint": "正在测试端点",
"ollama_error_unmarshalling_body": "解析正文时出错:%v",
"ollama_invalid_num_ctx_in_request": "请求中的 num_ctx 无效:%v",
"ollama_warning_parse_variables": "警告:无法将 options.variables 解析为 JSON%v",
"ollama_error_marshalling_body": "序列化正文时出错:%v",
"ollama_error_building_chat_url": "构建 /chat URL 时出错:%v",
"ollama_error_creating_chat_request": "创建 /chat 请求时出错:%v",
"ollama_failed_create_request": "创建请求失败",
"ollama_error_getting_chat_body": "获取 /chat 正文时出错:%v",
"ollama_upstream_non_2xx_body_unreadable": "上游 Fabric 服务器返回非 2xx 状态 %d 且无法读取正文:%v",
"ollama_upstream_non_2xx": "上游 Fabric 服务器返回非 2xx 状态 %d%s",
"ollama_upstream_returned_status": "上游 Fabric 服务器返回状态 %d",
"ollama_error_prefix": "错误:%s",
"ollama_error_parse_upstream_response": "错误:无法解析上游响应",
"ollama_failed_unmarshal_fabric_response": "解析 Fabric 响应失败",
"ollama_error_writing_response": "写入响应时出错:%v",
"ollama_error_scanning_body": "扫描正文时出错:%v",
"ollama_failed_scan_sse_stream": "扫描 SSE 响应流失败:%v",
"ollama_sse_buffer_limit": "SSE 行超过 1MB 缓冲区限制 - 数据行过大",
"ollama_warning_no_content": "警告:未从上游 Fabric 服务器收到内容",
"ollama_no_content_from_upstream": "未从上游 Fabric 服务器收到内容",
"ollama_empty_address": "地址为空",
"ollama_invalid_address": "无效地址:%w",
"ollama_invalid_address_missing_host": "无效地址:缺少主机",
"ollama_invalid_address_missing_hostname": "无效地址:缺少主机名",
"ollama_invalid_address_path_not_allowed": "无效地址:简单地址中不允许路径组件"
}

View File

@@ -15,6 +15,7 @@ import (
"time"
"github.com/danielmiessler/fabric/internal/core"
"github.com/danielmiessler/fabric/internal/i18n"
"github.com/gin-gonic/gin"
)
@@ -108,28 +109,28 @@ func parseOllamaNumCtx(options map[string]any) (int, error) {
switch v := val.(type) {
case float64:
if math.IsNaN(v) || math.IsInf(v, 0) {
return 0, fmt.Errorf("num_ctx must be a finite number")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_must_be_finite"))
}
if math.Trunc(v) != v {
return 0, fmt.Errorf("num_ctx must be an integer, got float with fractional part")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_must_be_integer"))
}
// Check for overflow on 32-bit systems (negative values handled by validation at line 166)
if v > float64(maxInt) {
return 0, fmt.Errorf("num_ctx value out of range")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_value_out_of_range"))
}
contextLength = int(v)
case float32:
f64 := float64(v)
if math.IsNaN(f64) || math.IsInf(f64, 0) {
return 0, fmt.Errorf("num_ctx must be a finite number")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_must_be_finite"))
}
if math.Trunc(f64) != f64 {
return 0, fmt.Errorf("num_ctx must be an integer, got float with fractional part")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_must_be_integer"))
}
// Check for overflow on 32-bit systems (negative values handled by validation at line 177)
if f64 > float64(maxInt) {
return 0, fmt.Errorf("num_ctx value out of range")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_value_out_of_range"))
}
contextLength = int(v)
@@ -138,23 +139,23 @@ func parseOllamaNumCtx(options map[string]any) (int, error) {
case int64:
if v < 0 {
return 0, fmt.Errorf("num_ctx must be positive, got: %d", v)
return 0, fmt.Errorf(i18n.T("ollama_num_ctx_must_be_positive"), v)
}
if v > maxInt {
return 0, fmt.Errorf("num_ctx value too large: %d", v)
return 0, fmt.Errorf(i18n.T("ollama_num_ctx_value_too_large"), v)
}
contextLength = int(v)
case json.Number:
i64, err := v.Int64()
if err != nil {
return 0, fmt.Errorf("num_ctx must be a valid number")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_must_be_valid_number"))
}
if i64 < 0 {
return 0, fmt.Errorf("num_ctx must be positive, got: %d", i64)
return 0, fmt.Errorf(i18n.T("ollama_num_ctx_must_be_positive"), i64)
}
if i64 > maxInt {
return 0, fmt.Errorf("num_ctx value too large: %d", i64)
return 0, fmt.Errorf(i18n.T("ollama_num_ctx_value_too_large"), i64)
}
contextLength = int(i64)
@@ -166,21 +167,21 @@ func parseOllamaNumCtx(options map[string]any) (int, error) {
if len(v) > 50 {
errVal = v[:50] + "..."
}
return 0, fmt.Errorf("num_ctx must be a valid number, got: %s", errVal)
return 0, fmt.Errorf(i18n.T("ollama_num_ctx_must_be_valid_number_got"), errVal)
}
contextLength = parsed
default:
return 0, fmt.Errorf("num_ctx must be a number, got invalid type")
return 0, fmt.Errorf("%s", i18n.T("ollama_num_ctx_invalid_type"))
}
if contextLength <= 0 {
return 0, fmt.Errorf("num_ctx must be positive, got: %d", contextLength)
return 0, fmt.Errorf(i18n.T("ollama_num_ctx_must_be_positive"), contextLength)
}
const maxContextLength = 1000000
if contextLength > maxContextLength {
return 0, fmt.Errorf("num_ctx exceeds maximum allowed value of %d", maxContextLength)
return 0, fmt.Errorf(i18n.T("ollama_num_ctx_exceeds_maximum"), maxContextLength)
}
return contextLength, nil
@@ -257,22 +258,22 @@ func (f APIConvert) ollamaTags(c *gin.Context) {
func (f APIConvert) ollamaChat(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body)
if err != nil {
log.Printf("Error reading body: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "testing endpoint"})
log.Printf(i18n.T("ollama_error_reading_body"), err)
c.JSON(http.StatusInternalServerError, gin.H{"error": i18n.T("ollama_error_endpoint")})
return
}
var prompt OllamaRequestBody
err = json.Unmarshal(body, &prompt)
if err != nil {
log.Printf("Error unmarshalling body: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "testing endpoint"})
log.Printf(i18n.T("ollama_error_unmarshalling_body"), err)
c.JSON(http.StatusInternalServerError, gin.H{"error": i18n.T("ollama_error_endpoint")})
return
}
// Extract and validate num_ctx from options
numCtx, err := parseOllamaNumCtx(prompt.Options)
if err != nil {
log.Printf("Invalid num_ctx in request: %v", err)
log.Printf(i18n.T("ollama_invalid_num_ctx_in_request"), err)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
@@ -289,7 +290,7 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
case string:
// Parse JSON string into map
if err := json.Unmarshal([]byte(v), &variables); err != nil {
log.Printf("Warning: failed to parse options.variables as JSON: %v", err)
log.Printf(i18n.T("ollama_warning_parse_variables"), err)
}
case map[string]any:
// Convert map[string]any to map[string]string
@@ -332,21 +333,21 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
fabricChatReq, err := json.Marshal(chat)
if err != nil {
log.Printf("Error marshalling body: %v", err)
log.Printf(i18n.T("ollama_error_marshalling_body"), err)
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
var req *http.Request
baseURL, err := buildFabricChatURL(*f.addr)
if err != nil {
log.Printf("Error building /chat URL: %v", err)
log.Printf(i18n.T("ollama_error_building_chat_url"), err)
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
req, err = http.NewRequest("POST", fmt.Sprintf("%s/chat", baseURL), bytes.NewBuffer(fabricChatReq))
if err != nil {
log.Printf("Error creating /chat request: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create request"})
log.Printf(i18n.T("ollama_error_creating_chat_request"), err)
c.JSON(http.StatusInternalServerError, gin.H{"error": i18n.T("ollama_failed_create_request")})
return
}
@@ -354,7 +355,7 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
fabricRes, err := http.DefaultClient.Do(req)
if err != nil {
log.Printf("Error getting /chat body: %v", err)
log.Printf(i18n.T("ollama_error_getting_chat_body"), err)
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
@@ -363,14 +364,14 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
if fabricRes.StatusCode < http.StatusOK || fabricRes.StatusCode >= http.StatusMultipleChoices {
bodyBytes, readErr := io.ReadAll(fabricRes.Body)
if readErr != nil {
log.Printf("Upstream Fabric server returned non-2xx status %d and body could not be read: %v", fabricRes.StatusCode, readErr)
log.Printf(i18n.T("ollama_upstream_non_2xx_body_unreadable"), fabricRes.StatusCode, readErr)
} else {
log.Printf("Upstream Fabric server returned non-2xx status %d: %s", fabricRes.StatusCode, string(bodyBytes))
log.Printf(i18n.T("ollama_upstream_non_2xx"), fabricRes.StatusCode, string(bodyBytes))
}
errorMessage := fmt.Sprintf("upstream Fabric server returned status %d", fabricRes.StatusCode)
errorMessage := fmt.Sprintf(i18n.T("ollama_upstream_returned_status"), fabricRes.StatusCode)
if prompt.Stream {
_ = writeOllamaResponse(c, prompt.Model, fmt.Sprintf("Error: %s", errorMessage), true)
_ = writeOllamaResponse(c, prompt.Model, fmt.Sprintf(i18n.T("ollama_error_prefix"), errorMessage), true)
} else {
c.JSON(fabricRes.StatusCode, gin.H{"error": errorMessage})
}
@@ -392,19 +393,19 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
payload := strings.TrimPrefix(line, "data: ")
var fabricResponse FabricResponseFormat
if err := json.Unmarshal([]byte(payload), &fabricResponse); err != nil {
log.Printf("Error unmarshalling body: %v", err)
log.Printf(i18n.T("ollama_error_unmarshalling_body"), err)
if prompt.Stream {
// In streaming mode, send the error in the same streaming format
_ = writeOllamaResponse(c, prompt.Model, "Error: failed to parse upstream response", true)
_ = writeOllamaResponse(c, prompt.Model, i18n.T("ollama_error_parse_upstream_response"), true)
} else {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to unmarshal Fabric response"})
c.JSON(http.StatusInternalServerError, gin.H{"error": i18n.T("ollama_failed_unmarshal_fabric_response")})
}
return
}
if fabricResponse.Type == "error" {
if prompt.Stream {
// In streaming mode, propagate the upstream error via a final streaming chunk
_ = writeOllamaResponse(c, prompt.Model, fmt.Sprintf("Error: %s", fabricResponse.Content), true)
_ = writeOllamaResponse(c, prompt.Model, fmt.Sprintf(i18n.T("ollama_error_prefix"), fabricResponse.Content), true)
} else {
c.JSON(http.StatusInternalServerError, gin.H{"error": fabricResponse.Content})
}
@@ -416,21 +417,21 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
contentBuilder.WriteString(fabricResponse.Content)
if prompt.Stream {
if err := writeOllamaResponse(c, prompt.Model, fabricResponse.Content, false); err != nil {
log.Printf("Error writing response: %v", err)
log.Printf(i18n.T("ollama_error_writing_response"), err)
return
}
}
}
if err := scanner.Err(); err != nil {
log.Printf("Error scanning body: %v", err)
errorMsg := fmt.Sprintf("failed to scan SSE response stream: %v", err)
log.Printf(i18n.T("ollama_error_scanning_body"), err)
errorMsg := fmt.Sprintf(i18n.T("ollama_failed_scan_sse_stream"), err)
// Check for buffer size exceeded error
if strings.Contains(err.Error(), "token too long") {
errorMsg = "SSE line exceeds 1MB buffer limit - data line too large"
errorMsg = i18n.T("ollama_sse_buffer_limit")
}
if prompt.Stream {
// In streaming mode, send the error in the same streaming format
_ = writeOllamaResponse(c, prompt.Model, fmt.Sprintf("Error: %s", errorMsg), true)
_ = writeOllamaResponse(c, prompt.Model, fmt.Sprintf(i18n.T("ollama_error_prefix"), errorMsg), true)
} else {
c.JSON(http.StatusInternalServerError, gin.H{"error": errorMsg})
}
@@ -442,10 +443,10 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
// Check if we received any content from upstream
if contentBuilder.Len() == 0 {
log.Printf("Warning: no content received from upstream Fabric server")
log.Printf("%s", i18n.T("ollama_warning_no_content"))
// In non-streaming mode, treat absence of content as an error
if !prompt.Stream {
c.JSON(http.StatusBadGateway, gin.H{"error": "no content received from upstream Fabric server"})
c.JSON(http.StatusBadGateway, gin.H{"error": i18n.T("ollama_no_content_from_upstream")})
return
}
}
@@ -458,7 +459,7 @@ func (f APIConvert) ollamaChat(c *gin.Context) {
finalResponse := buildFinalOllamaResponse(prompt.Model, "", duration)
if err := writeOllamaResponseStruct(c, finalResponse); err != nil {
log.Printf("Error writing response: %v", err)
log.Printf(i18n.T("ollama_error_writing_response"), err)
}
}
@@ -492,18 +493,18 @@ func buildFinalOllamaResponse(model string, content string, duration int64) Olla
// contains a path component.
func buildFabricChatURL(addr string) (string, error) {
if addr == "" {
return "", fmt.Errorf("empty address")
return "", fmt.Errorf("%s", i18n.T("ollama_empty_address"))
}
if strings.HasPrefix(addr, "http://") || strings.HasPrefix(addr, "https://") {
parsed, err := url.Parse(addr)
if err != nil {
return "", fmt.Errorf("invalid address: %w", err)
return "", fmt.Errorf(i18n.T("ollama_invalid_address"), err)
}
if parsed.Host == "" {
return "", fmt.Errorf("invalid address: missing host")
return "", fmt.Errorf("%s", i18n.T("ollama_invalid_address_missing_host"))
}
if strings.HasPrefix(parsed.Host, ":") {
return "", fmt.Errorf("invalid address: missing hostname")
return "", fmt.Errorf("%s", i18n.T("ollama_invalid_address_missing_hostname"))
}
return strings.TrimRight(parsed.String(), "/"), nil
}
@@ -513,17 +514,17 @@ func buildFabricChatURL(addr string) (string, error) {
// Validate bare addresses (without http/https prefix)
parsed, err := url.Parse("http://" + addr)
if err != nil {
return "", fmt.Errorf("invalid address: %w", err)
return "", fmt.Errorf(i18n.T("ollama_invalid_address"), err)
}
if parsed.Host == "" {
return "", fmt.Errorf("invalid address: missing host")
return "", fmt.Errorf("%s", i18n.T("ollama_invalid_address_missing_host"))
}
if strings.HasPrefix(parsed.Host, ":") {
return "", fmt.Errorf("invalid address: missing hostname")
return "", fmt.Errorf("%s", i18n.T("ollama_invalid_address_missing_hostname"))
}
// Bare addresses should be host[:port] only - reject path components
if parsed.Path != "" && parsed.Path != "/" {
return "", fmt.Errorf("invalid address: path component not allowed in bare address")
return "", fmt.Errorf("%s", i18n.T("ollama_invalid_address_path_not_allowed"))
}
return strings.TrimRight(parsed.String(), "/"), nil
}