@@ -29,7 +29,8 @@ public class VertexAIExtensionsTest
2929 [ Fact ]
3030 public async Task AsIChatClient_BasicRequestResponse_NonStreaming ( )
3131 {
32- IChatClient client = ( await CreateClientAsync ( ) ) . AsIChatClient ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "gemini-2.5-pro" ) ) ;
32+ IChatClient client = await new PredictionServiceClientBuilder ( )
33+ . BuildIChatClientAsync ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "gemini-2.5-pro" ) ) ;
3334 Assert . NotNull ( client ) ;
3435
3536 var response = await client . GetResponseAsync ( "Hello" ) ;
@@ -40,7 +41,8 @@ public async Task AsIChatClient_BasicRequestResponse_NonStreaming()
4041 [ Fact ]
4142 public async Task AsIChatClient_BasicRequestResponse_Streaming ( )
4243 {
43- IChatClient client = ( await CreateClientAsync ( ) ) . AsIChatClient ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "gemini-2.5-pro" ) ) ;
44+ IChatClient client = await new PredictionServiceClientBuilder ( )
45+ . BuildIChatClientAsync ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "gemini-2.5-pro" ) ) ;
4446 Assert . NotNull ( client ) ;
4547
4648 ChatResponse response = await client . GetStreamingResponseAsync ( "Hello" ) . ToChatResponseAsync ( ) ;
@@ -51,7 +53,8 @@ public async Task AsIChatClient_BasicRequestResponse_Streaming()
5153 [ Fact ]
5254 public async Task AsIEmbeddingGenerator_EmbedSeveralInputs ( )
5355 {
54- IEmbeddingGenerator < string , Embedding < float > > generator = ( await CreateClientAsync ( ) ) . AsIEmbeddingGenerator ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "gemini-embedding-001" ) ) ;
56+ IEmbeddingGenerator < string , Embedding < float > > generator = await new PredictionServiceClientBuilder ( )
57+ . BuildIEmbeddingGeneratorAsync ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "gemini-embedding-001" ) ) ;
5558 Assert . NotNull ( generator ) ;
5659
5760 GeneratedEmbeddings < Embedding < float > > embeddings = await generator . GenerateAsync ( [ "Hello" , "World" ] ) ;
@@ -67,7 +70,8 @@ public async Task AsIEmbeddingGenerator_EmbedSeveralInputs()
6770 [ Fact ]
6871 public async Task AsIImageGenerator_GenerateImage ( )
6972 {
70- IImageGenerator generator = ( await CreateClientAsync ( ) ) . AsIImageGenerator ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "imagen-4.0-fast-generate-001" ) ) ;
73+ IImageGenerator generator = await new PredictionServiceClientBuilder ( )
74+ . BuildIImageGeneratorAsync ( EndpointName . FormatProjectLocationPublisherModel ( s_projectId , s_location , "google" , "imagen-4.0-fast-generate-001" ) ) ;
7175 Assert . NotNull ( generator ) ;
7276
7377 ImageGenerationResponse response = await generator . GenerateImagesAsync ( "A cute baby sea otter" ) ;
@@ -77,8 +81,5 @@ public async Task AsIImageGenerator_GenerateImage()
7781 Assert . Equal ( "image/png" , image . MediaType ) ;
7882 Assert . InRange ( image . Data . Length , 1 , int . MaxValue ) ;
7983 }
80-
81- private static Task < PredictionServiceClient > CreateClientAsync ( ) =>
82- PredictionServiceClient . CreateAsync ( ) ;
8384}
8485
0 commit comments