mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-10 07:38:04 -05:00
feat(agent/serve): Report task cost through Step.additional_output
- Added `task_cumulative_cost` and `task_total_cost` attributes to the `Step.additional_output` in the `AgentProtocolServer.execute_step` endpoint. - Updated `agbenchmark` dependency in Agent and Forge
This commit is contained in:
@@ -233,14 +233,21 @@ class AgentProtocolServer:
|
||||
|
||||
if step.is_last and execute_command == finish.__name__:
|
||||
assert execute_command_args
|
||||
|
||||
additional_output = {}
|
||||
task_total_cost = agent.llm_provider.get_incurred_cost()
|
||||
if task_total_cost > 0:
|
||||
additional_output["task_total_cost"] = task_total_cost
|
||||
logger.info(
|
||||
f"Total LLM cost for task {task_id}: "
|
||||
f"${round(task_total_cost, 2)}"
|
||||
)
|
||||
|
||||
step = await self.db.update_step(
|
||||
task_id=task_id,
|
||||
step_id=step.step_id,
|
||||
output=execute_command_args["reason"],
|
||||
)
|
||||
logger.info(
|
||||
f"Total LLM cost for task {task_id}: "
|
||||
f"${round(agent.llm_provider.get_incurred_cost(), 2)}"
|
||||
additional_output=additional_output,
|
||||
)
|
||||
return step
|
||||
|
||||
@@ -320,6 +327,14 @@ class AgentProtocolServer:
|
||||
**raw_output,
|
||||
}
|
||||
|
||||
task_cumulative_cost = agent.llm_provider.get_incurred_cost()
|
||||
if task_cumulative_cost > 0:
|
||||
additional_output["task_cumulative_cost"] = task_cumulative_cost
|
||||
logger.debug(
|
||||
f"Running total LLM cost for task {task_id}: "
|
||||
f"${round(task_cumulative_cost, 3)}"
|
||||
)
|
||||
|
||||
step = await self.db.update_step(
|
||||
task_id=task_id,
|
||||
step_id=step.step_id,
|
||||
@@ -328,10 +343,6 @@ class AgentProtocolServer:
|
||||
additional_output=additional_output,
|
||||
)
|
||||
|
||||
logger.debug(
|
||||
f"Running total LLM cost for task {task_id}: "
|
||||
f"${round(agent.llm_provider.get_incurred_cost(), 3)}"
|
||||
)
|
||||
agent.state.save_to_json_file(agent.file_manager.state_file_path)
|
||||
return step
|
||||
|
||||
|
||||
2
autogpts/autogpt/poetry.lock
generated
2
autogpts/autogpt/poetry.lock
generated
@@ -51,7 +51,7 @@ uvicorn = "^0.23.2"
|
||||
type = "git"
|
||||
url = "https://github.com/Significant-Gravitas/AutoGPT.git"
|
||||
reference = "HEAD"
|
||||
resolved_reference = "2a55efb3221600ec68496275022a94ade48ef79c"
|
||||
resolved_reference = "21f1e64559ad3c292932ff1ea4d69abfe655280a"
|
||||
subdirectory = "benchmark"
|
||||
|
||||
[[package]]
|
||||
|
||||
2
autogpts/forge/poetry.lock
generated
2
autogpts/forge/poetry.lock
generated
@@ -40,7 +40,7 @@ uvicorn = "^0.23.2"
|
||||
type = "git"
|
||||
url = "https://github.com/Significant-Gravitas/AutoGPT.git"
|
||||
reference = "HEAD"
|
||||
resolved_reference = "2a55efb3221600ec68496275022a94ade48ef79c"
|
||||
resolved_reference = "21f1e64559ad3c292932ff1ea4d69abfe655280a"
|
||||
subdirectory = "benchmark"
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in New Issue
Block a user