Commit ab635c6b authored by Your Name's avatar Your Name

Fix deprecated get_database() call and dict config access errors

parent a5210aaa
......@@ -1004,9 +1004,14 @@ def get_context_config_for_model(
# Step 1: Get provider-level defaults and model-specific config
model_specific_config = None
if provider_config:
# Try to find model-specific config in provider
if hasattr(provider_config, 'models') and provider_config.models:
for model in provider_config.models:
# Handle both dict (user) and object (global) config formats
if isinstance(provider_config, dict):
models = provider_config.get('models', [])
else:
models = provider_config.models if hasattr(provider_config, 'models') else []
if models:
for model in models:
# Handle both Pydantic objects and dictionaries
model_name_value = model.name if hasattr(model, 'name') else model.get('name')
if model_name_value == model_name:
......
......@@ -124,8 +124,8 @@ class KiloProviderHandler(BaseProviderHandler):
# Regular user: ONLY use database credentials, NO file fallback
try:
from ..database import get_database
db = get_database()
from ..database import DatabaseRegistry
db = DatabaseRegistry.get_config_database()
if db:
db_creds = db.get_user_oauth2_credentials(
user_id=self.user_id,
......
......@@ -168,8 +168,14 @@ def get_max_request_tokens_for_model(
return max_tokens
# Then check provider models config
if hasattr(provider_config, 'models') and provider_config.models:
for model in provider_config.models:
# Handle both dict (user) and object (global) config formats
if isinstance(provider_config, dict):
models = provider_config.get('models', [])
else:
models = provider_config.models if hasattr(provider_config, 'models') else []
if models:
for model in models:
# Handle both Pydantic objects and dictionaries
model_name_value = model.name if hasattr(model, 'name') else model.get('name')
if model_name_value == model_name:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment