Skip to content

Commit fc150e3

Browse files
authored
fix: added defer client.Close() to Vertex samples (#4425)
1 parent 4efe098 commit fc150e3

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

vertexai/batch-predict/batch_code_predict.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func batchCodePredict(w io.Writer, projectID, location, name, outputURI string,
5151
if err != nil {
5252
return err
5353
}
54+
defer client.Close()
5455

5556
req := &aiplatformpb.CreateBatchPredictionJobRequest{
5657
Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),

vertexai/batch-predict/batch_text_predict.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func batchTextPredict(w io.Writer, projectID, location, name, outputURI string,
5454
if err != nil {
5555
return err
5656
}
57+
defer client.Close()
5758

5859
req := &aiplatformpb.CreateBatchPredictionJobRequest{
5960
Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),

vertexai/snippets/gemini_translate.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func geminiTranslate(w io.Writer, project, location string) error {
3636
if err != nil {
3737
return fmt.Errorf("error creating client: %w", err)
3838
}
39+
defer client.Close()
40+
3941
model := client.GenerativeModel(modelName)
4042

4143
model.GenerationConfig = genai.GenerationConfig{

0 commit comments

Comments
 (0)