Add callback for token usage#999
Conversation
|
Your PR has commits that are missing the Signed-off-by trailer. This is likely due to the pre-commit hook not being configured on your local machine. The usual fix for this issue is to run |
Dependency Review✅ No vulnerabilities or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #999 +/- ##
==========================================
- Coverage 82.06% 82.04% -0.02%
==========================================
Files 198 199 +1
Lines 8208 8239 +31
==========================================
+ Hits 6736 6760 +24
- Misses 1472 1479 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| return model_name | ||
|
|
||
| def on_llm_end(self, response: LLMResult, **kwargs) -> None: | ||
| if response.generations[0]: |
There was a problem hiding this comment.
NIT: may be worth checking list is non-empty before checking first element, ie.
if respoonse.generations and response.generations[0]
Context
We need to provide token usage to Datadog so that it can calculate the LLM cost.
What
botocorefrom auto otherwise it will overwrite the token usage that we annotated.Have you written unit tests?
tested locally and in dev
Are there any specific instructions on how to test this change?
run some prompts in dev and then check that DataDog traces calculate token costs
Relevant links