New crate crates/gateway-domain, the first member of layer L2 in architecture.json (L2 is now a pure layer: tokio, axum, reqwest, libc and the other adapter crates are forbidden dependencies there). It depends on serde, serde_json, leleka-sampler-ref and leleka-tokenizer only. Moved out of control-plane/src with git mv, content unchanged apart from paths: sampling (request sampling extensions, validation) and EngineTune (was in wire.rs), reasoning_budget (the budget driver and its tests), codec (Family, TextCodec, TokenDecoder, QwenCodec), json_order, and the Chat Completions translation (chat_completions: Request -> Responses request, reply fields; the axum handlers stay in chat.rs). strata-control re-exports codec, json_order, reasoning_budget and sampling under their old paths, and wire.rs re-exports EngineTune, so no caller and no test outside the moved modules changed. 4 new tests cover the chat translation. Architecture gate: layer entry added; dyn-trait:leleka-gateway-domain = 5 appears because the five dyn in the moved code (Box<dyn TokenDecoder>, Box<dyn Iterator> in the budget driver, &dyn Fn, ...) change crate; dyn-trait:strata-control fell 21 -> 16 in the same step, so the total is unchanged (--allow-increase was needed for the new per-crate key only). Test outcomes: 597 ok / 2 ignored before, 615 ok / 2 ignored after (18 new tests); the 13 moved tests keep their ids in the new crate and their outcome.
30 lines
772 B
Rust
30 lines
772 B
Rust
//! Stateless, one-choice Chat Completions adapter over native Responses.
|
|
use crate::{app::AppState, responses};
|
|
use axum::{
|
|
Json,
|
|
body::{Body, to_bytes},
|
|
extract::{State, rejection::JsonRejection},
|
|
http::StatusCode,
|
|
response::{IntoResponse, Response, Sse, sse::Event},
|
|
};
|
|
use futures_core::Stream;
|
|
use serde_json::{Value, json};
|
|
use std::{
|
|
convert::Infallible,
|
|
pin::Pin,
|
|
task::{Context, Poll},
|
|
};
|
|
use tokio::sync::mpsc;
|
|
|
|
use crate::native_events::{MAX_EVENT, NativeEvents};
|
|
use leleka_gateway_domain::chat_completions::{Request, call, finish, identity, usage};
|
|
|
|
struct Events(mpsc::Receiver<Event>);
|
|
|
|
mod completion;
|
|
#[allow(unused_imports)]
|
|
pub use completion::*;
|
|
mod stream_response;
|
|
#[allow(unused_imports)]
|
|
pub use stream_response::*;
|