Skip to content

Commit

Permalink
Remove apiVersion and location options (#8124)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Apr 4, 2024
1 parent d27cd8e commit bf7d2d8
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 61 deletions.
9 changes: 3 additions & 6 deletions packages/vertexai/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Provider } from '@firebase/component';
import { getModularInstance } from '@firebase/util';
import { DEFAULT_LOCATION, VERTEX_TYPE } from './constants';
import { VertexAIService } from './service';
import { VertexAI, VertexAIOptions } from './public-types';
import { VertexAI } from './public-types';
import { ERROR_FACTORY, VertexError } from './errors';
import { ModelParams, RequestOptions } from './types';
import { GenerativeModel } from './models/generative-model';
Expand All @@ -42,16 +42,13 @@ declare module '@firebase/component' {
*
* @param app - The {@link @firebase/app#FirebaseApp} to use.
*/
export function getVertexAI(
app: FirebaseApp = getApp(),
options?: VertexAIOptions
): VertexAI {
export function getVertexAI(app: FirebaseApp = getApp()): VertexAI {
app = getModularInstance(app);
// Dependencies
const vertexProvider: Provider<'vertex'> = _getProvider(app, VERTEX_TYPE);

return vertexProvider.getImmediate({
identifier: options?.location || DEFAULT_LOCATION
identifier: DEFAULT_LOCATION
});
}

Expand Down
27 changes: 0 additions & 27 deletions packages/vertexai/src/index.test.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/vertexai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ function registerVertex(): void {
_registerComponent(
new Component(
VERTEX_TYPE,
(container, { instanceIdentifier: location }) => {
container => {
// getImmediate for FirebaseApp will always succeed
const app = container.getProvider('app').getImmediate();
const appCheckProvider = container.getProvider('app-check-internal');
return new VertexAIService(app, appCheckProvider, { location });
return new VertexAIService(app, appCheckProvider);
},
ComponentType.PUBLIC
).setMultipleInstances(true)
Expand Down
4 changes: 0 additions & 4 deletions packages/vertexai/src/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ export interface VertexAI {
app: FirebaseApp;
location: string;
}

export interface VertexAIOptions {
location?: string;
}
12 changes: 0 additions & 12 deletions packages/vertexai/src/requests/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ describe('request methods', () => {
);
expect(url.toString()).to.include(DEFAULT_API_VERSION);
});
it('custom apiVersion', async () => {
const url = new RequestUrl(
'models/model-name',
Task.GENERATE_CONTENT,
fakeApiSettings,
false,
{ apiVersion: 'v100omega' }
);
expect(url.toString()).to.include(
'/v100omega/projects/my-project/locations/us-central1/models/model-name'
);
});
it('custom baseUrl', async () => {
const url = new RequestUrl(
'models/model-name',
Expand Down
3 changes: 2 additions & 1 deletion packages/vertexai/src/requests/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class RequestUrl {
public requestOptions?: RequestOptions
) {}
toString(): string {
const apiVersion = this.requestOptions?.apiVersion || DEFAULT_API_VERSION;
// TODO: allow user-set option if that feature becomes available
const apiVersion = DEFAULT_API_VERSION;
const baseUrl = this.requestOptions?.baseUrl || DEFAULT_BASE_URL;
let url = `${baseUrl}/${apiVersion}`;
url += `/projects/${this.apiSettings.project}`;
Expand Down
8 changes: 4 additions & 4 deletions packages/vertexai/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { FirebaseApp, _FirebaseService } from '@firebase/app';
import { VertexAI, VertexAIOptions } from './public-types';
import { VertexAI } from './public-types';
import {
AppCheckInternalComponentName,
FirebaseAppCheckInternal
Expand All @@ -30,12 +30,12 @@ export class VertexAIService implements VertexAI, _FirebaseService {

constructor(
public app: FirebaseApp,
appCheckProvider?: Provider<AppCheckInternalComponentName>,
public options?: VertexAIOptions
appCheckProvider?: Provider<AppCheckInternalComponentName>
) {
const appCheck = appCheckProvider?.getImmediate({ optional: true });
this.appCheck = appCheck || null;
this.location = this.options?.location || DEFAULT_LOCATION;
// TODO: add in user-set location option when that feature is available
this.location = DEFAULT_LOCATION;
}

_delete(): Promise<void> {
Expand Down
5 changes: 0 additions & 5 deletions packages/vertexai/src/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ export interface RequestOptions {
* Request timeout in milliseconds.
*/
timeout?: number;
/**
* Version of API endpoint to call (e.g. "v1" or "v1beta"). If not specified,
* defaults to latest stable version.
*/
apiVersion?: string;
/**
* Base url for endpoint. Defaults to https://firebaseml.googleapis.com
*/
Expand Down

0 comments on commit bf7d2d8

Please sign in to comment.