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

Method validate_connection

web/pgadmin/llm/client.py:120–138  ·  view source on GitHub ↗

Validate the connection to the LLM provider. Returns: Tuple of (success, error_message). If success is True, error_message is None.

(self)

Source from the content-addressed store, hash-verified

118 yield response
119
120 def validate_connection(self) -> tuple[bool, Optional[str]]:
121 """
122 Validate the connection to the LLM provider.
123
124 Returns:
125 Tuple of (success, error_message).
126 If success is True, error_message is None.
127 """
128 try:
129 # Try a minimal request to validate the connection
130 self.chat(
131 messages=[Message.user("Hello")],
132 max_tokens=10
133 )
134 return True, None
135 except LLMError as e:
136 return False, str(e)
137 except Exception as e:
138 return False, f"Connection failed: {str(e)}"
139
140
141class LLMClientError(Exception):

Callers

nothing calls this directly

Calls 2

chatMethod · 0.95
userMethod · 0.80

Tested by

no test coverage detected