mirror of
https://github.com/RightNow-AI/openfang.git
synced 2026-07-30 15:01:15 +00:00
bug fixes
This commit is contained in:
@@ -687,7 +687,7 @@ impl OpenFangKernel {
|
||||
"Fallback provider configured"
|
||||
);
|
||||
driver_chain.push(d.clone());
|
||||
model_chain.push((d, fb.model.clone()));
|
||||
model_chain.push((d, strip_provider_prefix(&fb.model, &fb.provider)));
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
@@ -1950,6 +1950,24 @@ impl OpenFangKernel {
|
||||
kernel_clone
|
||||
.scheduler
|
||||
.record_usage(agent_id, &result.total_usage);
|
||||
|
||||
// Persist usage to database (same as non-streaming path)
|
||||
let model = &manifest.model.model;
|
||||
let cost = MeteringEngine::estimate_cost_with_catalog(
|
||||
&kernel_clone.model_catalog.read().unwrap_or_else(|e| e.into_inner()),
|
||||
model,
|
||||
result.total_usage.input_tokens,
|
||||
result.total_usage.output_tokens,
|
||||
);
|
||||
let _ = kernel_clone.metering.record(&openfang_memory::usage::UsageRecord {
|
||||
agent_id,
|
||||
model: model.clone(),
|
||||
input_tokens: result.total_usage.input_tokens,
|
||||
output_tokens: result.total_usage.output_tokens,
|
||||
cost_usd: cost,
|
||||
tool_calls: result.iterations.saturating_sub(1),
|
||||
});
|
||||
|
||||
let _ = kernel_clone
|
||||
.registry
|
||||
.set_state(agent_id, AgentState::Running);
|
||||
@@ -4629,7 +4647,7 @@ impl OpenFangKernel {
|
||||
skip_permissions: true,
|
||||
};
|
||||
match drivers::create_driver(&config) {
|
||||
Ok(d) => chain.push((d, fb.model.clone())),
|
||||
Ok(d) => chain.push((d, strip_provider_prefix(&fb.model, &fb.provider))),
|
||||
Err(e) => {
|
||||
warn!("Fallback driver '{}' failed to init: {e}", fb.provider);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user