fix(billing): use actual tokens in nonstreaming ReAct billing
- ai_react_nonstreaming now passes real input/output tokens to billing - Was passing hardcoded 0,0 despite destructuring token data - Also fix unused variable warnings
This commit is contained in:
parent
64ca5eeea1
commit
32d7b3b902
@ -33,7 +33,7 @@ pub async fn process_message_ai_react_nonstreaming(
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
match final_answer {
|
match final_answer {
|
||||||
Ok((response, input_tokens, output_tokens)) => {
|
Ok((response, _input_tokens, _output_tokens)) => {
|
||||||
if let Err(e) = create_and_publish_ai_message(
|
if let Err(e) = create_and_publish_ai_message(
|
||||||
&db,
|
&db,
|
||||||
&cache,
|
&cache,
|
||||||
@ -66,15 +66,17 @@ pub async fn process_message_ai_react_nonstreaming(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Record billing (non-fatal)
|
// Record billing (non-fatal)
|
||||||
// TODO: ReAct agent does not track token counts yet; billing with 0/0
|
if let Err(e) = super::billing::record_ai_usage(
|
||||||
let _ = super::billing::record_ai_usage(
|
|
||||||
&db,
|
&db,
|
||||||
project_id,
|
project_id,
|
||||||
model_id,
|
model_id,
|
||||||
0,
|
_input_tokens,
|
||||||
0,
|
_output_tokens,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
{
|
||||||
|
tracing::warn!(error = %e, "AI billing recording failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|||||||
@ -155,7 +155,7 @@ pub async fn process_message_ai_react_streaming(
|
|||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let (final_content, input_tokens, output_tokens, err_msg, should_log) = match result {
|
let (final_content, input_tokens, output_tokens, err_msg, _should_log) = match result {
|
||||||
Ok((content, input, output)) => (content, input, output, None, false),
|
Ok((content, input, output)) => (content, input, output, None, false),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let msg = format!("[Agent error: {}]", e);
|
let msg = format!("[Agent error: {}]", e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user