Ana içeriğe geç

Class: OpenAI

Hierarchy

Constructors

constructor

new OpenAI(init?): OpenAI

Parameters

NameType
init?Partial<OpenAI> & { azure?: AzureOpenAIConfig }

Returns

OpenAI

Overrides

BaseLLM&lt;OpenAIAdditionalChatOptions&gt;.constructor

Defined in

packages/core/src/llm/open_ai.ts:172

Properties

additionalChatOptions

Optional additionalChatOptions: OpenAIAdditionalChatOptions

Defined in

packages/core/src/llm/open_ai.ts:160


additionalSessionOptions

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

Defined in

packages/core/src/llm/open_ai.ts:167


apiKey

Optional apiKey: string = undefined

Defined in

packages/core/src/llm/open_ai.ts:163


maxRetries

maxRetries: number

Defined in

packages/core/src/llm/open_ai.ts:164


maxTokens

Optional maxTokens: number

Defined in

packages/core/src/llm/open_ai.ts:159


model

model: string

Defined in

packages/core/src/llm/open_ai.ts:156


session

session: OpenAISession

Defined in

packages/core/src/llm/open_ai.ts:166


temperature

temperature: number

Defined in

packages/core/src/llm/open_ai.ts:157


timeout

Optional timeout: number

Defined in

packages/core/src/llm/open_ai.ts:165


topP

topP: number

Defined in

packages/core/src/llm/open_ai.ts:158

Accessors

metadata

get metadata(): LLMMetadata & OpenAIAdditionalMetadata

Returns

LLMMetadata & OpenAIAdditionalMetadata

Overrides

BaseLLM.metadata

Defined in

packages/core/src/llm/open_ai.ts:225

Methods

chat

chat(params): Promise<AsyncIterable<ChatResponseChunk>>

Parameters

NameType
paramsLLMChatParamsStreaming<OpenAIAdditionalChatOptions>

Returns

Promise<AsyncIterable<ChatResponseChunk>>

Overrides

BaseLLM.chat

Defined in

packages/core/src/llm/open_ai.ts:277

chat(params): Promise<ChatResponse>

Parameters

NameType
paramsLLMChatParamsNonStreaming<OpenAIAdditionalChatOptions>

Returns

Promise<ChatResponse>

Overrides

BaseLLM.chat

Defined in

packages/core/src/llm/open_ai.ts:280


complete

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

Parameters

NameType
paramsLLMCompletionParamsStreaming

Returns

Promise<AsyncIterable<CompletionResponse>>

Inherited from

BaseLLM.complete

Defined in

packages/core/src/llm/base.ts:23

complete(params): Promise<CompletionResponse>

Parameters

NameType
paramsLLMCompletionParamsNonStreaming

Returns

Promise<CompletionResponse>

Inherited from

BaseLLM.complete

Defined in

packages/core/src/llm/base.ts:26


mapMessageType

mapMessageType(messageType): "function" | "user" | "assistant" | "system" | "tool"

Parameters

NameType
messageTypeMessageType

Returns

"function" | "user" | "assistant" | "system" | "tool"

Defined in

packages/core/src/llm/open_ai.ts:241


streamChat

streamChat(baseRequestParams): AsyncIterable<ChatResponseChunk>

Parameters

NameType
baseRequestParamsChatCompletionCreateParams

Returns

AsyncIterable<ChatResponseChunk>

Defined in

packages/core/src/llm/open_ai.ts:330


toOpenAIMessage

toOpenAIMessage(messages): { content: MessageContent = message.content; role: "function" | "user" | "assistant" | "system" | "tool" }[]

Parameters

NameType
messagesChatMessage[]

Returns

{ content: MessageContent = message.content; role: "function" | "user" | "assistant" | "system" | "tool" }[]

Defined in

packages/core/src/llm/open_ai.ts:260


toTool

toTool(tool): ChatCompletionTool

Parameters

NameType
toolBaseTool

Returns

ChatCompletionTool

Defined in

packages/core/src/llm/open_ai.ts:366