MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / get_default_provider

Function get_default_provider

web/pgadmin/llm/utils.py:507–540  ·  view source on GitHub ↗

Get the default LLM provider. First checks if LLM is enabled at the system level (config.LLM_ENABLED). If enabled, reads from user preferences (which default to system config). Returns None if disabled at system level or user preference is empty. Returns: The provider

()

Source from the content-addressed store, hash-verified

505
506
507def get_default_provider():
508 """
509 Get the default LLM provider.
510
511 First checks if LLM is enabled at the system level (config.LLM_ENABLED).
512 If enabled, reads from user preferences (which default to system config).
513 Returns None if disabled at system level or user preference is empty.
514
515 Returns:
516 The provider name ('anthropic', 'openai', 'ollama', 'docker')
517 or None if disabled.
518 """
519 # Check master switch first - cannot be overridden by user
520 if not getattr(config, 'LLM_ENABLED', False):
521 return None
522
523 # Valid provider values
524 valid_providers = {'anthropic', 'openai', 'ollama', 'docker'}
525
526 # Get preference value (includes config default if not set by user)
527 try:
528 pref_module = Preferences.module('ai')
529 if pref_module:
530 pref = pref_module.preference('default_provider')
531 if pref:
532 value = pref.get()
533 # Check if it's a valid provider
534 if value and str(value).strip() in valid_providers:
535 return str(value).strip()
536 except Exception:
537 pass
538
539 # No valid provider configured
540 return None
541
542
543def is_llm_enabled_system():

Callers 4

get_llm_clientFunction · 0.90
get_llm_statusFunction · 0.90
is_llm_enabledFunction · 0.85
get_llm_configFunction · 0.85

Calls 3

moduleMethod · 0.80
preferenceMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected