BaseClient
BaseClient is the abstract transport contract for prompt-driven modules in AutoPipeline. It is implemented in src/autopipeline/components/primitives/clients/base_client.py.
All concrete entries in CLIENT_REGISTRY inherit from this class.
Base
Overview
Role in the Stack
The client layer is intentionally narrow:
- clients handle transport
- prompt adapters format payloads
- modules interpret responses
BaseClient exists to keep that separation explicit.
Constructor
Constructor Parameters
| Parameter | Required | Meaning |
|---|---|---|
model_name | Yes | Model identifier passed to the backend transport layer. |
**kwargs | No | Backend-specific config captured into self.config. |
Stored attributes
The constructor stores:
self.model_nameself.config
Methods
Public Methods
| Method | Purpose |
|---|---|
call_model(messages) | Abstract transport call implemented by subclasses. |
parse_response_to_json(response) | Shared JSON extraction and repair helper. |
Methods
Method Reference
call_model(messages)
call_model(messages) -> str
This method is abstract. Concrete subclasses define:
- accepted
messagespayload shape - network or SDK call behavior
- retry logic
- returned raw text format
parse_response_to_json(response)
parse_response_to_json(response: str) -> Any
Input
| Parameter | Meaning |
|---|---|
response | Raw text returned by the model backend. |
Output
Returns:
- a parsed Python object on success
Noneif extraction and repair both fail
Internal behavior
The method:
- tries to extract a JSON block from the response
- repairs malformed JSON with
json_repair - falls back to repairing the full response when no explicit block is found
Config
Minimal Integration Example
BaseClient is not instantiated directly, but all concrete client configs eventually map into its constructor shape:
client_cfg:
backend: api
model_name: gpt-4o
base_url: https://...
api_key: ${client_config.api_key}
Failure Mode
Failure Semantics
BaseClient itself does not perform transport retries, but parse_response_to_json(...) is soft-fail by design:
- malformed or missing JSON -> returns
None - parse errors are logged rather than raised
This behavior is important because the judge and parser modules often prefer retrying over crashing.
Extension
Extension Notes
- Subclass
BaseClientwhen transport or authentication changes. - Do not move prompt serialization into this layer.
- Keep output normalization above the client layer so transport code stays backend-specific and simple.