From 5d6188d685f371b219456f5b5251e0f33cc3fd27 Mon Sep 17 00:00:00 2001 From: Young-Jin Park Date: Fri, 1 Nov 2024 23:39:30 -0400 Subject: [PATCH] fix: change streaming helper imports to be relative --- src/lib/AbstractChatCompletionRunner.ts | 10 ++++----- src/lib/AssistantStream.ts | 26 ++++++++++++------------ src/lib/ChatCompletionRunner.ts | 6 +++--- src/lib/ChatCompletionStream.ts | 16 +++++++-------- src/lib/ChatCompletionStreamingRunner.ts | 8 ++++---- src/lib/EventStream.ts | 2 +- src/lib/chatCompletionUtils.ts | 2 +- src/lib/parser.ts | 2 +- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/lib/AbstractChatCompletionRunner.ts b/src/lib/AbstractChatCompletionRunner.ts index e943a4e4f..406f5a431 100644 --- a/src/lib/AbstractChatCompletionRunner.ts +++ b/src/lib/AbstractChatCompletionRunner.ts @@ -1,13 +1,13 @@ -import * as Core from 'openai/core'; -import { type CompletionUsage } from 'openai/resources/completions'; +import * as Core from '../core'; +import { type CompletionUsage } from '../resources/completions'; import { type ChatCompletion, type ChatCompletionMessage, type ChatCompletionMessageParam, type ChatCompletionCreateParams, type ChatCompletionTool, -} from 'openai/resources/chat/completions'; -import { OpenAIError } from 'openai/error'; +} from '../resources/chat/completions'; +import { OpenAIError } from '../error'; import { type RunnableFunction, isRunnableFunctionWithParse, @@ -23,7 +23,7 @@ import { isAssistantMessage, isFunctionMessage, isToolMessage } from './chatComp import { BaseEvents, EventStream } from './EventStream'; import { ParsedChatCompletion } from '../resources/beta/chat/completions'; import OpenAI from '../index'; -import { isAutoParsableTool, parseChatCompletion } from 'openai/lib/parser'; +import { isAutoParsableTool, parseChatCompletion } from '../lib/parser'; const DEFAULT_MAX_CHAT_COMPLETIONS = 10; export interface RunnerOptions extends Core.RequestOptions { diff --git a/src/lib/AssistantStream.ts b/src/lib/AssistantStream.ts index c826c910e..caf68e7dd 100644 --- a/src/lib/AssistantStream.ts +++ b/src/lib/AssistantStream.ts @@ -8,9 +8,9 @@ import { TextDelta, MessageDelta, MessageContent, -} from 'openai/resources/beta/threads/messages'; -import * as Core from 'openai/core'; -import { RequestOptions } from 'openai/core'; +} from '../resources/beta/threads/messages'; +import * as Core from '../core'; +import { RequestOptions } from '../core'; import { Run, RunCreateParamsBase, @@ -18,18 +18,18 @@ import { Runs, RunSubmitToolOutputsParamsBase, RunSubmitToolOutputsParamsStreaming, -} from 'openai/resources/beta/threads/runs/runs'; -import { type ReadableStream } from 'openai/_shims/index'; -import { Stream } from 'openai/streaming'; -import { APIUserAbortError, OpenAIError } from 'openai/error'; +} from '../resources/beta/threads/runs/runs'; +import { type ReadableStream } from '../_shims/index'; +import { Stream } from '../streaming'; +import { APIUserAbortError, OpenAIError } from '../error'; import { AssistantStreamEvent, MessageStreamEvent, RunStepStreamEvent, RunStreamEvent, -} from 'openai/resources/beta/assistants'; -import { RunStep, RunStepDelta, ToolCall, ToolCallDelta } from 'openai/resources/beta/threads/runs/steps'; -import { ThreadCreateAndRunParamsBase, Threads } from 'openai/resources/beta/threads/threads'; +} from '../resources/beta/assistants'; +import { RunStep, RunStepDelta, ToolCall, ToolCallDelta } from '../resources/beta/threads/runs/steps'; +import { ThreadCreateAndRunParamsBase, Threads } from '../resources/beta/threads/threads'; import { BaseEvents, EventStream } from './EventStream'; export interface AssistantStreamEvents extends BaseEvents { @@ -192,7 +192,7 @@ export class AssistantStream runs: Runs, params: RunSubmitToolOutputsParamsStream, options: RequestOptions | undefined, - ) { + ): AssistantStream { const runner = new AssistantStream(); runner._run(() => runner._runToolAssistantStream(threadId, runId, runs, params, { @@ -238,7 +238,7 @@ export class AssistantStream params: ThreadCreateAndRunParamsBaseStream, thread: Threads, options?: RequestOptions, - ) { + ): AssistantStream { const runner = new AssistantStream(); runner._run(() => runner._threadAssistantStream(params, thread, { @@ -254,7 +254,7 @@ export class AssistantStream runs: Runs, params: RunCreateParamsBaseStream, options?: RequestOptions, - ) { + ): AssistantStream { const runner = new AssistantStream(); runner._run(() => runner._runAssistantStream(threadId, runs, params, { diff --git a/src/lib/ChatCompletionRunner.ts b/src/lib/ChatCompletionRunner.ts index 0b962a110..9e68e6671 100644 --- a/src/lib/ChatCompletionRunner.ts +++ b/src/lib/ChatCompletionRunner.ts @@ -1,7 +1,7 @@ import { type ChatCompletionMessageParam, type ChatCompletionCreateParamsNonStreaming, -} from 'openai/resources/chat/completions'; +} from '../resources/chat/completions'; import { type RunnableFunctions, type BaseFunctionsArgs, RunnableTools } from './RunnableFunction'; import { AbstractChatCompletionRunner, @@ -9,8 +9,8 @@ import { RunnerOptions, } from './AbstractChatCompletionRunner'; import { isAssistantMessage } from './chatCompletionUtils'; -import OpenAI from 'openai/index'; -import { AutoParseableTool } from 'openai/lib/parser'; +import OpenAI from '../index'; +import { AutoParseableTool } from '../lib/parser'; export interface ChatCompletionRunnerEvents extends AbstractChatCompletionRunnerEvents { content: (content: string) => void; diff --git a/src/lib/ChatCompletionStream.ts b/src/lib/ChatCompletionStream.ts index e3661c8c1..a88f8a23b 100644 --- a/src/lib/ChatCompletionStream.ts +++ b/src/lib/ChatCompletionStream.ts @@ -1,10 +1,10 @@ -import * as Core from 'openai/core'; +import * as Core from '../core'; import { OpenAIError, APIUserAbortError, LengthFinishReasonError, ContentFilterFinishReasonError, -} from 'openai/error'; +} from '../error'; import { ChatCompletionTokenLogprob, type ChatCompletion, @@ -12,15 +12,15 @@ import { type ChatCompletionCreateParams, type ChatCompletionCreateParamsStreaming, type ChatCompletionCreateParamsBase, -} from 'openai/resources/chat/completions'; +} from '../resources/chat/completions'; import { AbstractChatCompletionRunner, type AbstractChatCompletionRunnerEvents, } from './AbstractChatCompletionRunner'; -import { type ReadableStream } from 'openai/_shims/index'; -import { Stream } from 'openai/streaming'; -import OpenAI from 'openai/index'; -import { ParsedChatCompletion } from 'openai/resources/beta/chat/completions'; +import { type ReadableStream } from '../_shims/index'; +import { Stream } from '../streaming'; +import OpenAI from '../index'; +import { ParsedChatCompletion } from '../resources/beta/chat/completions'; import { AutoParseableResponseFormat, hasAutoParseableInput, @@ -28,7 +28,7 @@ import { isAutoParsableTool, maybeParseChatCompletion, shouldParseToolCall, -} from 'openai/lib/parser'; +} from '../lib/parser'; import { partialParse } from '../_vendor/partial-json-parser/parser'; export interface ContentDeltaEvent { diff --git a/src/lib/ChatCompletionStreamingRunner.ts b/src/lib/ChatCompletionStreamingRunner.ts index ea6c74116..ba0c6496f 100644 --- a/src/lib/ChatCompletionStreamingRunner.ts +++ b/src/lib/ChatCompletionStreamingRunner.ts @@ -1,13 +1,13 @@ import { type ChatCompletionChunk, type ChatCompletionCreateParamsStreaming, -} from 'openai/resources/chat/completions'; +} from '../resources/chat/completions'; import { RunnerOptions, type AbstractChatCompletionRunnerEvents } from './AbstractChatCompletionRunner'; -import { type ReadableStream } from 'openai/_shims/index'; +import { type ReadableStream } from '../_shims/index'; import { RunnableTools, type BaseFunctionsArgs, type RunnableFunctions } from './RunnableFunction'; import { ChatCompletionSnapshot, ChatCompletionStream } from './ChatCompletionStream'; -import OpenAI from 'openai/index'; -import { AutoParseableTool } from 'openai/lib/parser'; +import OpenAI from '../index'; +import { AutoParseableTool } from '../lib/parser'; export interface ChatCompletionStreamEvents extends AbstractChatCompletionRunnerEvents { content: (contentDelta: string, contentSnapshot: string) => void; diff --git a/src/lib/EventStream.ts b/src/lib/EventStream.ts index a18c771dd..d3f485e9d 100644 --- a/src/lib/EventStream.ts +++ b/src/lib/EventStream.ts @@ -1,4 +1,4 @@ -import { APIUserAbortError, OpenAIError } from 'openai/error'; +import { APIUserAbortError, OpenAIError } from '../error'; export class EventStream { controller: AbortController = new AbortController(); diff --git a/src/lib/chatCompletionUtils.ts b/src/lib/chatCompletionUtils.ts index a0d9099de..7e9f8a093 100644 --- a/src/lib/chatCompletionUtils.ts +++ b/src/lib/chatCompletionUtils.ts @@ -3,7 +3,7 @@ import { type ChatCompletionFunctionMessageParam, type ChatCompletionMessageParam, type ChatCompletionToolMessageParam, -} from 'openai/resources'; +} from '../resources'; export const isAssistantMessage = ( message: ChatCompletionMessageParam | null | undefined, diff --git a/src/lib/parser.ts b/src/lib/parser.ts index 8bf2a3a36..f2678e312 100644 --- a/src/lib/parser.ts +++ b/src/lib/parser.ts @@ -13,7 +13,7 @@ import { ParsedFunctionToolCall, } from '../resources/beta/chat/completions'; import { ResponseFormatJSONSchema } from '../resources/shared'; -import { ContentFilterFinishReasonError, LengthFinishReasonError, OpenAIError } from 'openai/error'; +import { ContentFilterFinishReasonError, LengthFinishReasonError, OpenAIError } from '../error'; type AnyChatCompletionCreateParams = | ChatCompletionCreateParams