Skip to content

Commit

Permalink
Retry on VertexAI's InternalServerError
Browse files Browse the repository at this point in the history
  • Loading branch information
DonggeLiu committed Nov 14, 2024
1 parent 60f3db1 commit 1c2d235
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llm_toolkit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
import openai
import tiktoken
import vertexai
from google.api_core.exceptions import (GoogleAPICallError, InvalidArgument,
from google.api_core.exceptions import (GoogleAPICallError,
InternalServerError, InvalidArgument,
ResourceExhausted)
from vertexai import generative_models
from vertexai.preview.generative_models import ChatSession, GenerativeModel
Expand Down Expand Up @@ -650,6 +651,7 @@ def get_chat_client(self, model: GenerativeModel) -> Any:
InvalidArgument,
ValueError, # TODO(dongge): Handle RECITATION specifically.
IndexError, # A known error from vertexai.
InternalServerError, # A known error from vertexai.
],
other_exceptions={ResourceExhausted: 100})
def _do_generate(self, client: ChatSession, prompt: str,
Expand Down

0 comments on commit 1c2d235

Please sign in to comment.