Skip to content

Commit 4b6ab32

Browse files
committed
Replace 'vertexAI' error prefix with 'AI'
1 parent 44870ba commit 4b6ab32

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

packages/vertexai/src/api.test.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { expect } from 'chai';
2121
import { AI } from './public-types';
2222
import { GenerativeModel } from './models/generative-model';
2323
import { VertexAIBackend } from './backend';
24+
import { AI_TYPE } from './constants';
2425

2526
const fakeAI: AI = {
2627
app: {
@@ -43,8 +44,8 @@ describe('Top level API', () => {
4344
} catch (e) {
4445
expect((e as AIError).code).includes(AIErrorCode.NO_MODEL);
4546
expect((e as AIError).message).includes(
46-
`VertexAI: Must provide a model name. Example: ` +
47-
`getGenerativeModel({ model: 'my-model-name' }) (vertexAI/${AIErrorCode.NO_MODEL})`
47+
`AI: Must provide a model name. Example: ` +
48+
`getGenerativeModel({ model: 'my-model-name' }) (${AI_TYPE}/${AIErrorCode.NO_MODEL})`
4849
);
4950
}
5051
});
@@ -58,9 +59,9 @@ describe('Top level API', () => {
5859
} catch (e) {
5960
expect((e as AIError).code).includes(AIErrorCode.NO_API_KEY);
6061
expect((e as AIError).message).equals(
61-
`VertexAI: The "apiKey" field is empty in the local ` +
62+
`AI: The "apiKey" field is empty in the local ` +
6263
`Firebase config. Firebase AI requires this field to` +
63-
` contain a valid API key. (vertexAI/${AIErrorCode.NO_API_KEY})`
64+
` contain a valid API key. (${AI_TYPE}/${AIErrorCode.NO_API_KEY})`
6465
);
6566
}
6667
});
@@ -74,9 +75,9 @@ describe('Top level API', () => {
7475
} catch (e) {
7576
expect((e as AIError).code).includes(AIErrorCode.NO_PROJECT_ID);
7677
expect((e as AIError).message).equals(
77-
`VertexAI: The "projectId" field is empty in the local` +
78+
`AI: The "projectId" field is empty in the local` +
7879
` Firebase config. Firebase AI requires this field ` +
79-
`to contain a valid project ID. (vertexAI/${AIErrorCode.NO_PROJECT_ID})`
80+
`to contain a valid project ID. (${AI_TYPE}/${AIErrorCode.NO_PROJECT_ID})`
8081
);
8182
}
8283
});
@@ -90,9 +91,9 @@ describe('Top level API', () => {
9091
} catch (e) {
9192
expect((e as AIError).code).includes(AIErrorCode.NO_APP_ID);
9293
expect((e as AIError).message).equals(
93-
`VertexAI: The "appId" field is empty in the local` +
94+
`AI: The "appId" field is empty in the local` +
9495
` Firebase config. Firebase AI requires this field ` +
95-
`to contain a valid app ID. (vertexAI/${AIErrorCode.NO_APP_ID})`
96+
`to contain a valid app ID. (${AI_TYPE}/${AIErrorCode.NO_APP_ID})`
9697
);
9798
}
9899
});
@@ -107,8 +108,8 @@ describe('Top level API', () => {
107108
} catch (e) {
108109
expect((e as AIError).code).includes(AIErrorCode.NO_MODEL);
109110
expect((e as AIError).message).includes(
110-
`VertexAI: Must provide a model name. Example: ` +
111-
`getImagenModel({ model: 'my-model-name' }) (vertexAI/${AIErrorCode.NO_MODEL})`
111+
`AI: Must provide a model name. Example: ` +
112+
`getImagenModel({ model: 'my-model-name' }) (${AI_TYPE}/${AIErrorCode.NO_MODEL})`
112113
);
113114
}
114115
});
@@ -122,9 +123,9 @@ describe('Top level API', () => {
122123
} catch (e) {
123124
expect((e as AIError).code).includes(AIErrorCode.NO_API_KEY);
124125
expect((e as AIError).message).equals(
125-
`VertexAI: The "apiKey" field is empty in the local ` +
126+
`AI: The "apiKey" field is empty in the local ` +
126127
`Firebase config. Firebase AI requires this field to` +
127-
` contain a valid API key. (vertexAI/${AIErrorCode.NO_API_KEY})`
128+
` contain a valid API key. (${AI_TYPE}/${AIErrorCode.NO_API_KEY})`
128129
);
129130
}
130131
});
@@ -138,9 +139,9 @@ describe('Top level API', () => {
138139
} catch (e) {
139140
expect((e as AIError).code).includes(AIErrorCode.NO_PROJECT_ID);
140141
expect((e as AIError).message).equals(
141-
`VertexAI: The "projectId" field is empty in the local` +
142+
`AI: The "projectId" field is empty in the local` +
142143
` Firebase config. Firebase AI requires this field ` +
143-
`to contain a valid project ID. (vertexAI/${AIErrorCode.NO_PROJECT_ID})`
144+
`to contain a valid project ID. (${AI_TYPE}/${AIErrorCode.NO_PROJECT_ID})`
144145
);
145146
}
146147
});
@@ -154,9 +155,9 @@ describe('Top level API', () => {
154155
} catch (e) {
155156
expect((e as AIError).code).includes(AIErrorCode.NO_APP_ID);
156157
expect((e as AIError).message).equals(
157-
`VertexAI: The "appId" field is empty in the local` +
158+
`AI: The "appId" field is empty in the local` +
158159
` Firebase config. Firebase AI requires this field ` +
159-
`to contain a valid app ID. (vertexAI/${AIErrorCode.NO_APP_ID})`
160+
`to contain a valid app ID. (${AI_TYPE}/${AIErrorCode.NO_APP_ID})`
160161
);
161162
}
162163
});

packages/vertexai/src/errors.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { FirebaseError } from '@firebase/util';
1919
import { AIErrorCode, CustomErrorData } from './types';
20-
import { VERTEX_TYPE } from './constants';
20+
import { AI_TYPE } from './constants';
2121

2222
/**
2323
* Error class for the Firebase AI SDK.
@@ -38,10 +38,9 @@ export class AIError extends FirebaseError {
3838
readonly customErrorData?: CustomErrorData
3939
) {
4040
// Match error format used by FirebaseError from ErrorFactory
41-
const service = VERTEX_TYPE; // TODO (v12): Rename to GENAI_TYPE on breaking release.
42-
const serviceName = 'VertexAI'; // TODO (v12): Rename to AI on breaking release.
41+
const service = AI_TYPE;
4342
const fullCode = `${service}/${code}`;
44-
const fullMessage = `${serviceName}: ${message} (${fullCode})`;
43+
const fullMessage = `${service}: ${message} (${fullCode})`;
4544
super(code, fullMessage);
4645

4746
// FirebaseError initializes a stack trace, but it assumes the error is created from the error

packages/vertexai/src/helpers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('Identifier Encoding/Decoding', () => {
110110
});
111111

112112
it('should throw AIError for malformed identifier string (incorrect prefix)', () => {
113-
const encoded = 'firebase/vertexai/location';
113+
const encoded = 'firebase/AI/location';
114114
// This will also hit the default case in the switch statement
115115
expect(() => decodeInstanceIdentifier(encoded)).to.throw(
116116
AIError,

0 commit comments

Comments
 (0)