datarobot_genai.core.chat.auth
auth
Authorization context helpers for chat flows.
get_authorization_context_from_headers
get_authorization_context_from_headers(headers: dict[str, str], secret_key: str | None = None) -> dict[str, Any] | None
Extract authorization context from headers using AuthContextHeaderHandler.
Parameters
headers : dict[str, str] HTTP headers from which to extract the authorization context. secret_key : str | None Secret key for JWT decoding. If None, retrieves from environment variable.
Returns
dict[str, Any] | None The extracted authorization context, or None if not found.
Source code in datarobot_genai/core/chat/auth.py
get_authorization_context_from_params
get_authorization_context_from_params(completion_create_params: CompletionCreateParams | CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming) -> dict[str, Any] | None
Extract authorization context from completion create parameters.
Parameters
completion_create_params : CompletionCreateParams The parameters used to create the completion.
Returns
dict[str, Any] | None The extracted authorization context, or None if not found.
Source code in datarobot_genai/core/chat/auth.py
resolve_authorization_context
resolve_authorization_context(completion_create_params: CompletionCreateParams | CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming, **kwargs: Any) -> dict[str, Any]
Resolve the authorization context for the agent.
Authorization context is required for propagating information needed by downstream agents and tools to retrieve access tokens to connect to external services. This method extracts the authorization context from either the incoming HTTP headers or the completion create parameters.
Parameters
completion_create_params : CompletionCreateParams | CompletionCreateParamsNonStreaming |
CompletionCreateParamsStreaming
Parameters supplied to the completion API. May include a fallback
authorization_context mapping under the same key.
**kwargs : Any
Additional keyword arguments. Expected to include a headers key
containing incoming HTTP headers as dict[str, str].
Returns
dict[str, Any] The initialized authorization context.