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: vendoring 4.77.0 #152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
8 changes: 4 additions & 4 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 @@ -44,6 +44,6 @@
"dependencies": {
"agentkeepalive": "^4.5.0",
"dotenv": "^16.3.1",
"openai": "4.55.3"
"openai": "4.77.0"
}
}
5 changes: 5 additions & 0 deletions src/apis/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ApiResource } from '../apiResource';
import { RequestOptions } from '../baseClient';
import { finalResponse, initOpenAIClient, overrideConfig } from '../utils';
import { createHeaders } from './createHeaders';
import { AssistantUpdateParams as oaiAssistantUpdateParams } from 'openai/resources/beta/assistants';

export interface AssistantCreateParams {
model: string;
Expand Down Expand Up @@ -46,6 +47,10 @@ export interface AssistantUpdateParams {
model?: string;
name?: string | null;
tools?: Array<any>;
response_format?: any | null;
temperature?: number | null;
tool_resources?: oaiAssistantUpdateParams.ToolResources | null;
top_p?: number | null;
[key: string]: any;
}

Expand Down
8 changes: 8 additions & 0 deletions src/apis/chatCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class ChatCompletions extends ApiResource {
export interface ChatCompletionsBodyBase extends ModelParams {
messages?: Array<Message>;
response_format?: object;
audio?: any | null;
modalities?: Array<any> | null;
prediction?: any | null;
reasoning_effort?: any;
store?: boolean | null;
metadata?: Record<string, string> | null;
max_completion_tokens?: number | null;
}

export interface ChatCompletionsBodyStreaming extends ChatCompletionsBodyBase {
Expand Down Expand Up @@ -89,6 +96,7 @@ interface Message {
function_call?: any;
tool_calls?: Array<ChatCompletionMessageToolCall>;
tool_call_id?: string;
[key: string]: any;
}

export interface Logprobs {
Expand Down
12 changes: 9 additions & 3 deletions src/apis/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ export interface CompletionsBodyBase extends ModelParams {
prompt: string;
}

export interface ChatCompletionStreamOptions {
include_usage?: boolean;
}

export interface CompletionsBodyStreaming extends CompletionsBodyBase {
stream?: true;
stream_options?: ChatCompletionStreamOptions | null;
}

export interface CompletionsBodyNonStreaming extends CompletionsBodyBase {
Expand All @@ -66,23 +71,23 @@ interface Usage {
prompt_tokens?: number;
completion_tokens?: number;
total_tokens?: number;
[key: string]: any;
}

interface Logprobs {
text_offset?: Array<number>;

token_logprobs?: Array<number>;

tokens?: Array<string>;

top_logprobs?: Array<Record<string, number>>;
[key: string]: any;
}

interface Choices {
index?: number;
text?: string;
logprobs: Logprobs;
finish_reason?: string;
[key: string]: any;
}

interface TextCompletion extends APIResponseType {
Expand All @@ -93,4 +98,5 @@ interface TextCompletion extends APIResponseType {
choices: Array<Choices>;
usage?: Usage;
system_fingerprint?: string;
[key: string]: any;
}
21 changes: 20 additions & 1 deletion src/apis/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,26 @@ export interface EmbeddingsBody extends ModelParams {
encoding_format?: string;
}

export type EmbeddingsResponse = Record<string, any> & APIResponseType;
export interface EmbeddingArr {
embedding?: Array<number>;
index?: number;
object?: string;
[key: string]: any;
}

export interface Usage {
prompt_tokens?: number;
total_tokens?: number;
[key: string]: any;
}

interface EmbeddingsResponse extends APIResponseType {
data?: Array<EmbeddingArr>;
model?: string;
object?: string;
usage?: Usage;
[key: string]: any;
}

export class Embeddings extends ApiResource {
create(
Expand Down
33 changes: 33 additions & 0 deletions src/apis/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,37 @@ export class MainFiles extends ApiResource {

return finalResponse(result);
}

async waitForProcessing(
id: string,
_body: PollOptions,
params?: ApiClientInterface
): Promise<FileObject> {
const body: PollOptions = _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.files.waitForProcessing(id, {
...(body.pollInterval !== undefined && {
pollInterval: body.pollInterval,
}),
...(body.maxWait !== undefined && { maxWait: body.maxWait }),
});

return result;
}
}

interface PollOptions {
pollInterval?: number | undefined;
maxWait?: number | undefined;
}

export interface FileCreateParams {
Expand All @@ -145,9 +176,11 @@ export interface FileObject {
purpose?: string;
status?: string;
status_details?: string;
[key: string]: any;
}

export interface FileListParams {
purpose?: string;
order?: 'asc' | 'desc';
[key: string]: any;
}
3 changes: 2 additions & 1 deletion src/apis/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ export interface ImageCreateVariationParams {

export interface ImagesResponse {
created: number;

data: Array<Image>;
[key: string]: any;
}

export interface Image {
b64_json?: string;
revised_prompt?: string;
url?: string;
[key: string]: any;
}

export class Images extends ApiResource {
Expand Down
60 changes: 60 additions & 0 deletions src/apis/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { ApiResource } from '../apiResource';
import { RequestOptions } from '../baseClient';
import { finalResponse, initOpenAIClient, overrideConfig } from '../utils';
import { createHeaders } from './createHeaders';
import {
ThreadCreateParams as oaiThreadCreateParams,
ThreadUpdateParams as oaiThreadUpdateParams,
ThreadCreateAndRunParams as oaiThreadCreateAndRunParams,
AssistantToolChoiceOption,
} from 'openai/resources/beta/threads/threads';

export class Threads extends ApiResource {
messages: Messages;
Expand Down Expand Up @@ -278,6 +284,29 @@ export class Messages extends ApiResource {

return finalResponse(result);
}

async del(
threadId: string,
messageId: 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.threads.messages
.del(threadId, messageId, opts)
.withResponse();

return finalResponse(result);
}
}

export class Runs extends ApiResource {
Expand Down Expand Up @@ -654,6 +683,7 @@ export class Steps extends ApiResource {
export interface ThreadCreateParams {
messages?: Array<Message>;
metadata?: unknown | null;
tool_resources?: oaiThreadCreateParams.ToolResources | null;
[key: string]: any;
}

Expand All @@ -666,19 +696,24 @@ export interface Message {

export interface ThreadUpdateParams {
metadata?: unknown | null;
tool_resources?: oaiThreadUpdateParams.ToolResources | null;
[key: string]: any;
}

export interface MessageCreateParams {
content: string;
role: string;
file_ids?: Array<string>;
attachments?: Array<any> | null;
metadata?: unknown | null;
[key: string]: any;
}

export interface MessageListParams extends CursorPageParams {
order?: string;
before?: string;
run_id?: string;
[key: string]: any;
}

export interface CursorPageParams {
Expand All @@ -705,6 +740,17 @@ export interface RunCreateParams {
model?: string | null;
tools?: Array<any> | null;
stream?: boolean | null;
include?: Array<any>;
additional_messages?: Array<any> | null;
max_completion_tokens?: number | null;
max_prompt_tokens?: number | null;
parallel_tool_calls?: boolean;
response_format?: any | null;
temperature?: number | null;
tool_choice?: any | null;
top_p?: number | null;
truncation_strategy?: any | null;
[key: string]: any;
}

export interface RunCreateParamsNonStreaming extends RunCreateParams {
Expand All @@ -719,6 +765,16 @@ export interface ThreadCreateAndRunParams {
thread?: any;
tools?: Array<any> | null;
stream?: boolean | null;
max_completion_tokens?: number | null;
max_prompt_tokens?: number | null;
parallel_tool_calls?: boolean;
response_format?: any | null;
temperature?: number | null;
tool_choice?: AssistantToolChoiceOption | null;
tool_resources?: oaiThreadCreateAndRunParams.ToolResources | null;
top_p?: number | null;
truncation_strategy?: oaiThreadCreateAndRunParams.TruncationStrategy | null;
[key: string]: any;
}

export interface ThreadCreateAndRunParamsNonStreaming
Expand All @@ -731,6 +787,7 @@ export type ThreadCreateAndRunParamsBaseStream = Omit<
'stream'
> & {
stream?: true;
assistant_id: string;
};

export interface RunListParams extends CursorPageParams {
Expand All @@ -741,6 +798,8 @@ export interface RunListParams extends CursorPageParams {
export interface StepListParams extends CursorPageParams {
before?: string;
order?: string;
include?: Array<any>;
[key: string]: any;
}

export interface RunUpdateParams {
Expand All @@ -760,6 +819,7 @@ export interface ToolOutput {

export type RunCreateParamsBaseStream = Omit<RunCreateParams, 'stream'> & {
stream?: true;
assistant_id: string;
};

export interface RunSubmitToolOutputsParamsNonStreaming
Expand Down
4 changes: 2 additions & 2 deletions src/apis/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export class Uploads extends ApiResource {

async complete(
uploadId: string,
_body: any,
_body: UploadCompleteParams,
params?: ApiClientInterface,
opts?: RequestOptions
): Promise<any> {
const body: any = _body;
const body: UploadCompleteParams = _body;
if (params) {
const config = overrideConfig(this.client.config, params.config);
this.client.customHeaders = {
Expand Down
Loading
Loading