From b9585d20162c2eae1a7441cf348dd14821f0367b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 30 Nov 2024 17:24:39 -0800 Subject: [PATCH] fix(langsmith.py): fix langsmith quickstart Fixes https://github.com/BerriAI/litellm/issues/6861 --- litellm/integrations/langsmith.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/integrations/langsmith.py b/litellm/integrations/langsmith.py index 033638b90..f44ac5b87 100644 --- a/litellm/integrations/langsmith.py +++ b/litellm/integrations/langsmith.py @@ -68,7 +68,11 @@ class LangsmithLogger(CustomBatchLogger): if _batch_size: self.batch_size = int(_batch_size) self.log_queue: List[LangsmithQueueObject] = [] - asyncio.create_task(self.periodic_flush()) + loop = asyncio.get_event_loop_policy().get_event_loop() + if not loop.is_running(): + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + loop.create_task(self.periodic_flush()) self.flush_lock = asyncio.Lock() super().__init__(**kwargs, flush_lock=self.flush_lock)