@@ -157,7 +157,7 @@ async def send_request(
157157 log .error (f'Failed to parse error response: { e } ' )
158158 raise HTTPException (
159159 status_code = r .status ,
160- detail = 'Open WebUI: Server Connection Error' ,
160+ detail = ERROR_MESSAGES . SERVER_CONNECTION_ERROR ,
161161 )
162162
163163 r .raise_for_status ()
@@ -184,7 +184,7 @@ async def send_request(
184184 except Exception as e :
185185 raise HTTPException (
186186 status_code = r .status if r else 500 ,
187- detail = f'Ollama: { e } ' if str (e ) else 'Open WebUI: Server Connection Error' ,
187+ detail = f'Ollama: { e } ' if str (e ) else ERROR_MESSAGES . SERVER_CONNECTION_ERROR ,
188188 )
189189 finally :
190190 if not streaming :
@@ -251,7 +251,7 @@ async def verify_connection(form_data: ConnectionVerificationForm, user=Depends(
251251 return data
252252 except aiohttp .ClientError as e :
253253 log .exception (f'Client error: { str (e )} ' )
254- raise HTTPException (status_code = 500 , detail = 'Open WebUI: Server Connection Error' )
254+ raise HTTPException (status_code = 500 , detail = ERROR_MESSAGES . SERVER_CONNECTION_ERROR )
255255 except Exception as e :
256256 log .exception (f'Unexpected error: { e } ' )
257257 error_detail = f'Unexpected error: { str (e )} '
@@ -428,7 +428,7 @@ async def get_filtered_models(models, user, db=None):
428428@router .get ('/api/tags/{url_idx}' )
429429async def get_ollama_tags (request : Request , url_idx : Optional [int ] = None , user = Depends (get_verified_user )):
430430 if not request .app .state .config .ENABLE_OLLAMA_API :
431- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
431+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
432432
433433 models = []
434434
@@ -621,7 +621,7 @@ async def pull_model(
621621 user = Depends (get_admin_user ),
622622):
623623 if not request .app .state .config .ENABLE_OLLAMA_API :
624- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
624+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
625625
626626 form_data = form_data .model_dump (exclude_none = True )
627627 form_data ['model' ] = form_data .get ('model' , form_data .get ('name' ))
@@ -656,7 +656,7 @@ async def push_model(
656656 user = Depends (get_admin_user ),
657657):
658658 if not request .app .state .config .ENABLE_OLLAMA_API :
659- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
659+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
660660
661661 if url_idx is None :
662662 await get_all_models (request , user = user )
@@ -699,7 +699,7 @@ async def create_model(
699699 user = Depends (get_admin_user ),
700700):
701701 if not request .app .state .config .ENABLE_OLLAMA_API :
702- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
702+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
703703
704704 log .debug (f'form_data: { form_data } ' )
705705 url = request .app .state .config .OLLAMA_BASE_URLS [url_idx ]
@@ -727,7 +727,7 @@ async def copy_model(
727727 user = Depends (get_admin_user ),
728728):
729729 if not request .app .state .config .ENABLE_OLLAMA_API :
730- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
730+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
731731
732732 if url_idx is None :
733733 await get_all_models (request , user = user )
@@ -762,7 +762,7 @@ async def delete_model(
762762 user = Depends (get_admin_user ),
763763):
764764 if not request .app .state .config .ENABLE_OLLAMA_API :
765- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
765+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
766766
767767 form_data = form_data .model_dump (exclude_none = True )
768768 form_data ['model' ] = form_data .get ('model' , form_data .get ('name' ))
@@ -797,7 +797,7 @@ async def delete_model(
797797@router .post ('/api/show' )
798798async def show_model_info (request : Request , form_data : ModelNameForm , user = Depends (get_verified_user )):
799799 if not request .app .state .config .ENABLE_OLLAMA_API :
800- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
800+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
801801
802802 form_data = form_data .model_dump (exclude_none = True )
803803 form_data ['model' ] = form_data .get ('model' , form_data .get ('name' ))
@@ -850,7 +850,7 @@ async def embed(
850850 user = Depends (get_verified_user ),
851851):
852852 if not request .app .state .config .ENABLE_OLLAMA_API :
853- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
853+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
854854
855855 log .info (f'generate_ollama_batch_embeddings { form_data } ' )
856856
@@ -909,7 +909,7 @@ async def embeddings(
909909 user = Depends (get_verified_user ),
910910):
911911 if not request .app .state .config .ENABLE_OLLAMA_API :
912- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
912+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
913913
914914 log .info (f'generate_ollama_embeddings { form_data } ' )
915915
@@ -976,7 +976,7 @@ async def generate_completion(
976976 user = Depends (get_verified_user ),
977977):
978978 if not request .app .state .config .ENABLE_OLLAMA_API :
979- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
979+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
980980
981981 # Enforce per-model access control
982982 await check_model_access (user , await Models .get_model_by_id (form_data .model ), BYPASS_MODEL_ACCESS_CONTROL )
@@ -1067,7 +1067,7 @@ async def generate_chat_completion(
10671067 bypass_system_prompt : bool = False ,
10681068):
10691069 if not request .app .state .config .ENABLE_OLLAMA_API :
1070- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
1070+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
10711071
10721072 # NOTE: We intentionally do NOT use Depends(get_async_session) here.
10731073 # Database operations (get_model_by_id, AccessGrants.has_access) manage their own short-lived sessions.
@@ -1313,7 +1313,7 @@ async def generate_anthropic_messages(
13131313 See https://docs.ollama.com/api/anthropic-compatibility
13141314 """
13151315 if not request .app .state .config .ENABLE_OLLAMA_API :
1316- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
1316+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
13171317
13181318 payload = {** form_data }
13191319 model_id = payload .get ('model' , '' )
@@ -1371,7 +1371,7 @@ async def generate_responses(
13711371 See https://ollama.com/blog/responses-api
13721372 """
13731373 if not request .app .state .config .ENABLE_OLLAMA_API :
1374- raise HTTPException (status_code = 503 , detail = 'Ollama API is disabled' )
1374+ raise HTTPException (status_code = 503 , detail = ERROR_MESSAGES . OLLAMA_API_DISABLED )
13751375
13761376 payload = form_data .model_dump ()
13771377 model_id = form_data .model
@@ -1396,13 +1396,13 @@ async def generate_responses(
13961396 ):
13971397 raise HTTPException (
13981398 status_code = 403 ,
1399- detail = 'Model not found' ,
1399+ detail = ERROR_MESSAGES . MODEL_NOT_FOUND () ,
14001400 )
14011401 else :
14021402 if user .role != 'admin' :
14031403 raise HTTPException (
14041404 status_code = 403 ,
1405- detail = 'Model not found' ,
1405+ detail = ERROR_MESSAGES . MODEL_NOT_FOUND () ,
14061406 )
14071407
14081408 url , url_idx = await get_ollama_url (request , payload ['model' ], url_idx )
0 commit comments