Class: OpenAI
Unified language model interface
Extends
Extended by
Constructors
new OpenAI()
new OpenAI(
init
?):OpenAI
Parameters
• init?: Partial
<OpenAI
> & object
Returns
Overrides
Defined in
packages/llamaindex/src/llm/openai.ts:177
Properties
additionalChatOptions?
optional
additionalChatOptions:OpenAIAdditionalChatOptions
Defined in
packages/llamaindex/src/llm/openai.ts:165
additionalSessionOptions?
optional
additionalSessionOptions:Omit
<Partial
<ClientOptions
>,"apiKey"
|"timeout"
|"maxRetries"
>
Defined in
packages/llamaindex/src/llm/openai.ts:172
apiKey?
optional
apiKey:string
=undefined
Defined in
packages/llamaindex/src/llm/openai.ts:168
maxRetries
maxRetries:
number
Defined in
packages/llamaindex/src/llm/openai.ts:169
maxTokens?
optional
maxTokens:number
Defined in
packages/llamaindex/src/llm/openai.ts:164
model
model:
string
Defined in
packages/llamaindex/src/llm/openai.ts:161
session
session:
OpenAISession
Defined in
packages/llamaindex/src/llm/openai.ts:171
temperature
temperature:
number
Defined in
packages/llamaindex/src/llm/openai.ts:162
timeout?
optional
timeout:number
Defined in
packages/llamaindex/src/llm/openai.ts:170
topP
topP:
number
Defined in
packages/llamaindex/src/llm/openai.ts:163
Accessors
metadata
get
metadata():LLMMetadata
Returns
Overrides
Defined in
packages/llamaindex/src/llm/openai.ts:228
supportToolCall
get
supportToolCall():boolean
Returns
boolean
Overrides
Defined in
packages/llamaindex/src/llm/openai.ts:224
Methods
chat()
chat(params)
chat(
params
):Promise
<AsyncIterable
<ChatResponseChunk
<ToolCallLLMMessageOptions
>>>
Get a chat response from the LLM
Parameters
• params: LLMChatParamsStreaming
<OpenAIAdditionalChatOptions
, ToolCallLLMMessageOptions
>
Returns
Promise
<AsyncIterable
<ChatResponseChunk
<ToolCallLLMMessageOptions
>>>
Overrides
Defined in
packages/llamaindex/src/llm/openai.ts:305
chat(params)
chat(
params
):Promise
<ChatResponse
<ToolCallLLMMessageOptions
>>
Get a chat response from the LLM
Parameters
• params: LLMChatParamsNonStreaming
<OpenAIAdditionalChatOptions
, ToolCallLLMMessageOptions
>
Returns
Promise
<ChatResponse
<ToolCallLLMMessageOptions
>>
Overrides
Defined in
packages/llamaindex/src/llm/openai.ts:311
complete()
complete(params)
complete(
params
):Promise
<AsyncIterable
<CompletionResponse
>>
Get a prompt completion from the LLM
Parameters
• params: LLMCompletionParamsStreaming
Returns
Promise
<AsyncIterable
<CompletionResponse
>>
Inherited from
Defined in
packages/core/dist/llms/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
Defined in
packages/core/dist/llms/index.d.ts:169
streamChat()
protected
streamChat(baseRequestParams
):AsyncIterable
<ChatResponseChunk
<ToolCallLLMMessageOptions
>>
Parameters
• baseRequestParams: ChatCompletionCreateParams
Returns
AsyncIterable
<ChatResponseChunk
<ToolCallLLMMessageOptions
>>
Defined in
packages/llamaindex/src/llm/openai.ts:387
toOpenAIMessage()
static
toOpenAIMessage(messages
):ChatCompletionMessageParam
[]
Parameters
• messages: ChatMessage
<ToolCallLLMMessageOptions
>[]
Returns
ChatCompletionMessageParam
[]
Defined in
packages/llamaindex/src/llm/openai.ts:256
toOpenAIRole()
static
toOpenAIRole(messageType
):ChatCompletionRole
Parameters
• messageType: MessageType
Returns
ChatCompletionRole
Defined in
packages/llamaindex/src/llm/openai.ts:243
toTool()
static
toTool(tool
):ChatCompletionTool
Parameters
• tool: BaseTool
<any
>
Returns
ChatCompletionTool