review: Gesamtkosten auch im allgemeinen Cost-Header
Eine gestreamte Review-Antwort trägt die Summe im junction-Objekt; eine nicht gestreamte hatte sie nur in X-Junction-Review-Cost-Usd. Jetzt steht dieselbe Summe zusätzlich in X-Junction-Cost-Usd, damit ein Client, der nur den allgemeinen Kosten-Header kennt, nicht den Review-Sonderfall behandeln muss. Test: usage-review mit drei Calls -> X-Junction-Cost-Usd: 0.005400. Tests: 525 OK, 0 FAIL.
This commit is contained in:
1 parent
715aef2a8b
commit
a5023e474e
3 files changed
+7
-1
No files matched your search
@@ -561,7 +561,9 @@ row: it describes the subscription (zero token price, budget/requests) rather th
|
||||
the pay-as-you-go list price.
|
||||
|
||||
A non-streaming response carries `X-Junction-Tokens-In`, `X-Junction-Tokens-Out`
|
||||
and, when the price is known, `X-Junction-Cost-Usd`. An unpriced model keeps
|
||||
and, when the price is known, `X-Junction-Cost-Usd`. A reviewed answer puts the
|
||||
sum over the worker and all rounds in both `X-Junction-Review-Cost-Usd` and the
|
||||
general `X-Junction-Cost-Usd`, so one header is enough. An unpriced model keeps
|
||||
`unknown`; without any price table the headers are not invented. A cache hit is a
|
||||
call that cost nothing: it reports cost `0.000000` and zero tokens even though the
|
||||
cached body still contains the provider's original usage. The spend log and
|
||||
|
||||
@@ -3636,6 +3636,9 @@ static int review_serve(j_conn *client, j_endpoint *ep, const j_req *rq,
|
||||
if (rev.cost_known) {
|
||||
snprintf(v, sizeof v, "%.6f", rev.cost);
|
||||
j_hdrs_set(&h, "X-Junction-Review-Cost-Usd", v);
|
||||
/* The same total in the general per-call header: a client that
|
||||
* knows one cost header should not have to special-case review. */
|
||||
j_hdrs_set(&h, "X-Junction-Cost-Usd", v);
|
||||
}
|
||||
}
|
||||
add_route_meta_headers(&h);
|
||||
|
||||
@@ -301,6 +301,7 @@ UH=$(tr -d '\r' < "$TMP/review_usage_h.txt")
|
||||
contains "$UH" "X-Junction-Review-Tokens-In: 3600" "the header carries the summed input tokens"
|
||||
contains "$UH" "X-Junction-Review-Tokens-Out: 900" "the header carries the summed output tokens"
|
||||
contains "$UH" "X-Junction-Review-Cost-Usd: 0.005400" "the header carries the summed cost"
|
||||
contains "$UH" "X-Junction-Cost-Usd: 0.005400" "the general cost header carries the review total too"
|
||||
contains "$UH" "X-Junction-Ms: " "the request time covers the whole review"
|
||||
|
||||
# Streaming: derselbe Block steckt im finalen SSE-Chunk, nicht nur im JSON-Pfad.
|
||||
|
||||
Reference in new issue
Block a user