diff --git a/src/_shims/index.js b/src/_shims/index.js index b5fc8229..54d85efc 100644 --- a/src/_shims/index.js +++ b/src/_shims/index.js @@ -2,7 +2,7 @@ * Disclaimer: modules in _shims aren't intended to be imported by SDK users. */ const shims = require('./registry'); -const auto = require('openai/_shims/auto/runtime'); +const auto = require('../_shims/auto/runtime'); if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true }); for (const property of Object.keys(shims)) { Object.defineProperty(exports, property, { diff --git a/src/_shims/index.mjs b/src/_shims/index.mjs index 81665e61..b2a5c6b0 100644 --- a/src/_shims/index.mjs +++ b/src/_shims/index.mjs @@ -2,6 +2,6 @@ * Disclaimer: modules in _shims aren't intended to be imported by SDK users. */ import * as shims from './registry.mjs'; -import * as auto from 'openai/_shims/auto/runtime'; +import * as auto from '../_shims/auto/runtime'; if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true }); export * from './registry.mjs'; diff --git a/src/index.ts b/src/index.ts index f65eefe3..897b4803 100644 --- a/src/index.ts +++ b/src/index.ts @@ -293,6 +293,7 @@ export namespace OpenAI { export import Model = API.Model; export import ModelDeleted = API.ModelDeleted; export import ModelsPage = API.ModelsPage; + export import ThreadsPage = API.Beta.ThreadsPage; export import FineTuning = API.FineTuning; diff --git a/src/lib/AbstractAssistantStreamRunner.ts b/src/lib/AbstractAssistantStreamRunner.ts index b600f0df..39bddbd3 100644 --- a/src/lib/AbstractAssistantStreamRunner.ts +++ b/src/lib/AbstractAssistantStreamRunner.ts @@ -1,5 +1,5 @@ -import * as Core from 'openai/core'; -import { APIUserAbortError, OpenAIError } from 'openai/error'; +import * as Core from '../core'; +import { APIUserAbortError, OpenAIError } from '../error'; import { Run, RunSubmitToolOutputsParamsBase } from 'openai/resources/beta/threads/runs/runs'; import { RunCreateParamsBase, Runs } from 'openai/resources/beta/threads/runs/runs'; import { ThreadCreateAndRunParamsBase, Threads } from 'openai/resources/beta/threads/threads'; diff --git a/src/lib/AbstractChatCompletionRunner.ts b/src/lib/AbstractChatCompletionRunner.ts index 8a8f4670..19196cb8 100644 --- a/src/lib/AbstractChatCompletionRunner.ts +++ b/src/lib/AbstractChatCompletionRunner.ts @@ -1,4 +1,4 @@ -import * as Core from 'openai/core'; +import * as Core from '../core'; import { type CompletionUsage } from 'openai/resources/completions'; import { type Completions, @@ -8,7 +8,7 @@ import { type ChatCompletionCreateParams, type ChatCompletionTool, } from 'openai/resources/chat/completions'; -import { APIUserAbortError, OpenAIError } from 'openai/error'; +import { APIUserAbortError, OpenAIError } from '../error'; import { type RunnableFunction, isRunnableFunctionWithParse, diff --git a/src/lib/AssistantStream.ts b/src/lib/AssistantStream.ts index de7511b5..4545ac52 100644 --- a/src/lib/AssistantStream.ts +++ b/src/lib/AssistantStream.ts @@ -9,8 +9,8 @@ import { Messages, MessageContent, } from 'openai/resources/beta/threads/messages'; -import * as Core from 'openai/core'; -import { RequestOptions } from 'openai/core'; +import * as Core from '../core'; +import { RequestOptions } from '../core'; import { Run, RunCreateParamsBase, @@ -24,8 +24,8 @@ import { AbstractAssistantStreamRunner, } from './AbstractAssistantStreamRunner'; import { type ReadableStream } from 'openai/_shims/index'; -import { Stream } from 'openai/streaming'; -import { APIUserAbortError, OpenAIError } from 'openai/error'; +import { Stream } from '../streaming'; +import { APIUserAbortError, OpenAIError } from '../error'; import { AssistantStreamEvent, MessageStreamEvent, diff --git a/src/lib/ChatCompletionRunFunctions.test.ts b/src/lib/ChatCompletionRunFunctions.test.ts index b524218a..17694fb0 100644 --- a/src/lib/ChatCompletionRunFunctions.test.ts +++ b/src/lib/ChatCompletionRunFunctions.test.ts @@ -1,5 +1,5 @@ import OpenAI from 'openai'; -import { OpenAIError, APIConnectionError } from 'openai/error'; +import { OpenAIError, APIConnectionError } from '../error'; import { PassThrough } from 'stream'; import { ParsingToolFunction, diff --git a/src/lib/ChatCompletionStream.ts b/src/lib/ChatCompletionStream.ts index 2ea04038..f24a0992 100644 --- a/src/lib/ChatCompletionStream.ts +++ b/src/lib/ChatCompletionStream.ts @@ -1,5 +1,5 @@ -import * as Core from 'openai/core'; -import { OpenAIError, APIUserAbortError } from 'openai/error'; +import * as Core from '../core'; +import { OpenAIError, APIUserAbortError } from '../error'; import { Completions, type ChatCompletion, @@ -12,7 +12,7 @@ import { type AbstractChatCompletionRunnerEvents, } from './AbstractChatCompletionRunner'; import { type ReadableStream } from 'openai/_shims/index'; -import { Stream } from 'openai/streaming'; +import { Stream } from '../streaming'; export interface ChatCompletionStreamEvents extends AbstractChatCompletionRunnerEvents { content: (contentDelta: string, contentSnapshot: string) => void; diff --git a/src/resources/beta/beta.ts b/src/resources/beta/beta.ts index cefe6682..9149a064 100644 --- a/src/resources/beta/beta.ts +++ b/src/resources/beta/beta.ts @@ -39,6 +39,7 @@ export namespace Beta { export import AssistantUpdateParams = AssistantsAPI.AssistantUpdateParams; export import AssistantListParams = AssistantsAPI.AssistantListParams; export import Threads = ThreadsAPI.Threads; + export import ThreadsPage = ThreadsAPI.ThreadsPage; export import AssistantResponseFormat = ThreadsAPI.AssistantResponseFormat; export import AssistantResponseFormatOption = ThreadsAPI.AssistantResponseFormatOption; export import AssistantToolChoice = ThreadsAPI.AssistantToolChoice; diff --git a/src/resources/beta/index.ts b/src/resources/beta/index.ts index 029cd084..2d7ecb59 100644 --- a/src/resources/beta/index.ts +++ b/src/resources/beta/index.ts @@ -34,6 +34,7 @@ export { ThreadCreateAndRunPollParams, ThreadCreateAndRunStreamParams, Threads, + ThreadsPage, } from './threads/index'; export { Beta } from './beta'; export { Chat } from './chat/index'; diff --git a/src/resources/beta/threads/index.ts b/src/resources/beta/threads/index.ts index b55f67ed..79d85b2b 100644 --- a/src/resources/beta/threads/index.ts +++ b/src/resources/beta/threads/index.ts @@ -49,6 +49,7 @@ export { ThreadCreateAndRunPollParams, ThreadCreateAndRunStreamParams, Threads, + ThreadsPage, } from './threads'; export { RequiredActionFunctionToolCall, diff --git a/src/resources/beta/threads/threads.ts b/src/resources/beta/threads/threads.ts index 27009437..709b5a3a 100644 --- a/src/resources/beta/threads/threads.ts +++ b/src/resources/beta/threads/threads.ts @@ -10,7 +10,7 @@ import * as AssistantsAPI from '../assistants'; import * as MessagesAPI from './messages'; import * as RunsAPI from './runs/runs'; import { Stream } from '../../../streaming'; -import { Page } from 'openai/pagination'; +import { Page } from '../../../pagination'; /** * Note: no pagination actually occurs yet, this is for forwards-compatibility. @@ -68,6 +68,13 @@ export class Threads extends APIResource { }); } + /** + * Clean up a thread. + */ + clean(threadId: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post(`/threads/${threadId}/clean`); + } + /** * Delete a thread. */ @@ -1489,6 +1496,7 @@ export namespace Threads { export import AssistantToolChoiceFunction = ThreadsAPI.AssistantToolChoiceFunction; export import AssistantToolChoiceOption = ThreadsAPI.AssistantToolChoiceOption; export import Thread = ThreadsAPI.Thread; + export import ThreadsPage = ThreadsAPI.ThreadsPage; export import ThreadDeleted = ThreadsAPI.ThreadDeleted; export import ThreadCreateParams = ThreadsAPI.ThreadCreateParams; export import ThreadUpdateParams = ThreadsAPI.ThreadUpdateParams; diff --git a/src/resources/models.ts b/src/resources/models.ts index f15422e3..f7c390cf 100644 --- a/src/resources/models.ts +++ b/src/resources/models.ts @@ -43,6 +43,24 @@ export class Models extends APIResource { stop(model: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.post(`/models/${model}/stop`, options); } + + /** + * Download a model. + */ + download(model: string) { + return this._client.get(`/models/download/${model}`); + } + + /** + * Abort a model download. + */ + abortDownload(downloadId: string) { + return this._client.get(`/models/abort-download/${downloadId}`); + } + + update(model: string, body: Record, options?: Core.RequestOptions) { + return this._client.post(`/models/${model}/config`, { body, ...options }); + } } /** diff --git a/src/streaming.ts b/src/streaming.ts index 722a8f69..64cb2efd 100644 --- a/src/streaming.ts +++ b/src/streaming.ts @@ -1,7 +1,7 @@ import { ReadableStream, type Response } from './_shims/index'; import { OpenAIError } from './error'; -import { APIError } from 'openai/error'; +import { APIError } from './error'; type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;