Skip to content

Commit

Permalink
handle empty query
Browse files Browse the repository at this point in the history
  • Loading branch information
liukidar committed Dec 14, 2024
1 parent 4475116 commit a6fa692
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fast_graphrag/_graphrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async def _query() -> TQueryResponse[GTNode, GTEdge, GTHash, GTChunk]:
return get_event_loop().run_until_complete(_query())

async def async_query(
self, query: str, params: Optional[QueryParam] = None
self, query: Optional[str], params: Optional[QueryParam] = None
) -> TQueryResponse[GTNode, GTEdge, GTHash, GTChunk]:
"""Query the graph with a given input.
Expand All @@ -168,6 +168,10 @@ async def async_query(
Returns:
TQueryResponse: The result of the query (response + context).
"""
if query is None or len(query) == 0:
return TQueryResponse[GTNode, GTEdge, GTHash, GTChunk](
response=PROMPTS["fail_response"], context=TContext([], [], [])
)
if params is None:
params = QueryParam()

Expand Down

0 comments on commit a6fa692

Please sign in to comment.