Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state handlers / observability #9

Closed
krrishdholakia opened this issue Jul 28, 2023 · 3 comments
Closed

Add state handlers / observability #9

krrishdholakia opened this issue Jul 28, 2023 · 3 comments

Comments

@krrishdholakia
Copy link
Contributor

When I call litellm there's always just 2 things I need to know - did the query succeed or fail?

If it succeeds I'll log it to PostHog

If it fails I'll log it to PostHog + Slack

Wonder if litellm can help simplify this for me.

@krrishdholakia
Copy link
Contributor Author

krrishdholakia commented Jul 28, 2023

Analytics.js has callbacks -> maybe having them as success_callback and failure_callback

Screenshot 2023-07-28 at 9 34 21 AM

Alt idea:

from litellm import completion_client
completion = completion_client(success_callback=["posthog"], failure_callback=["posthog","slack"]) 

response = completion(model="gpt-3.5-turbo", messages=messages)

@krrishdholakia
Copy link
Contributor Author

krrishdholakia commented Jul 28, 2023

Sketching this idea out a bit more - enabling custom functions as well

Use Case: I want to create a unified pricing dashboard on top of this. For that I need to know when it worked/didn't work - when it works -> i'm calculating the number of tokens used for input/output and then sending that data to my supabase table.

from litellm import completion_client
completion = completion_client(success_callback=["posthog"], failure_callback=["posthog","slack"]) 

def success_handler():
   print("it worked!")

def failure_handler():
   print("error occurred")

response = completion(model="gpt-3.5-turbo", messages=messages, success_callback_fn=success_handler, failure_callback_fn=failure_handler)

@krrishdholakia krrishdholakia changed the title Add state handlers Add state handlers / observability Jul 28, 2023
@krrishdholakia
Copy link
Contributor Author

closing as this has been implemented.

https://litellm.readthedocs.io/en/latest/advanced/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant