This commit is contained in:
Yannick Stephan
2025-02-20 13:34:47 +01:00
parent 60717fd6be
commit 38dc2466da

View File

@@ -1,7 +1,8 @@
import inspect
import os
from lightrag import LightRAG
from lightrag.llm import openai_complete, openai_embed
from lightrag.utils import EmbeddingFunc
from lightrag.utils import EmbeddingFunc, always_get_an_event_loop
from lightrag import QueryParam
# WorkingDir
@@ -44,3 +45,10 @@ async def print_stream(stream):
async for chunk in stream:
if chunk:
print(chunk, end="", flush=True)
loop = always_get_an_event_loop()
if inspect.isasyncgen(resp):
loop.run_until_complete(print_stream(resp))
else:
print(resp)