Skip to content

Commit

Permalink
Return proper response type in synthesizer (#11701)
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-markewich authored Mar 6, 2024
1 parent 1e21bee commit 8f74286
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions llama-index-core/llama_index/core/response_synthesizers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
QueryTextType = Union[str, QueryBundle]


def empty_response_generator() -> Generator[str, None, None]:
yield "Empty Response"


class BaseSynthesizer(ChainableMixin, PromptMixin):
"""Response builder class."""

Expand Down Expand Up @@ -177,7 +181,10 @@ def synthesize(
**response_kwargs: Any,
) -> RESPONSE_TYPE:
if len(nodes) == 0:
return Response("Empty Response")
if self._streaming:
return StreamingResponse(response_gen=empty_response_generator())
else:
return Response("Empty Response")

if isinstance(query, str):
query = QueryBundle(query_str=query)
Expand Down Expand Up @@ -210,7 +217,10 @@ async def asynthesize(
**response_kwargs: Any,
) -> RESPONSE_TYPE:
if len(nodes) == 0:
return Response("Empty Response")
if self._streaming:
return StreamingResponse(response_gen=empty_response_generator())
else:
return Response("Empty Response")

if isinstance(query, str):
query = QueryBundle(query_str=query)
Expand Down

0 comments on commit 8f74286

Please sign in to comment.