Skip to content
Open
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
7fbd6a7
[ATOM gRPC] atomesh: structured output to ATOM gRPC workers; answers …
Jasen2201 Nov 21, 2026
494bb93
Merge the Generate review fixes (#3673) into atomesh structured outpu…
Jasen2201 Nov 22, 2026
6c03d34
Merge Abort before submission (#3673) into atomesh structured output …
Jasen2201 Nov 22, 2026
da818c7
Merge the chat-template and top_logprobs review fixes (#3673) into at…
Jasen2201 Nov 22, 2026
c938e02
Merge the stop-string review fixes (#3675) into the chat render
Jasen2201 Nov 22, 2026
423f7c3
[ATOM gRPC] atomesh: refuse chat and /generate logprobs for ATOM gRPC…
Jasen2201 Nov 22, 2026
42ebfd5
Merge the step-flush ordering fix (#3673) into atomesh structured out…
Jasen2201 Nov 22, 2026
e497f58
Merge discovery and P/D (#3676) into structured output and render
Jasen2201 Nov 22, 2026
1bb481c
Merge discovery and P/D (#3676) into structured output and render
Jasen2201 Nov 23, 2026
33fe5a0
Merge discovery and P/D (#3676) into structured output and render
Jasen2201 Nov 23, 2026
cc1098e
Merge discovery and P/D (#3676) into structured output and render
Jasen2201 Nov 23, 2026
277e0a0
Merge discovery and P/D (#3676) into structured output and render
Jasen2201 Nov 23, 2026
660cb90
Merge discovery and P/D (#3676) into structured output and render
Jasen2201 Nov 23, 2026
4958086
Merge discovery and P/D (#3676) into structured output and render
Jasen2201 Nov 23, 2026
ee0397c
Merge main into atomesh structured output and render
Jasen2201 Nov 23, 2026
dfd8551
Merge atomesh discovery and P/D into atomesh structured output and re…
Jasen2201 Nov 23, 2026
657c3e7
Merge the E fixes into atomesh structured output and render
Jasen2201 Nov 23, 2026
48c7274
Merge the E fixes into atomesh structured output and render
Jasen2201 Nov 23, 2026
7586061
atomesh: read an ATOM worker's output as ATOM's servers read it
Jasen2201 Nov 23, 2026
8b17a0b
atomesh: parse an ATOM reply with the parsers its worker names
Jasen2201 Nov 23, 2026
8b6c400
atomesh: write ATOM's usage fields for an ATOM worker's reply only
Jasen2201 Nov 23, 2026
6d9b890
atomesh: give only an ATOM worker's chat reply ATOM's shape
Jasen2201 Nov 23, 2026
b4eb5dd
atomesh: stream the ids a Complete carries past the partials
Jasen2201 Nov 23, 2026
4dfcde5
atomesh: parse an ATOM worker's forced tool call in the model's syntax
Jasen2201 Nov 23, 2026
aa9e17a
atomesh: carry the tools a chat's messages declare, on any role
Jasen2201 Nov 23, 2026
48e878e
atomesh: answer an ATOM completion that asks for logprobs with null l…
Jasen2201 Nov 23, 2026
f33c3ea
atomesh: reconcile a gRPC response's cached tokens against the route …
Jasen2201 Nov 23, 2026
a3eefca
Merge the E fixes into atomesh structured output and render
Jasen2201 Nov 23, 2026
0d60579
atomesh: place an ATOM stream's usage where its model's HTTP chat does
Jasen2201 Nov 23, 2026
6d09550
atomesh: type a unary reply's tool arguments by the declared schemas
Jasen2201 Nov 23, 2026
2d5c242
atomesh: stream the logprobs of the ids a Complete carries past the p…
Jasen2201 Nov 23, 2026
0247234
atomesh: read an ATOM reply as starting in reasoning where ATOM's HTT…
Jasen2201 Nov 23, 2026
0440ae9
Merge the E fixes into atomesh structured output and render
Jasen2201 Nov 23, 2026
f7a5dc7
atomesh: give the SSE snapshot test's contexts usage_on_finish
Jasen2201 Nov 23, 2026
615a209
Merge the E fixes into atomesh structured output and render
Jasen2201 Nov 23, 2026
ac2c44a
atomesh: build the usage test's request in its initializer
Jasen2201 Nov 23, 2026
16fc424
Merge the E fixes into atomesh structured output and render
Jasen2201 Nov 23, 2026
a9553f1
Merge discovery and P/D's headers and replaced-rank fix into structur…
Jasen2201 Nov 23, 2026
8f8f7b1
Give structured output and render's new files the full source header
Jasen2201 Nov 23, 2026
c4e2307
atomesh: an ATOM reading skips special tokens whatever the request asks
Jasen2201 Nov 23, 2026
4a0f2f3
atomesh: a chat whose messages declare an empty tool list parses no t…
Jasen2201 Nov 23, 2026
ce25316
atomesh: import Tokenizer where only the AtomOutput tests use it
Jasen2201 Nov 23, 2026
a8eee1a
Merge discovery and P/D's tokenizer and prefill-info fixes into struc…
Jasen2201 Nov 23, 2026
6d49a7f
atomesh: a tool declared again is read with its last declaration
Jasen2201 Nov 23, 2026
b62691e
atomesh: a streamed /generate's final event carries every unstreamed id
Jasen2201 Nov 23, 2026
bf1c0ff
atomesh: a message's namespaced tool keeps its namespace
Jasen2201 Nov 23, 2026
2203ea7
Merge discovery and P/D's tokenizer, template and stream-release fixe…
Jasen2201 Nov 23, 2026
bc2d136
Merge discovery and P/D's test cleanup into structured output and render
Jasen2201 Nov 23, 2026
986569a
atomesh: read a completion's meta_info without decoding the body twice
Jasen2201 Nov 23, 2026
c6a1da0
atomesh: a namespaced top-level tool keeps its namespace
Jasen2201 Nov 23, 2026
44558e2
Merge discovery and P/D's prefill-info, tokenizer-gate, leg-refusal a…
Jasen2201 Nov 24, 2026
a260184
Merge discovery and P/D's template-readiness and greedy-n fixes into …
Jasen2201 Nov 24, 2026
545e673
atomesh: ATOM chat tests record the worker template their tokenizer c…
Jasen2201 Nov 24, 2026
546c85d
atomesh: a long unstreamed reply keeps a last "<" or "</"
Jasen2201 Nov 24, 2026
d120179
atomesh: an ATOM chat's reasoning_effort reaches its kwargs as ATOM's…
Jasen2201 Nov 24, 2026
0a70c21
atomesh: a streamed reply keeps a last "<" or "</" too
Jasen2201 Nov 24, 2026
f8fac35
atomesh: a long unstreamed reply keeps its answer's whitespace
Jasen2201 Nov 24, 2026
0026c5c
Merge discovery and P/D's template-precedence and seq_id-race fixes i…
Jasen2201 Nov 24, 2026
07fd4de
Merge discovery and P/D's template-file, prefill-marker and health fi…
Jasen2201 Nov 24, 2026
2294d89
atomesh: an ATOM chat's thinking control reaches its kwargs as on HTTP
Jasen2201 Nov 24, 2026
88aeced
atomesh: an ATOM reply cut off inside a native call keeps the call
Jasen2201 Nov 24, 2026
2d82d4a
atomesh: a streamed chat feeds a Complete's unstreamed ids in pieces
Jasen2201 Nov 24, 2026
d8e6bcd
atomesh: a streamed /generate records the Complete's token count
Jasen2201 Nov 24, 2026
aea2033
Merge discovery and P/D's merged delivery-time stamping into structur…
Jasen2201 Nov 24, 2026
74891c7
atomesh: a namespaced named tool_choice keeps its namespace
Jasen2201 Nov 24, 2026
06940ea
atomesh: a long reply closing an empty implicit reasoning block drops…
Jasen2201 Nov 24, 2026
c16fea9
atomesh: a streamed chat copies each replayed piece of a Complete alone
Jasen2201 Nov 24, 2026
9ce6027
atomesh: a streamed chat reads the text its Complete releases as a pa…
Jasen2201 Nov 24, 2026
55b3518
Merge discovery and P/D's one-template rule, review fixes and merge o…
Jasen2201 Nov 24, 2026
8b09945
atomesh: a cut-off ATOM tool call is closed by its own parser's rule
Jasen2201 Nov 24, 2026
07d169c
Merge discovery and P/D's template binding of tokenizer jobs and chat…
Jasen2201 Nov 24, 2026
821c8b3
atomesh: a bare Qwen XML function call is a call, as on ATOM's HTTP chat
Jasen2201 Nov 24, 2026
239e32c
atomesh: only an ATOM worker's reply reads a bare Qwen XML call as a …
Jasen2201 Nov 24, 2026
2a12025
atomesh: a bare Qwen XML call's text ends where the call starts
Jasen2201 Nov 24, 2026
f3246e5
atomesh: a bare Qwen XML call cut off after its name is closed at end…
Jasen2201 Nov 24, 2026
0c32cd8
atomesh: a streamed chat's reasoning parser reads each delta token by…
Jasen2201 Nov 24, 2026
1891b8a
Merge discovery and P/D's single tokenizer lookup and template-file p…
Jasen2201 Nov 24, 2026
348210a
atomesh: a streamed ATOM reply keeps a `<tool_call>` it quotes before…
Jasen2201 Nov 24, 2026
beb0963
atomesh: text a streamed ATOM reply holds at its end as a call's star…
Jasen2201 Nov 24, 2026
0c435ca
atomesh: a bare Qwen XML call cut off in a tag is kept, unary as stre…
Jasen2201 Nov 24, 2026
f0838d5
Merge discovery and P/D's template check while a model's tokenizer lo…
Jasen2201 Nov 24, 2026
95c6fad
atomesh: a streamed MiniMax reply's held partial marker is text at it…
Jasen2201 Nov 24, 2026
93394b3
atomesh: a bare Qwen XML call naming no declared tool is text, unary …
Jasen2201 Nov 24, 2026
2c38520
atomesh: an ATOM reply's text is all of it outside its calls, read unary
Jasen2201 Nov 24, 2026
584c705
Merge discovery and P/D's template ranking at admission into structur…
Jasen2201 Nov 24, 2026
22e0734
Merge discovery and P/D's one-step template admission into structured…
Jasen2201 Nov 24, 2026
5b5faa1
atomesh: each Qwen XML call in one delta streams its own arguments
Jasen2201 Nov 24, 2026
f544044
atomesh: a cut-off ATOM Qwen call is not closed past text after its <…
Jasen2201 Nov 24, 2026
4a26965
Merge discovery and P/D's tokenizer handover on a last worker's remov…
Jasen2201 Nov 24, 2026
a97e80e
atomesh: a bare header whose name runs into a `<` is text, as unary r…
Jasen2201 Nov 24, 2026
96c18b0
atomesh: /generate's stream decodes a chunk into one String
Jasen2201 Nov 24, 2026
f2453c2
atomesh: a timed /generate reply serializes its timing without a JSON…
Jasen2201 Nov 24, 2026
e2fe38d
Merge the engine's skip of a turned-off prefix chain store into atome…
Jasen2201 Nov 26, 2026
ffe1025
Merge main into atomesh structured output and chat render
Jasen2201 Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions atom/mesh/src/observability/route_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ pub(crate) async fn estimated<F: Future>(attempts: F) -> (F::Output, Option<f64>
.await
}

/// Drops the estimate of `pool`'s selection unless the request is sent to the selected
/// `worker`: DP ranks keep separate KV caches, so a remapped request loses it.
pub(crate) fn keep_estimate_for(pool: &'static str, worker: &Arc<dyn Worker>) {
if !computes_prompt(pool) {
return;
}
let _ = ESTIMATE.try_with(|estimate| {
let mut estimate = estimate.borrow_mut();
if estimate
.as_ref()
.is_some_and(|e| e.worker.url() != worker.url())
{
*estimate = None;
}
});
}

fn computes_prompt(pool: &'static str) -> bool {
matches!(
pool,
Expand Down Expand Up @@ -157,18 +174,7 @@ pub(crate) fn record_estimate(
/// Records the worker a request is sent to after rank mapping.
pub(crate) fn record_dispatch(pool: &'static str, worker: &Arc<dyn Worker>) {
MeshMetrics::record_selected_dp_rank(pool, worker.base_url(), worker.dp_rank());
if computes_prompt(pool) {
let _ = ESTIMATE.try_with(|estimate| {
let mut estimate = estimate.borrow_mut();
// DP ranks keep separate KV caches, so a remapped request loses the estimate.
if estimate
.as_ref()
.is_some_and(|e| e.worker.url() != worker.url())
{
*estimate = None;
}
});
}
keep_estimate_for(pool, worker);
let _ = TRACE.try_with(|trace| {
let selections = trace.selections.borrow();
let selection = selections.iter().find(|selection| selection.pool == pool);
Expand Down
2 changes: 1 addition & 1 deletion atom/mesh/src/routers/atom_bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl RouterTrait for AtomBridgeRouter {
Ok(extras) => extras,
Err(response) => return response,
};
let (uri, headers, parsed, metadata) = request.into_native_parts();
let (uri, headers, parsed, metadata, _) = request.into_native_parts();
let headers = Some(&headers);
let model = metadata.model.as_deref();
REQUEST_EXTRAS
Expand Down
55 changes: 53 additions & 2 deletions atom/mesh/src/routers/grpc/completion_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ use crate::{
generate::{GenerateFinishReason, GenerateRequest, GenerateResponse},
sampling_params::SamplingParams,
},
routers::comm::error,
routers::{
comm::error,
render::atom_usage::{self, AtomUsage},
},
};

/// Build a synthetic SGLang `GenerateRequest` from an OpenAI `CompletionRequest`.
Expand Down Expand Up @@ -117,6 +120,16 @@ pub(crate) fn completion_to_generate(c: &CompletionRequest) -> Result<GenerateRe
})
}

/// `generate` without the logprobs its completion asked for: ATOM's HTTP /v1/completions
/// answers logprobs null, and its gRPC workers refuse a request for them.
pub(crate) fn without_logprobs(generate: GenerateRequest) -> GenerateRequest {
GenerateRequest {
return_logprob: Some(false),
top_logprobs_num: None,
..generate
}
}

/// Convert a list of native `GenerateResponse`s into an OpenAI `CompletionResponse`.
fn build_completion_response(gens: Vec<GenerateResponse>, model: String) -> CompletionResponse {
let id = gens
Expand Down Expand Up @@ -204,8 +217,18 @@ pub(crate) async fn wrap_generate_response_as_completion(
}
};

// An ATOM worker's sequences carry their timing, which its usage reports.
let meta_infos = meta_infos(&bytes);
let atom = AtomUsage::of_meta_infos(&meta_infos.iter().collect::<Vec<_>>());

let completion = build_completion_response(gens, model);
let json = match serde_json::to_vec(&completion) {
let json = match atom {
None => serde_json::to_vec(&completion),
Some(atom) => atom
.extend_response(&completion, atom_usage::COMPLETION)
.and_then(|value| serde_json::to_vec(&value)),
};
let json = match json {
Ok(v) => v,
Err(e) => {
return error::internal_error(
Expand All @@ -224,6 +247,18 @@ pub(crate) async fn wrap_generate_response_as_completion(
new
}

/// A generate response's `meta_info` alone; its text, ids and logprobs are skipped.
#[derive(serde::Deserialize)]
struct MetaInfoOnly {
meta_info: Option<Value>,
}

/// Each response's `meta_info` in a `/generate` body, read without decoding the rest.
fn meta_infos(body: &[u8]) -> Vec<Value> {
let responses: Vec<MetaInfoOnly> = serde_json::from_slice(body).unwrap_or_default();
responses.into_iter().filter_map(|r| r.meta_info).collect()
}

/// Map a generate `finish_reason` Value (the raw JSON form, since streaming
/// chunks are parsed loosely as Value to avoid coupling to a single schema)
/// into the OpenAI completion `finish_reason` string.
Expand Down Expand Up @@ -457,3 +492,19 @@ fn find_subsequence(haystack: &[u8], needle: &[u8]) -> Option<usize> {
}
haystack.windows(needle.len()).position(|w| w == needle)
}

#[cfg(test)]
mod meta_info_tests {
use super::*;

#[test]
fn meta_infos_are_read_alone_and_responses_without_one_are_skipped() {
let body = json!([
{"text": "a long reply", "output_ids": [1, 2], "meta_info": {"ttft": 0.5}},
{"text": "no meta"},
]);
let read = meta_infos(&serde_json::to_vec(&body).unwrap());
assert_eq!(read, [json!({"ttft": 0.5})]);
assert!(meta_infos(b"not json").is_empty());
}
}
7 changes: 6 additions & 1 deletion atom/mesh/src/routers/grpc/engine/atom/pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ use crate::core::placement::backend::BackendAdapter;
use crate::core::placement::PlacementPlan;
use crate::core::worker::RuntimeType;
use crate::core::{Worker, WorkerLoadGuard, WorkerRegistry};
use crate::observability::events::{Event, RequestPDSentEvent};
use crate::observability::{
events::{Event, RequestPDSentEvent},
metrics::metrics_labels,
route_trace,
};
use crate::routers::grpc::engine::worker_client_cache::{get_grpc_client_from_worker, GrpcClient};
use crate::routers::prepare::generation_payload::GenerationPayload;
use crate::routers::token_handle::engine_error::EngineError;
Expand Down Expand Up @@ -243,6 +247,7 @@ impl AtomPairs {
let started = Instant::now();
let prefill =
apply_atom_pd_rank_mapping_policy(self.mapping, &self.workers, prefill.clone(), decode);
route_trace::keep_estimate_for(metrics_labels::WORKER_PREFILL, &prefill);
let prefill_load = WorkerLoadGuard::new(prefill.clone(), None);
let decode_load = WorkerLoadGuard::new(decode.clone(), None);
RequestPDSentEvent {
Expand Down
23 changes: 17 additions & 6 deletions atom/mesh/src/routers/grpc/engine/atom/request.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: MIT
// Copyright (C) 2026, Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2026 ATOM Project Contributors
//! A `GenerationPayload` as ATOM's GenerateRequest: the sampling fields ATOM's
//! HTTP routes read, stop strings and stop ids as token id sequences, and the
//! worker's DP rank.
//! A `GenerationPayload` as ATOM's GenerateRequest: the sampling fields ATOM's HTTP routes read,
//! stop strings and stop ids as token id sequences, the worker's DP rank and a chat's
//! StructuredOutput.

use crate::atom_engine::{
grpc::GenerateRequest,
grpc::{self, GenerateRequest},
wire::pb::{SamplingParams, TokenIds},
};
use crate::core::Worker;
use crate::protocols::common::StringOrArray;
use crate::routers::prepare::generation_payload::GenerationPayload;
use crate::routers::prepare::generation_payload::{GenerationPayload, StructuredOutput};
use crate::routers::token_handle::engine_error::EngineError;
use crate::tokenizer::traits::Tokenizer;

Expand Down Expand Up @@ -63,12 +63,23 @@ pub(crate) fn generate_request(
kv_transfer_params_json: None,
data_parallel_rank: worker.dp_rank().map(|rank| rank as i32),
stream: payload.stream,
structured_output: None,
structured_output: payload.structured_output.as_ref().map(structured_output),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4dfcde5: a reply read as ATOM's (ResponseContext.reads_as_atom, set for an ATOM producer) no longer takes the JSON path for a named or required tool_choice. Both renderers parse it with the model's tool parser, as ATOM's HTTP chat does; SGLang and vLLM keep the JSON path. h_atom_native_tool_calls covers a named and a required choice, unary and streamed.

dp_session_id: payload.dp_session_id.clone(),
dp_parent_session_id: payload.dp_parent_session_id.clone(),
})
}

fn structured_output(carried: &StructuredOutput) -> grpc::StructuredOutput {
grpc::StructuredOutput {
tools_json: carried.tools_json.clone(),
tool_choice_json: carried.tool_choice_json.clone(),
response_format_json: carried.response_format_json.clone(),
chat_template_kwargs_json: carried.chat_template_kwargs_json.clone(),
prompt_opens_reasoning: carried.prompt_opens_reasoning,
message_tools_json: carried.message_tools_json.clone(),
}
}

/// Each stop string as ATOM encodes one, without special tokens, dropping a
/// string that encodes to nothing.
fn stop_token_sequences(
Expand Down
2 changes: 2 additions & 0 deletions atom/mesh/src/routers/grpc/engine/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mod a_payload_to_proto {
stream: false,
return_hidden_states: false,
log_metrics: false,
structured_output: None,
dp_session_id: None,
dp_parent_session_id: None,
chat_template: None,
Expand Down Expand Up @@ -820,6 +821,7 @@ mod e_engine_dispatch {
stream: false,
return_hidden_states: false,
log_metrics: false,
structured_output: None,
dp_session_id: None,
dp_parent_session_id: None,
chat_template: None,
Expand Down
59 changes: 55 additions & 4 deletions atom/mesh/src/routers/grpc/pd_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ use std::sync::Arc;

use async_trait::async_trait;
use axum::{http::HeaderMap, response::Response};
use bytes::Bytes;
use tracing::debug;

#[cfg(feature = "grpc-client")]
use super::engine::atom::pair::AtomPairs;
use super::{
completion_adapter::{
completion_to_generate, wrap_generate_response_as_completion,
completion_to_generate, without_logprobs, wrap_generate_response_as_completion,
wrap_streaming_generate_as_completion,
},
pipeline::Pipeline,
router::{atom_chat_refusal, atom_serves, declared_tools, logprobs_refused, media_refused},
};
use crate::{
app_context::AppContext,
Expand All @@ -26,7 +28,11 @@ use crate::{
protocols::{
chat::ChatCompletionRequest, completion::CompletionRequest, generate::GenerateRequest,
},
routers::{comm::error, RouterTrait},
routers::{
comm::error,
prepare::{inference::ParsedInference, message_tools::MessageTools, read_thinking},
RouterTrait,
},
};

#[derive(Clone)]
Expand Down Expand Up @@ -125,6 +131,8 @@ impl GrpcPDRouter {
&self,
headers: Option<&HeaderMap>,
body: &ChatCompletionRequest,
message_tools: Option<MessageTools>,
thinking: Option<serde_json::Value>,
model_id: Option<&str>,
) -> Response {
debug!(
Expand All @@ -142,12 +150,21 @@ impl GrpcPDRouter {
&self.retry_config,
|_attempt| {
let request = Arc::clone(&request);
let message_tools = message_tools.clone();
let thinking = thinking.clone();
let headers = headers_cloned.clone();
let model_id = model_id_cloned.clone();
let components = Arc::clone(&components);
async move {
pipeline
.execute_chat(request, headers, model_id, components)
.execute_chat_declaring(
request,
(message_tools, thinking),
headers,
model_id,
components,
None,
)
.await
}
},
Expand Down Expand Up @@ -215,6 +232,14 @@ impl RouterTrait for GrpcPDRouter {
body: &GenerateRequest,
model_id: Option<&str>,
) -> Response {
if atom_serves(&self.worker_registry, model_id) {
if ParsedInference::generate_carries_media(body) {
return media_refused();
}
if body.return_logprob == Some(true) {
return logprobs_refused();
}
}
self.route_generate_impl(headers, body, model_id).await
}

Expand All @@ -224,7 +249,32 @@ impl RouterTrait for GrpcPDRouter {
body: &ChatCompletionRequest,
model_id: Option<&str>,
) -> Response {
self.route_chat_impl(headers, body, model_id).await
if let Some(refused) = atom_chat_refusal(&self.worker_registry, body, model_id) {
return refused;
}
self.route_chat_impl(headers, body, None, None, model_id)
.await
}

async fn route_chat_body(
&self,
headers: Option<&HeaderMap>,
body: &ChatCompletionRequest,
raw: Bytes,
model_id: Option<&str>,
) -> Response {
if let Some(refused) = atom_chat_refusal(&self.worker_registry, body, model_id) {
return refused;
}
let message_tools = match declared_tools(&self.worker_registry, &raw, model_id) {
Ok(declared) => declared,
Err(refused) => return refused,
};
// ATOM's alone, as message tools are.
let thinking = message_tools.as_ref().and_then(|_| read_thinking(&raw));
drop(raw);
self.route_chat_impl(headers, body, message_tools, thinking, model_id)
.await
}

async fn route_completion(
Expand All @@ -234,6 +284,7 @@ impl RouterTrait for GrpcPDRouter {
model_id: Option<&str>,
) -> Response {
let synthetic = match completion_to_generate(body) {
Ok(g) if atom_serves(&self.worker_registry, model_id) => without_logprobs(g),
Ok(g) => g,
Err(msg) => return error::bad_request("completion_unsupported_field", msg),
};
Expand Down
Loading
Loading