handle non-streaming case

This commit is contained in:
Luca Beurer-Kellner
2025-03-27 15:00:58 +01:00
committed by Hemang
parent 0df61524da
commit 0157aad27b
2 changed files with 5 additions and 2 deletions
+4 -1
View File
@@ -171,6 +171,10 @@ class StreamInstrumentor:
"""
def decorator(func):
assert asyncio.iscoroutinefunction(
func
), "Listener must be an async function"
if event == "chunk":
if self.on_chunk_listeners is None:
self.on_chunk_listeners = []
@@ -296,7 +300,6 @@ class StreamInstrumentor:
# yield item
yield item
# finally, execute on complete listeners
on_complete_tasks = [
asyncio.create_task(listener(), name="instrumentor:end")
for listener in self.on_complete_listeners
+1 -1
View File
@@ -225,7 +225,7 @@ async def stream_response(
raise YieldException(f"data: {error_chunk}\n\n".encode())
@instrumentor.on("end")
def send_to_explorer() -> None:
async def send_to_explorer() -> None:
# Send full merged response to the explorer
# Don't block on the response from explorer
if context.dataset_name: