mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
(fix) async langfuse logger
This commit is contained in:
parent
f2cfb76920
commit
6a695477ba
1 changed files with 3 additions and 14 deletions
|
@ -1864,12 +1864,6 @@ def client(original_function):
|
||||||
# we only support async s3 logging for acompletion/aembedding since that's used on proxy
|
# we only support async s3 logging for acompletion/aembedding since that's used on proxy
|
||||||
litellm._async_success_callback.append(callback)
|
litellm._async_success_callback.append(callback)
|
||||||
removed_async_items.append(index)
|
removed_async_items.append(index)
|
||||||
elif callback == "langfuse" and inspect.iscoroutinefunction(
|
|
||||||
original_function
|
|
||||||
):
|
|
||||||
# use async success callback for langfuse if this is litellm.acompletion(). Streaming logging does not work otherwise
|
|
||||||
litellm._async_success_callback.append(callback)
|
|
||||||
removed_async_items.append(index)
|
|
||||||
|
|
||||||
# Pop the async items from success_callback in reverse order to avoid index issues
|
# Pop the async items from success_callback in reverse order to avoid index issues
|
||||||
for index in reversed(removed_async_items):
|
for index in reversed(removed_async_items):
|
||||||
|
@ -2357,18 +2351,13 @@ def client(original_function):
|
||||||
print_verbose(
|
print_verbose(
|
||||||
f"Async Wrapper: Completed Call, calling async_success_handler: {logging_obj.async_success_handler}"
|
f"Async Wrapper: Completed Call, calling async_success_handler: {logging_obj.async_success_handler}"
|
||||||
)
|
)
|
||||||
# asyncio.to_thread(
|
asyncio.create_task(
|
||||||
# logging_obj.async_success_handler(result, start_time, end_time)
|
logging_obj.async_success_handler(result, start_time, end_time)
|
||||||
# )
|
)
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
target=logging_obj.success_handler, args=(result, start_time, end_time)
|
target=logging_obj.success_handler, args=(result, start_time, end_time)
|
||||||
).start()
|
).start()
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
loop.run_in_executor(
|
|
||||||
executor=None,
|
|
||||||
func=logging_obj.async_success_handler(result, start_time, end_time),
|
|
||||||
)
|
|
||||||
# RETURN RESULT
|
# RETURN RESULT
|
||||||
if hasattr(result, "_hidden_params"):
|
if hasattr(result, "_hidden_params"):
|
||||||
result._hidden_params["model_id"] = kwargs.get("model_info", {}).get(
|
result._hidden_params["model_id"] = kwargs.get("model_info", {}).get(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue