API: Don't fallback to default values on model load request

It's best to pass them down the config stack.

API/User config.yml -> model config.yml -> model config.json -> fallback.

Doing this allows for seamless flow and yielding control to each
member in the stack.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-08-30 12:10:48 -04:00 committed by Brian Dashore
parent 4452d6f665
commit a96fa5f138
4 changed files with 19 additions and 17 deletions

View file

@ -149,7 +149,7 @@ async def unload_embedding_model():
embeddings_container = None
def get_config_default(key: str, fallback=None, model_type: str = "model"):
def get_config_default(key: str, model_type: str = "model"):
"""Fetches a default value from model config if allowed by the user."""
model_config = config.model_config()
@ -162,14 +162,12 @@ def get_config_default(key: str, fallback=None, model_type: str = "model"):
# Is this a draft model load parameter?
if model_type == "draft":
draft_config = config.draft_model_config()
return unwrap(draft_config.get(key), fallback)
return draft_config.get(key)
elif model_type == "embedding":
embeddings_config = config.embeddings_config()
return unwrap(embeddings_config.get(key), fallback)
return embeddings_config.get(key)
else:
return unwrap(model_config.get(key), fallback)
else:
return fallback
return model_config.get(key)
async def check_model_container():