mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Merge pull request #4714 from djliden/main
updates cost tracking example code in docs to resolve errors
This commit is contained in:
commit
177424c27c
1 changed files with 4 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ Define your custom callback class in a python file.
|
|||
```python
|
||||
from litellm.integrations.custom_logger import CustomLogger
|
||||
import litellm
|
||||
import logging
|
||||
|
||||
# This file includes the custom callbacks for LiteLLM Proxy
|
||||
# Once defined, these can be passed in proxy_config.yaml
|
||||
|
|
@ -25,9 +26,9 @@ class MyCustomHandler(CustomLogger):
|
|||
datefmt='%Y-%m-%d %H:%M:%S'
|
||||
)
|
||||
|
||||
response_cost = litellm.completion_cost(completion_response=completion_response)
|
||||
response_cost = litellm.completion_cost(completion_response=response_obj)
|
||||
print("regular response_cost", response_cost)
|
||||
logging.info(f"Model {completion_response.model} Cost: ${response_cost:.8f}")
|
||||
logging.info(f"Model {response_obj.model} Cost: ${response_cost:.8f}")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
@ -78,4 +79,4 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \
|
|||
"user": "ishaan-app",
|
||||
"temperature": 0.2
|
||||
}'
|
||||
```
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue