Merge pull request #2912 from BerriAI/litellm_ui_qa

[UI] QA Improvements to adding callbacks, models
This commit is contained in:
Ishaan Jaff 2024-04-09 07:34:05 -07:00 committed by GitHub
commit 6463c1ec93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1835,26 +1835,8 @@ class ProxyConfig:
return config
async def save_config(self, new_config: dict):
global prisma_client, llm_router, user_config_file_path, llm_model_list, general_settings
global prisma_client, general_settings, user_config_file_path
# Load existing config
backup_config = await self.get_config()
# update Router - verifies if this is a valid config
try:
(
llm_router,
llm_model_list,
general_settings,
) = await proxy_config.load_config(
router=llm_router, config_file_path=user_config_file_path
)
except Exception as e:
traceback.print_exc()
# Revert to old config instead
with open(f"{user_config_file_path}", "w") as config_file:
yaml.dump(backup_config, config_file, default_flow_style=False)
raise HTTPException(status_code=400, detail="Invalid config passed in")
## DB - writes valid config to db
"""
- Do not write restricted params like 'api_key' to the database
@ -6930,7 +6912,7 @@ async def add_new_model(
model_params: Deployment,
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
):
global llm_router, llm_model_list, general_settings, user_config_file_path, proxy_config, prisma_client, master_key, store_model_in_db
global llm_router, llm_model_list, general_settings, user_config_file_path, proxy_config, prisma_client, master_key, store_model_in_db, proxy_logging_obj
try:
import base64
@ -6969,6 +6951,11 @@ async def add_new_model(
"updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name,
}
)
await proxy_config.add_deployment(
prisma_client=prisma_client, proxy_logging_obj=proxy_logging_obj
)
else:
raise HTTPException(
status_code=500,
@ -7987,8 +7974,6 @@ async def update_config(config_info: ConfigYAML):
# Load existing config
config = await proxy_config.get_config()
backup_config = copy.deepcopy(config)
verbose_proxy_logger.debug("Loaded config: %s", config)
# update the general settings