forked from open-webui/open-webui
		
	fix: openai issue
This commit is contained in:
		
							parent
							
								
									f051b366e3
								
							
						
					
					
						commit
						7bc0c09b25
					
				
					 5 changed files with 108 additions and 21 deletions
				
			
		|  | @ -1,7 +1,7 @@ | |||
| from fastapi import FastAPI, Depends | ||||
| from fastapi.routing import APIRoute | ||||
| from fastapi.middleware.cors import CORSMiddleware | ||||
| from apps.web.routers import auths, users, chats, modelfiles, utils | ||||
| from apps.web.routers import auths, users, chats, modelfiles, configs, utils | ||||
| from config import WEBUI_VERSION, WEBUI_AUTH | ||||
| 
 | ||||
| app = FastAPI() | ||||
|  | @ -9,6 +9,7 @@ app = FastAPI() | |||
| origins = ["*"] | ||||
| 
 | ||||
| app.state.ENABLE_SIGNUP = True | ||||
| app.state.DEFAULT_MODELS = "llava:13b" | ||||
| 
 | ||||
| app.add_middleware( | ||||
|     CORSMiddleware, | ||||
|  | @ -19,13 +20,18 @@ app.add_middleware( | |||
| ) | ||||
| 
 | ||||
| app.include_router(auths.router, prefix="/auths", tags=["auths"]) | ||||
| 
 | ||||
| app.include_router(users.router, prefix="/users", tags=["users"]) | ||||
| app.include_router(chats.router, prefix="/chats", tags=["chats"]) | ||||
| app.include_router(modelfiles.router, prefix="/modelfiles", tags=["modelfiles"]) | ||||
| app.include_router(configs.router, prefix="/configs", tags=["configs"]) | ||||
| app.include_router(utils.router, prefix="/utils", tags=["utils"]) | ||||
| 
 | ||||
| 
 | ||||
| @app.get("/") | ||||
| async def get_status(): | ||||
|     return {"status": True, "version": WEBUI_VERSION, "auth": WEBUI_AUTH} | ||||
|     return { | ||||
|         "status": True, | ||||
|         "version": WEBUI_VERSION, | ||||
|         "auth": WEBUI_AUTH, | ||||
|         "default_models": app.state.DEFAULT_MODELS, | ||||
|     } | ||||
|  |  | |||
							
								
								
									
										41
									
								
								backend/apps/web/routers/configs.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								backend/apps/web/routers/configs.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | |||
| from fastapi import Response, Request | ||||
| from fastapi import Depends, FastAPI, HTTPException, status | ||||
| from datetime import datetime, timedelta | ||||
| from typing import List, Union | ||||
| 
 | ||||
| from fastapi import APIRouter | ||||
| from pydantic import BaseModel | ||||
| import time | ||||
| import uuid | ||||
| 
 | ||||
| from apps.web.models.users import Users | ||||
| 
 | ||||
| 
 | ||||
| from utils.utils import get_password_hash, get_current_user, create_token | ||||
| from utils.misc import get_gravatar_url, validate_email_format | ||||
| from constants import ERROR_MESSAGES | ||||
| 
 | ||||
| router = APIRouter() | ||||
| 
 | ||||
| 
 | ||||
| class SetDefaultModelsForm(BaseModel): | ||||
|     models: str | ||||
| 
 | ||||
| 
 | ||||
| ############################ | ||||
| # SetDefaultModels | ||||
| ############################ | ||||
| 
 | ||||
| 
 | ||||
| @router.post("/default/models", response_model=str) | ||||
| async def set_global_default_models( | ||||
|     request: Request, form_data: SetDefaultModelsForm, user=Depends(get_current_user) | ||||
| ): | ||||
|     if user.role == "admin": | ||||
|         request.app.state.DEFAULT_MODELS = form_data.models | ||||
|         return request.app.state.DEFAULT_MODELS | ||||
|     else: | ||||
|         raise HTTPException( | ||||
|             status_code=status.HTTP_403_FORBIDDEN, | ||||
|             detail=ERROR_MESSAGES.ACCESS_PROHIBITED, | ||||
|         ) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek