Hi, I am using gemini-2.5-flash-preview-05-20.
But sometimes it doesn’t return any data
My usage example is as follows:
from langchain.chat_models.base import init_chat_model
gemini = init_chat_model(model="gemini-2.5-flash-preview-05-20",model_provider="google_genai")
prompt = ChatPromptTemplate.from_messages(
[
SystemMessagePromptTemplate.from_template("xxx"),
]
chain = prompt | gemini
async for chunk in chain.astream({"history": history}, config=langfuse_handler_config):
logger.info(f"Response chunk : {chunk.content}")
Most of the time it works normally
Occasionally, it throws an exception message stating ‘No generation chunks were returned’
For requests that throw exceptions, I retry and it returns chunks normally
I added debugging logs at the location of the RPC request calling the Gemini API, and everything is normal
How should I solve this problem? Or where else can I check?
Also, I would like to know if my usage method can control the token of thoughts