diff --git a/package-lock.json b/package-lock.json index 1cef861..7b839d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "agentkeepalive": "^4.5.0", "dotenv": "^16.3.1", - "openai": "4.90.0", + "openai": "4.98.0", "ws": "^8.18.1" }, "devDependencies": { @@ -5576,9 +5576,9 @@ } }, "node_modules/openai": { - "version": "4.90.0", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.90.0.tgz", - "integrity": "sha512-YCuHMMycqtCg1B8G9ezkOF0j8UnBWD3Al/zYaelpuXwU1yhCEv+Y4n9G20MnyGy6cH4GsFwOMrgstQ+bgG1PtA==", + "version": "4.98.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.98.0.tgz", + "integrity": "sha512-TmDKur1WjxxMPQAtLG5sgBSCJmX7ynTsGmewKzoDwl1fRxtbLOsiR0FA/AOAAtYUmP6azal+MYQuOENfdU+7yg==", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", diff --git a/package.json b/package.json index 05f2a8d..db2671f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dependencies": { "agentkeepalive": "^4.5.0", "dotenv": "^16.3.1", - "openai": "4.90.0", + "openai": "4.98.0", "ws": "^8.18.1" } } diff --git a/src/apis/evals.ts b/src/apis/evals.ts new file mode 100644 index 0000000..4c87365 --- /dev/null +++ b/src/apis/evals.ts @@ -0,0 +1,268 @@ +import { + EvalCreateParams, + EvalCreateResponse, + EvalListParams, + EvalRetrieveResponse, + EvalUpdateParams, + EvalUpdateResponse, +} from 'openai/resources/evals/evals'; +import { ApiResource } from '../apiResource'; +import { ApiClientInterface } from '../_types/generalTypes'; +import { RequestOptions } from '../baseClient'; +import { finalResponse, initOpenAIClient, overrideConfig } from '../utils'; +import { createHeaders } from './createHeaders'; +import { + RunCreateParams, + RunCreateResponse, + RunListParams, + RunRetrieveResponse, +} from 'openai/resources/evals/runs/runs'; +import { OutputItemListParams } from 'openai/resources/evals/runs/output-items'; + +export class Evals extends ApiResource { + runs: EvalsRuns; + constructor(client: any) { + super(client); + this.runs = new EvalsRuns(client); + } + + async create( + body: EvalCreateParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.create(body, opts); + return result; + } + + async retrieve( + evalId: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.retrieve(evalId, opts).withResponse(); + return finalResponse(result); + } + + async update( + evalId: string, + body: EvalUpdateParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals + .update(evalId, body, opts) + .withResponse(); + return finalResponse(result); + } + + async list( + query?: EvalListParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.list(query, opts).withResponse(); + return finalResponse(result); + } + + async del( + evalId: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.del(evalId, opts).withResponse(); + return finalResponse(result); + } +} + +export class EvalsRuns extends ApiResource { + outputItems: OutputItems; + constructor(client: any) { + super(client); + this.outputItems = new OutputItems(client); + } + + async create( + evalId: string, + body: RunCreateParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.runs + .create(evalId, body, opts) + .withResponse(); + return finalResponse(result); + } + + async retrieve( + evalId: string, + runId: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.runs + .retrieve(evalId, runId, opts) + .withResponse(); + return finalResponse(result); + } + + async list( + evalId: string, + query?: RunListParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.runs + .list(evalId, query, opts) + .withResponse(); + return finalResponse(result); + } + + async del( + evalId: string, + runId: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.runs + .del(evalId, runId, opts) + .withResponse(); + return finalResponse(result); + } + + async cancel( + evalId: string, + runId: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.runs + .cancel(evalId, runId, opts) + .withResponse(); + return finalResponse(result); + } +} + +export class OutputItems extends ApiResource { + async retrieve( + evalId: string, + runId: string, + outputItemId: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.runs.outputItems + .retrieve(evalId, runId, outputItemId, opts) + .withResponse(); + return finalResponse(result); + } + + async list( + evalId: string, + runId: string, + query?: OutputItemListParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.evals.runs.outputItems + .list(evalId, runId, query, opts) + .withResponse(); + return finalResponse(result); + } +} diff --git a/src/apis/fineTuning.ts b/src/apis/fineTuning.ts index f052f95..eec2dd0 100644 --- a/src/apis/fineTuning.ts +++ b/src/apis/fineTuning.ts @@ -9,12 +9,24 @@ import { RequestOptions } from '../baseClient'; import { finalResponse, initOpenAIClient, overrideConfig } from '../utils'; import { createHeaders } from './createHeaders'; import { CheckpointListParams } from 'openai/resources/fine-tuning/jobs/checkpoints'; +import { + PermissionCreateParams, + PermissionRetrieveParams, +} from 'openai/resources/fine-tuning/checkpoints/permissions'; +import { + GraderRunParams, + GraderValidateParams, +} from 'openai/resources/fine-tuning/alpha/graders'; export class FineTuning extends ApiResource { jobs: Jobs; + checkpoints: FineTuningCheckpoints; + alpha: Alpha; constructor(client: any) { super(client); this.jobs = new Jobs(client); + this.checkpoints = new FineTuningCheckpoints(client); + this.alpha = new Alpha(client); } } @@ -162,6 +174,55 @@ export class Checkpoints extends ApiResource { } } +export class Alpha extends ApiResource { + grader: Grader; + constructor(client: any) { + super(client); + this.grader = new Grader(client); + } +} + +export class Grader extends ApiResource { + async run( + body: GraderRunParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.fineTuning.alpha.graders + .run(body, opts) + .withResponse(); + return finalResponse(result); + } + + async validate( + body: GraderValidateParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.fineTuning.alpha.graders + .validate(body, opts) + .withResponse(); + return finalResponse(result); + } +} + export interface JobCreateBody extends JobCreateParams { role_arn: string; job_name: string; @@ -170,3 +231,74 @@ export interface JobCreateBody extends JobCreateParams { portkey_options: Record; [key: string]: any; } + +export class FineTuningCheckpoints extends ApiResource { + permissions: Permissions; + + constructor(client: any) { + super(client); + this.permissions = new Permissions(client); + } +} + +export class Permissions extends ApiResource { + async create( + fineTunedModelCheckpoint: string, + body: PermissionCreateParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.fineTuning.checkpoints.permissions + .create(fineTunedModelCheckpoint, body, opts) + .withResponse(); + return finalResponse(result); + } + + async retrieve( + fineTunedModelCheckpoint: string, + query?: PermissionRetrieveParams, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.fineTuning.checkpoints.permissions + .retrieve(fineTunedModelCheckpoint, query, opts) + .withResponse(); + return finalResponse(result); + } + + async del( + fineTunedModelCheckpoint: string, + permissionId: string, + params?: ApiClientInterface, + opts?: RequestOptions + ): Promise { + if (params) { + const config = overrideConfig(this.client.config, params.config); + this.client.customHeaders = { + ...this.client.customHeaders, + ...createHeaders({ ...params, config }), + }; + } + const OAIclient = initOpenAIClient(this.client); + const result = await OAIclient.fineTuning.checkpoints.permissions + .del(fineTunedModelCheckpoint, permissionId, opts) + .withResponse(); + return finalResponse(result); + } +} diff --git a/src/apis/index.ts b/src/apis/index.ts index 2c0df0f..5a916ae 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -26,3 +26,4 @@ export { Realtime } from './realtime'; export { Responses } from './responses'; export { Labels } from './labels'; export { Collections } from './collections'; +export { Evals } from './evals'; diff --git a/src/client.ts b/src/client.ts index f713345..04d540a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -200,6 +200,7 @@ export class Portkey extends ApiClient { audio = new API.Audio(this); uploads = new API.Uploads(this); responses = new API.Responses(this); + evals = new API.Evals(this); admin = new API.Admin(this); virtualKeys = new API.VirtualKeys(this); apiKeys = new API.ApiKeys(this);