Implemented logging token usage (solves #322) (#438)

* Implemented logging token usage

Token usage is now tracked and logged into memory/logs/token_usage

* Step names are now inferred from function name

* Incorporated Anton's feedback

- Made LogUsage a dataclass
- For token logging, step name is now inferred via inspect module

* Formatted (black/ruff)

* Update gpt_engineer/ai.py

Co-authored-by: Anton Osika <anton.osika@gmail.com>

* formatting

---------

Co-authored-by: Anton Osika <anton.osika@gmail.com>
This commit is contained in:
UmerHA
2023-07-03 21:28:34 +02:00
committed by GitHub
parent 2b8e056d5d
commit 8fd315d264
4 changed files with 112 additions and 14 deletions

View File

@@ -61,6 +61,8 @@ def main(
if collect_consent():
collect_learnings(model, temperature, steps, dbs)
dbs.logs["token_usage"] = ai.format_token_usage_log()
if __name__ == "__main__":
app()