Skip to content

Commit

Permalink
genai: make bucket-referencing test more resilient (#10571)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben authored Jul 23, 2024
1 parent 58ffd42 commit ba82942
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vertexai/genai/caching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package genai

import (
"context"
"fmt"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -76,8 +77,10 @@ func testCaching(t *testing.T, client *Client) {
return cc
}

vertexProject := os.Getenv("VERTEX_PROJECT_ID")

want := &CachedContent{
Model: "projects/" + os.Getenv("VERTEX_PROJECT_ID") +
Model: "projects/" + vertexProject +
"/locations/us-central1/publishers/google/models/" + model,
CreateTime: time.Now().UTC(),
UpdateTime: time.Now().UTC(),
Expand All @@ -93,13 +96,15 @@ func testCaching(t *testing.T, client *Client) {
}
}

gcsFilePath := fmt.Sprintf("gs://0002-test-multimodal-%s/embeddings/xray-embedding.json", vertexProject)

ttl := 30 * time.Minute
wantExpireTime := time.Now().Add(ttl)
argcc := &CachedContent{
Model: model,
Expiration: ExpireTimeOrTTL{TTL: ttl},
Contents: []*Content{{Role: "user", Parts: []Part{
FileData{MIMEType: "text/plain", FileURI: "gs://0002-test-multimodal/embeddings/xray-embedding.json"},
FileData{MIMEType: "text/plain", FileURI: gcsFilePath},
}}},
}
cc := must(client.CreateCachedContent(ctx, argcc))
Expand Down
9 changes: 9 additions & 0 deletions vertexai/genai/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,3 +678,12 @@ func TestInferLocation(t *testing.T) {
})
}
}

func printResponse(resp *GenerateContentResponse) {
for _, cand := range resp.Candidates {
for _, part := range cand.Content.Parts {
fmt.Println(part)
}
}
fmt.Println("---")
}

0 comments on commit ba82942

Please sign in to comment.