Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api-report/genai-node.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ export interface CancelTuningJobParameters {
name: string;
}

// @public
export class CancelTuningJobResponse {
sdkHttpResponse?: HttpResponse;
}

// @public
export interface Candidate {
avgLogprobs?: number;
Expand Down
5 changes: 5 additions & 0 deletions api-report/genai-web.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ export interface CancelTuningJobParameters {
name: string;
}

// @public
export class CancelTuningJobResponse {
sdkHttpResponse?: HttpResponse;
}

// @public
export interface Candidate {
avgLogprobs?: number;
Expand Down
5 changes: 5 additions & 0 deletions api-report/genai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ export interface CancelTuningJobParameters {
name: string;
}

// @public
export class CancelTuningJobResponse {
sdkHttpResponse?: HttpResponse;
}

// @public
export interface Candidate {
avgLogprobs?: number;
Expand Down
32 changes: 32 additions & 0 deletions src/converters/_tunings_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,38 @@ export function cancelTuningJobParametersToVertex(
return toObject;
}

export function cancelTuningJobResponseFromMldev(
fromObject: types.CancelTuningJobResponse,
_rootObject?: unknown,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromSdkHttpResponse = common.getValueByPath(fromObject, [
'sdkHttpResponse',
]);
if (fromSdkHttpResponse != null) {
common.setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
}

return toObject;
}

export function cancelTuningJobResponseFromVertex(
fromObject: types.CancelTuningJobResponse,
_rootObject?: unknown,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromSdkHttpResponse = common.getValueByPath(fromObject, [
'sdkHttpResponse',
]);
if (fromSdkHttpResponse != null) {
common.setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
}

return toObject;
}

export function createTuningJobConfigToMldev(
fromObject: types.CreateTuningJobConfig,
parentObject: Record<string, unknown>,
Expand Down
68 changes: 53 additions & 15 deletions src/tunings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ export class Tunings extends BaseModule {
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
* ```
*/
async cancel(params: types.CancelTuningJobParameters): Promise<void> {
async cancel(
params: types.CancelTuningJobParameters,
): Promise<types.CancelTuningJobResponse> {
let response: Promise<types.CancelTuningJobResponse>;

let path: string = '';
let queryParams: Record<string, string> = {};
if (this.apiClient.isVertexAI()) {
Expand All @@ -293,13 +297,30 @@ export class Tunings extends BaseModule {
delete body['_url'];
delete body['_query'];

await this.apiClient.request({
path: path,
queryParams: queryParams,
body: JSON.stringify(body),
httpMethod: 'POST',
httpOptions: params.config?.httpOptions,
abortSignal: params.config?.abortSignal,
response = this.apiClient
.request({
path: path,
queryParams: queryParams,
body: JSON.stringify(body),
httpMethod: 'POST',
httpOptions: params.config?.httpOptions,
abortSignal: params.config?.abortSignal,
})
.then((httpResponse) => {
return httpResponse.json().then((jsonResponse) => {
const response = jsonResponse as types.CancelTuningJobResponse;
response.sdkHttpResponse = {
headers: httpResponse.headers,
} as types.HttpResponse;
return response;
});
}) as Promise<types.CancelTuningJobResponse>;

return response.then((apiResponse) => {
const resp = converters.cancelTuningJobResponseFromVertex(apiResponse);
const typedResp = new types.CancelTuningJobResponse();
Object.assign(typedResp, resp);
return typedResp;
});
} else {
const body = converters.cancelTuningJobParametersToMldev(params, params);
Expand All @@ -311,13 +332,30 @@ export class Tunings extends BaseModule {
delete body['_url'];
delete body['_query'];

await this.apiClient.request({
path: path,
queryParams: queryParams,
body: JSON.stringify(body),
httpMethod: 'POST',
httpOptions: params.config?.httpOptions,
abortSignal: params.config?.abortSignal,
response = this.apiClient
.request({
path: path,
queryParams: queryParams,
body: JSON.stringify(body),
httpMethod: 'POST',
httpOptions: params.config?.httpOptions,
abortSignal: params.config?.abortSignal,
})
.then((httpResponse) => {
return httpResponse.json().then((jsonResponse) => {
const response = jsonResponse as types.CancelTuningJobResponse;
response.sdkHttpResponse = {
headers: httpResponse.headers,
} as types.HttpResponse;
return response;
});
}) as Promise<types.CancelTuningJobResponse>;

return response.then((apiResponse) => {
const resp = converters.cancelTuningJobResponseFromMldev(apiResponse);
const typedResp = new types.CancelTuningJobResponse();
Object.assign(typedResp, resp);
return typedResp;
});
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4392,6 +4392,12 @@ export declare interface CancelTuningJobParameters {
config?: CancelTuningJobConfig;
}

/** Empty response for tunings.cancel method. */
export class CancelTuningJobResponse {
/** Used to retain the full HTTP response. */
sdkHttpResponse?: HttpResponse;
}

/** A single example for tuning. This data type is not supported in Vertex AI. */
export declare interface TuningExample {
/** Required. The expected model output. */
Expand Down