Skip to main content

Class: OpenAI

Unified language model interface

Extends

Extended by

Constructors

new OpenAI()

new OpenAI(init?): OpenAI

Parameters

init?: Omit<Partial<OpenAI>, "session"> & object

Returns

OpenAI

Overrides

ToolCallLLM.constructor

Defined in

packages/llm/openai/dist/index.d.ts:292

Properties

additionalChatOptions?

optional additionalChatOptions: OpenAIAdditionalChatOptions

Defined in

packages/llm/openai/dist/index.d.ts:285


additionalSessionOptions?

optional additionalSessionOptions: Omit<Partial<ClientOptions>, "apiKey" | "maxRetries" | "timeout">

Defined in

packages/llm/openai/dist/index.d.ts:289


apiKey?

optional apiKey: string

Defined in

packages/llm/openai/dist/index.d.ts:286


lazySession()

lazySession: () => Promise<LLMInstance>

Returns

Promise<LLMInstance>

Defined in

packages/llm/openai/dist/index.d.ts:290


maxRetries

maxRetries: number

Defined in

packages/llm/openai/dist/index.d.ts:287


maxTokens?

optional maxTokens: number

Defined in

packages/llm/openai/dist/index.d.ts:284


model

model: string & object | ChatModel

Defined in

packages/llm/openai/dist/index.d.ts:281


temperature

temperature: number

Defined in

packages/llm/openai/dist/index.d.ts:282


timeout?

optional timeout: number

Defined in

packages/llm/openai/dist/index.d.ts:288


topP

topP: number

Defined in

packages/llm/openai/dist/index.d.ts:283

Accessors

metadata

get metadata(): LLMMetadata

Returns

LLMMetadata

Overrides

ToolCallLLM.metadata

Defined in

packages/llm/openai/dist/index.d.ts:297


session

get session(): Promise<LLMInstance>

Returns

Promise<LLMInstance>

Defined in

packages/llm/openai/dist/index.d.ts:291


supportToolCall

get supportToolCall(): boolean

Returns

boolean

Overrides

ToolCallLLM.supportToolCall

Defined in

packages/llm/openai/dist/index.d.ts:296

Methods

chat()

chat(params)

chat(params): Promise<AsyncIterable<ChatResponseChunk<ToolCallLLMMessageOptions>, any, any>>

Get a chat response from the LLM

Parameters

params: LLMChatParamsStreaming<OpenAIAdditionalChatOptions, ToolCallLLMMessageOptions>

Returns

Promise<AsyncIterable<ChatResponseChunk<ToolCallLLMMessageOptions>, any, any>>

Overrides

ToolCallLLM.chat

Defined in

packages/llm/openai/dist/index.d.ts:300

chat(params)

chat(params): Promise<ChatResponse<ToolCallLLMMessageOptions>>

Get a chat response from the LLM

Parameters

params: LLMChatParamsNonStreaming<OpenAIAdditionalChatOptions, ToolCallLLMMessageOptions>

Returns

Promise<ChatResponse<ToolCallLLMMessageOptions>>

Overrides

ToolCallLLM.chat

Defined in

packages/llm/openai/dist/index.d.ts:301


complete()

complete(params)

complete(params): Promise<AsyncIterable<CompletionResponse, any, any>>

Get a prompt completion from the LLM

Parameters

params: LLMCompletionParamsStreaming

Returns

Promise<AsyncIterable<CompletionResponse, any, any>>

Inherited from

ToolCallLLM.complete

Defined in

packages/core/llms/dist/index.d.ts:168

complete(params)

complete(params): Promise<CompletionResponse>

Get a prompt completion from the LLM

Parameters

params: LLMCompletionParamsNonStreaming

Returns

Promise<CompletionResponse>

Inherited from

ToolCallLLM.complete

Defined in

packages/core/llms/dist/index.d.ts:169


streamChat()

protected streamChat(baseRequestParams): AsyncIterable<ChatResponseChunk<ToolCallLLMMessageOptions>, any, any>

Parameters

baseRequestParams: ChatCompletionCreateParams

Returns

AsyncIterable<ChatResponseChunk<ToolCallLLMMessageOptions>, any, any>

Defined in

packages/llm/openai/dist/index.d.ts:302


toOpenAIMessage()

static toOpenAIMessage(messages): ChatCompletionMessageParam[]

Parameters

messages: ChatMessage<ToolCallLLMMessageOptions>[]

Returns

ChatCompletionMessageParam[]

Defined in

packages/llm/openai/dist/index.d.ts:299


toOpenAIRole()

static toOpenAIRole(messageType): ChatCompletionRole

Parameters

messageType: MessageType

Returns

ChatCompletionRole

Defined in

packages/llm/openai/dist/index.d.ts:298


toTool()

static toTool(tool): ChatCompletionTool

Parameters

tool: BaseTool<any>

Returns

ChatCompletionTool

Defined in

packages/llm/openai/dist/index.d.ts:303