Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-relay-gateway/src/lexigram/ai/relay/gateway/passthrough.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-25 07:19 +0800

1"""Passthrough relay lifecycle for non-chat endpoint kinds. 

2 

3``PassthroughService`` relays endpoint kinds that do not fit the 

4chat-focused conversion engine (starting with embeddings) through the 

5generalized parts of the chat pipeline — channel selection by endpoint 

6kind, authorization, billing admission and settlement, and the upstream 

7HTTP adapter — while skipping ``RelayConverterProtocol`` entirely: the 

8wire format in is the wire format out, with the model alias 

9substituted only when the channel config declares a suffix. Bodies are 

10carried by :class:`RelayPassthroughBody` (decoded JSON or raw bytes 

11with a content type) and upstream responses by 

12:class:`RelayPassthroughResult` (verbatim bytes plus the upstream 

13content type) — JSON responses are still returned decoded through the 

14``payload`` accessor so the embeddings wire path is byte-for-byte 

15unchanged, while non-JSON responses ride in ``body`` uninterpreted. 

16The upstream response is returned verbatim, unvalidated beyond the 

17adapter's existing malformed-body handling. 

18 

19Implementation lives in three focused modules: 

20 

21- :mod:`lexigram.ai.relay.gateway.passthrough_body` — request body 

22 carrier and multipart field rewriting. 

23- :mod:`lexigram.ai.relay.gateway.passthrough_result` — upstream 

24 response carrier. 

25- :mod:`lexigram.ai.relay.gateway.passthrough_service` — the 

26 endpoint-kind dispatch service. 

27 

28This module re-exports the public surface so existing imports keep 

29resolving unchanged. 

30""" 

31 

32from __future__ import annotations 

33 

34from lexigram.ai.relay.gateway.passthrough_body import ( 

35 RelayPassthroughBody, 

36 rewrite_multipart_form_field, 

37) 

38from lexigram.ai.relay.gateway.passthrough_result import RelayPassthroughResult 

39from lexigram.ai.relay.gateway.passthrough_service import PassthroughService 

40 

41__all__ = [ 

42 "PassthroughService", 

43 "RelayPassthroughBody", 

44 "RelayPassthroughResult", 

45 "rewrite_multipart_form_field", 

46]