去掉流式查询和输出

This commit is contained in:
yangdx
2025-01-15 02:25:01 +08:00
parent 33e211789e
commit 4b32648eb5

View File

@@ -1,6 +1,6 @@
import asyncio
import os import os
import inspect # import asyncio
# import inspect
import logging import logging
from dotenv import load_dotenv from dotenv import load_dotenv
from lightrag import LightRAG, QueryParam from lightrag import LightRAG, QueryParam
@@ -64,19 +64,19 @@ print(
rag.query("What are the top themes in this story?", param=QueryParam(mode="hybrid")) rag.query("What are the top themes in this story?", param=QueryParam(mode="hybrid"))
) )
# stream response # # stream response
resp = rag.query( # resp = rag.query(
"What are the top themes in this story?", # "What are the top themes in this story?",
param=QueryParam(mode="hybrid", stream=True), # param=QueryParam(mode="hybrid", stream=True),
) # )
async def print_stream(stream): # async def print_stream(stream):
async for chunk in stream: # async for chunk in stream:
print(chunk, end="", flush=True) # print(chunk, end="", flush=True)
if inspect.isasyncgen(resp): # if inspect.isasyncgen(resp):
asyncio.run(print_stream(resp)) # asyncio.run(print_stream(resp))
else: # else:
print(resp) # print(resp)