lpgcast.serve¶
lpgcast serve: casting over HTTP, for a platform that holds the schema.
One stateless, synchronous route: POST /cast takes a schema inline, the
episodes and options, and returns what lpgcast cast --out writes — the
graph, groundings, pending edges, quarantine, episode results and the run
manifest. The service never writes to a database and never calls back to the
caller, so it holds no database credentials and needs no URL allow-list.
The key is fail-closed: every route but /health needs
Authorization: Bearer <LPGCAST_SERVE_API_KEY>, and without a configured
key the service refuses to cast unless LPGCAST_SERVE_ALLOW_ANONYMOUS is
set. Model settings come from the service's own LPGCAST_LLM_* environment;
a request cannot pick the model or the endpoint.
Needs the server extra (FastAPI and uvicorn).
Attributes¶
Classes¶
CastOptions
¶
Bases: BaseModel
Per-request settings; each one left out, or null, takes the service's value.
Source code in lpgcast/serve.py
Attributes¶
max_episode_tokens = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='forbid')
class-attribute
instance-attribute
¶
slice_max_elements = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
slice_max_tokens = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
user_instruction = None
class-attribute
instance-attribute
¶
CastRequest
¶
Bases: BaseModel
A schema (or a manifest carrying one) and the episodes to cast against it.
Source code in lpgcast/serve.py
Attributes¶
episodes = Field(min_length=1)
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='forbid', populate_by_name=True)
class-attribute
instance-attribute
¶
options = Field(default_factory=CastOptions)
class-attribute
instance-attribute
¶
schema_ = Field(alias='schema')
class-attribute
instance-attribute
¶
CastResponse
¶
Bases: BaseModel
What lpgcast cast --out writes, in one body.
Source code in lpgcast/serve.py
Health
¶
Bases: BaseModel
GET /health.
Source code in lpgcast/serve.py
Functions:¶
create_app(settings=None, serve=None, *, client=None)
¶
The service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
LPGCastSettings | None
|
Cast settings; defaults to the environment. |
None
|
serve
|
ServeSettings | None
|
Service settings; defaults to the environment. |
None
|
client
|
LLMClient | None
|
The model client shared by every request; defaults to one built from settings. |
None
|
Source code in lpgcast/serve.py
run(serve=None)
¶
Serve on LPGCAST_SERVE_HOST:LPGCAST_SERVE_PORT.