Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove apiVersion and location options #8124

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 { VertexService } from './service';
import { Vertex, VertexOptions } from './public-types';
import { Vertex } 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 getVertex(
app: FirebaseApp = getApp(),
options?: VertexOptions
): Vertex {
export function getVertex(app: FirebaseApp = getApp()): Vertex {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be getVertexAI now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this in the merge with the other PR.

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 VertexService(app, appCheckProvider, { location });
return new VertexService(app, appCheckProvider);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VertexAIService?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in the merge.

},
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 Vertex {
app: FirebaseApp;
location: string;
}

export interface VertexOptions {
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 { Vertex, VertexOptions } from './public-types';
import { Vertex } from './public-types';
import {
AppCheckInternalComponentName,
FirebaseAppCheckInternal
Expand All @@ -30,12 +30,12 @@ export class VertexService implements Vertex, _FirebaseService {

constructor(
public app: FirebaseApp,
appCheckProvider?: Provider<AppCheckInternalComponentName>,
public options?: VertexOptions
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