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

Feat/oai4.55.3 #101

Merged
merged 17 commits into from
Sep 5, 2024
Merged
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
33 changes: 16 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"dependencies": {
"agentkeepalive": "^4.5.0",
"dotenv": "^16.3.1",
"openai": "4.36.0"
"openai": "4.55.3"
}
}
12 changes: 12 additions & 0 deletions src/_types/portkeyConstructs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,21 @@ export interface ModelParams {
logit_bias?: Record<string, number>;
user?: string;
organization?: string;
seed?: number;
response_format?: any;
service_tier?: string;
top_logprobs?: number | null;
parallel_tool_calls?: boolean;
tools?: Array<Tool>;
tool_choice?: any;
}

export interface Message {
role: string
content: string
}

export interface Tool {
type?: string;
function?: Record<string, any>
}
105 changes: 5 additions & 100 deletions src/apis/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import { createHeaders } from "./createHeaders";
export interface AssistantCreateParams {
model: string;
description?: string | null;
file_ids?: Array<string>;
instructions?: string | null;
metadata?: unknown | null;
name?: string | null;
tools?: Array<any>;
response_format?: any | null;
temperature?: number | null;
tool_resources?: any | null;
top_p?: number | null;

}

export interface FileCreateParams {
Expand Down Expand Up @@ -45,13 +49,6 @@ export interface AssistantUpdateParams {


export class Assistants extends ApiResource {

files: Files;

constructor(client:any) {
super(client);
this.files = new Files(client);
}

async create(
_body: AssistantCreateParams,
Expand Down Expand Up @@ -159,95 +156,3 @@ export class Assistants extends ApiResource {
}

}

export class Files extends ApiResource{

async create(
assistantId: string,
_body: FileCreateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
const body: FileCreateParams = _body;
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.beta.assistants.files.create(assistantId, body, opts).withResponse();

return finalResponse(result);
}

async list(
assistantId: string,
_query?: FileListParams,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
const query: FileListParams | undefined = _query;
if (params) {
const config = overrideConfig(this.client.config, params.config);
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params, config }),
};
}

const OAIclient = initOpenAIClient(this.client);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const result = await OAIclient.beta.assistants.files.list(assistantId, query, opts).withResponse();

return finalResponse(result);
}

async retrieve(
assistantId: string,
fileId: string,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
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.beta.assistants.files.retrieve(assistantId, fileId, opts).withResponse();

return finalResponse(result);
}

async del(
assistantId: string,
fileId: string,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
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.beta.assistants.files.del(assistantId, fileId, opts).withResponse();

return finalResponse(result);
}

}
83 changes: 83 additions & 0 deletions src/apis/audio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { TranscriptionCreateParams } from "openai/resources/audio/transcriptions";
import { ApiClientInterface } from "../_types/generalTypes";
import { ApiResource } from "../apiResource";
import { RequestOptions } from "../baseClient";
import { finalResponse, initOpenAIClient, overrideConfig } from "../utils";
import { createHeaders } from "./createHeaders";
import { TranslationCreateParams } from "openai/resources/audio/translations";
import { SpeechCreateParams } from "openai/resources/audio/speech";

export class Audio extends ApiResource {
transcriptions: transcriptions;
translations: translations;
speech: speech;

constructor(client: any) {
super(client);
this.transcriptions = new transcriptions(client);
this.translations = new translations(client);
this.speech = new speech(client);
}
}

export class transcriptions extends ApiResource{
async create(
_body: TranscriptionCreateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
const body: TranscriptionCreateParams = _body;
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 response = await OAIclient.audio.transcriptions.create(body, opts).withResponse();
return finalResponse(response);
}
}


export class translations extends ApiResource{
async create(
_body: TranslationCreateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
const body: TranslationCreateParams = _body;
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 response = await OAIclient.audio.translations.create(body, opts).withResponse();
return finalResponse(response);
}
}


export class speech extends ApiResource{
async create(
_body: SpeechCreateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
const body: SpeechCreateParams = _body;
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 response = await OAIclient.audio.speech.create(body, opts);
return response;
}
}
Loading
Loading