@@ -27,7 +27,8 @@ const fakeVertexAI: VertexAI = {
27
27
automaticDataCollectionEnabled : true ,
28
28
options : {
29
29
apiKey : 'key' ,
30
- projectId : 'my-project'
30
+ projectId : 'my-project' ,
31
+ appId : 'my-appid'
31
32
}
32
33
} ,
33
34
location : 'us-central1'
@@ -48,7 +49,7 @@ describe('Top level API', () => {
48
49
it ( 'getGenerativeModel throws if no apiKey is provided' , ( ) => {
49
50
const fakeVertexNoApiKey = {
50
51
...fakeVertexAI ,
51
- app : { options : { projectId : 'my-project' } }
52
+ app : { options : { projectId : 'my-project' , appId : 'my-appid' } }
52
53
} as VertexAI ;
53
54
try {
54
55
getGenerativeModel ( fakeVertexNoApiKey , { model : 'my-model' } ) ;
@@ -64,7 +65,7 @@ describe('Top level API', () => {
64
65
it ( 'getGenerativeModel throws if no projectId is provided' , ( ) => {
65
66
const fakeVertexNoProject = {
66
67
...fakeVertexAI ,
67
- app : { options : { apiKey : 'my-key' } }
68
+ app : { options : { apiKey : 'my-key' , appId : 'my-appid' } }
68
69
} as VertexAI ;
69
70
try {
70
71
getGenerativeModel ( fakeVertexNoProject , { model : 'my-model' } ) ;
@@ -79,6 +80,22 @@ describe('Top level API', () => {
79
80
) ;
80
81
}
81
82
} ) ;
83
+ it ( 'getGenerativeModel throws if no appId is provided' , ( ) => {
84
+ const fakeVertexNoProject = {
85
+ ...fakeVertexAI ,
86
+ app : { options : { apiKey : 'my-key' , projectId : 'my-projectid' } }
87
+ } as VertexAI ;
88
+ try {
89
+ getGenerativeModel ( fakeVertexNoProject , { model : 'my-model' } ) ;
90
+ } catch ( e ) {
91
+ expect ( ( e as VertexAIError ) . code ) . includes ( VertexAIErrorCode . NO_APP_ID ) ;
92
+ expect ( ( e as VertexAIError ) . message ) . equals (
93
+ `VertexAI: The "appId" field is empty in the local` +
94
+ ` Firebase config. Firebase VertexAI requires this field ` +
95
+ `to contain a valid app ID. (vertexAI/${ VertexAIErrorCode . NO_APP_ID } )`
96
+ ) ;
97
+ }
98
+ } ) ;
82
99
it ( 'getGenerativeModel gets a GenerativeModel' , ( ) => {
83
100
const genModel = getGenerativeModel ( fakeVertexAI , { model : 'my-model' } ) ;
84
101
expect ( genModel ) . to . be . an . instanceOf ( GenerativeModel ) ;
@@ -98,7 +115,7 @@ describe('Top level API', () => {
98
115
it ( 'getImagenModel throws if no apiKey is provided' , ( ) => {
99
116
const fakeVertexNoApiKey = {
100
117
...fakeVertexAI ,
101
- app : { options : { projectId : 'my-project' } }
118
+ app : { options : { projectId : 'my-project' , appId : 'my-appid' } }
102
119
} as VertexAI ;
103
120
try {
104
121
getImagenModel ( fakeVertexNoApiKey , { model : 'my-model' } ) ;
@@ -114,7 +131,7 @@ describe('Top level API', () => {
114
131
it ( 'getImagenModel throws if no projectId is provided' , ( ) => {
115
132
const fakeVertexNoProject = {
116
133
...fakeVertexAI ,
117
- app : { options : { apiKey : 'my-key' } }
134
+ app : { options : { apiKey : 'my-key' , appId : 'my-appid' } }
118
135
} as VertexAI ;
119
136
try {
120
137
getImagenModel ( fakeVertexNoProject , { model : 'my-model' } ) ;
@@ -129,6 +146,22 @@ describe('Top level API', () => {
129
146
) ;
130
147
}
131
148
} ) ;
149
+ it ( 'getImagenModel throws if no appId is provided' , ( ) => {
150
+ const fakeVertexNoProject = {
151
+ ...fakeVertexAI ,
152
+ app : { options : { apiKey : 'my-key' , projectId : 'my-project' } }
153
+ } as VertexAI ;
154
+ try {
155
+ getImagenModel ( fakeVertexNoProject , { model : 'my-model' } ) ;
156
+ } catch ( e ) {
157
+ expect ( ( e as VertexAIError ) . code ) . includes ( VertexAIErrorCode . NO_APP_ID ) ;
158
+ expect ( ( e as VertexAIError ) . message ) . equals (
159
+ `VertexAI: The "appId" field is empty in the local` +
160
+ ` Firebase config. Firebase VertexAI requires this field ` +
161
+ `to contain a valid app ID. (vertexAI/${ VertexAIErrorCode . NO_APP_ID } )`
162
+ ) ;
163
+ }
164
+ } ) ;
132
165
it ( 'getImagenModel gets an ImagenModel' , ( ) => {
133
166
const genModel = getImagenModel ( fakeVertexAI , { model : 'my-model' } ) ;
134
167
expect ( genModel ) . to . be . an . instanceOf ( ImagenModel ) ;
0 commit comments