prefactor_core.utils module
prefactor_core.utils module
Section titled “prefactor_core.utils module”Utility functions for prefactor-core.
prefactor_core.utils.generate_idempotency_key() → str
Section titled “prefactor_core.utils.generate_idempotency_key() → str”Generate a new UUID-based idempotency key.
The returned key is a UUID4 string (36 characters), always within the 64-character API limit.
- Returns: A unique idempotency key string.
prefactor_core.utils.validate_idempotency_key(key: str) → str
Section titled “prefactor_core.utils.validate_idempotency_key(key: str) → str”Validate that an idempotency key is a non-empty string of at most 64 characters.
- Parameters: key – The idempotency key to validate.
- Returns: The key unchanged if valid.
- Raises: ValueError – If the key is empty or exceeds 64 characters.
prefactor_core.utils.warn_missing_adaptor_config(instance_id: str, adaptor_name: str, create_client_call: str) → None
Section titled “prefactor_core.utils.warn_missing_adaptor_config(instance_id: str, adaptor_name: str, create_client_call: str) → None”Warn that an instance was registered before the adaptor configured the client.
Called by framework adaptors (langchain, livekit, etc.) when a
pre-created instance is passed in and the backing client wasn’t set up
through create_client() or from_config().
- Parameters:
- instance_id – The agent instance ID that was registered too early.
- adaptor_name – Human-readable adaptor name (e.g.
"middleware"). - create_client_call – The call the user should use instead
(e.g.
"PrefactorMiddleware.create_client(config)").