I have a pretty simple use case where I'm trying to stream back results with FastAPI. When I log the token over the response iterator, I see each token being logged in the console, but I'm not seeing the streamed results. Anyone see an issue I'm missing?
async def response_streamer(response):
for token in response:
logger.info(token)
yield f"{token}"
class ChatInput(BaseModel):
query_text: str
@app.post("/chat")
async def query_index(chat_input: ChatInput):
global index
chat_engine = index.as_chat_engine(
chat_mode="condense_question",
verbose=True,
llm=Settings.llm,
)
streaming_response = chat_engine.stream_chat(chat_input.query_text)
return StreamingResponse(
response_streamer(streaming_response.response_gen),
media_type="text/event-stream",
status_code=200,
)