@@ -22,7 +22,7 @@ async function main(
22
22
model = 'text-embedding-004' ,
23
23
texts = 'banana bread?;banana muffins?' ,
24
24
task = 'QUESTION_ANSWERING' ,
25
- outputDimensionality = 0 ,
25
+ dimensionality = 0 ,
26
26
apiEndpoint = 'us-central1-aiplatform.googleapis.com'
27
27
) {
28
28
const aiplatform = require ( '@google-cloud/aiplatform' ) ;
@@ -31,15 +31,14 @@ async function main(
31
31
const clientOptions = { apiEndpoint : apiEndpoint } ;
32
32
const location = 'us-central1' ;
33
33
const endpoint = `projects/${ project } /locations/${ location } /publishers/google/models/${ model } ` ;
34
- const parameters =
35
- outputDimensionality > 0
36
- ? helpers . toValue ( outputDimensionality )
37
- : helpers . toValue ( 256 ) ;
38
34
39
35
async function callPredict ( ) {
40
36
const instances = texts
41
37
. split ( ';' )
42
38
. map ( e => helpers . toValue ( { content : e , task_type : task } ) ) ;
39
+ const parameters = helpers . toValue (
40
+ dimensionality > 0 ? { outputDimensionality : parseInt ( dimensionality ) } : { }
41
+ ) ;
43
42
const request = { endpoint, instances, parameters} ;
44
43
const client = new PredictionServiceClient ( clientOptions ) ;
45
44
const [ response ] = await client . predict ( request ) ;
0 commit comments