-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Methods astream and astream_event not working for ChatVertexAI #733
Comments
Ok it turns out that this error only occurs if we use from langchain_google_vertexai import ChatVertexAI, VertexAI
import vertexai
vertexai.init()
llmodel = ChatVertexAI(model_name="gemini-2.0-flash", max_tokens=1024)
async for chunk in llmodel.astream('Say some interesting facts about chinchillas'):
print(chunk, flush=True) It may be related to incorrect async rest credentials https://www.googlecloudcommunity.com/gc/AI-ML/Async-REST-credentials-for-Vertex-AI/m-p/839712 |
Looks like the error is being originated from here: i.e the last line in this code snippet. @retry_decorator
async def _completion_with_retry_inner(
generation_method: Callable, **kwargs: Any
) -> Any:
return await generation_method(**kwargs) I further looked at the response_iter = _acompletion_with_retry(
self.async_prediction_client.stream_generate_content,
max_retries=self.max_retries,
request=request,
is_gemini=True,
**kwargs,
) This is being created from this method @property
def async_prediction_client(self) -> v1beta1PredictionServiceAsyncClient:
"""Returns PredictionServiceClient."""
if self.async_client is None:
async_client_kwargs: dict[str, Any] = dict(
client_options=self.client_options,
client_info=get_client_info(module=self._user_agent),
credentials=self.credentials,
)
if self.api_transport is not None:
async_client_kwargs["transport"] = self.api_transport
self.async_client = v1beta1PredictionServiceAsyncClient(
**async_client_kwargs
)
return self.async_client I am guessing the error is getting originated from the Vertex AI cloud library since the |
@tanukiki could you share a full trace, please? and is the error consistently reproducible on your side? |
When using:
I get
It works for base
VertexAI
model and forChatGoogleGenerativeAI
fromlangchain_google_genai
but not forChatVertexAI
. The same with.astream_events
The text was updated successfully, but these errors were encountered: