Merge pull request #4714 from djliden/main
updates cost tracking example code in docs to resolve errors
This commit is contained in:
commit
177424c27c
@ -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…
Reference in New Issue
Block a user