Fix 'list.remove(x): x not in list' error in crewai chat command

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-03-23 17:08:37 +00:00
parent ed1f009c64
commit 6161e6893e
2 changed files with 57 additions and 2 deletions

View File

@@ -964,11 +964,19 @@ class LLM:
callback_types = [type(callback) for callback in callbacks]
for callback in litellm.success_callback[:]:
if type(callback) in callback_types:
litellm.success_callback.remove(callback)
try:
litellm.success_callback.remove(callback)
except ValueError:
# Skip if callback is not in the list
pass
for callback in litellm._async_success_callback[:]:
if type(callback) in callback_types:
litellm._async_success_callback.remove(callback)
try:
litellm._async_success_callback.remove(callback)
except ValueError:
# Skip if callback is not in the list
pass
litellm.callbacks = callbacks