forked from phoenix/litellm-mirror
add custom callback to docs
This commit is contained in:
parent
eaaede608e
commit
ad5668dbdf
2 changed files with 49 additions and 0 deletions
48
docs/my-website/docs/observability/custom_callback.md
Normal file
48
docs/my-website/docs/observability/custom_callback.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Custom Callback Functions for Completion()
|
||||
|
||||
## Defining a Custom Callback Function
|
||||
Create a custom callback function that takes specific arguments:
|
||||
|
||||
```python
|
||||
def custom_callback(
|
||||
kwargs, # kwargs to completion
|
||||
completion_response, # response from completion
|
||||
start_time, end_time # start/end time
|
||||
):
|
||||
# Your custom code here
|
||||
```
|
||||
|
||||
## Using Your Custom Callback Function
|
||||
|
||||
```python
|
||||
import litellm
|
||||
from litellm import completion
|
||||
|
||||
# Assign the custom callback function
|
||||
litellm.success_callback = [custom_callback]
|
||||
|
||||
response = completion(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hi 👋 - i'm openai"
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
print(response)
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -90,6 +90,7 @@ const sidebars = {
|
|||
items: [
|
||||
"observability/callbacks",
|
||||
"observability/integrations",
|
||||
"observability/custom_callback",
|
||||
"observability/promptlayer_integration",
|
||||
"observability/langfuse_integration",
|
||||
"observability/traceloop_integration",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue