----------------------
Yes, you can get a stream response from the GPT index during a query by setting the
streaming
parameter to
True
during the
index.query()
call. When
streaming=True
, the query will return a
StreamingResponse
object instead of a standard
Response
object.
Here's the relevant extract from the documentation:
class gpt_index.response.schema.StreamingResponse(response_gen: Optional[Generator], source_nodes: List[NodeWithScore] = <factory>, extra_info: Optional[Dict[str, Any]] = None, response_txt: Optional[str] = None)
The
StreamingResponse
object has a
response_gen
attribute, which is the response generator. You can use the
print_response_stream()
method to print the response stream.
Source:
GPT Index Documentation - Response (
https://gpt-index.readthedocs.io/en/latest/reference/response.html)
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------