Nhảy tới nội dung

Class: OpenAIAgentWorker

Implements

Constructors

constructor

new OpenAIAgentWorker(«destructured»): OpenAIAgentWorker

Parameters

NameType
«destructured»OpenAIAgentWorkerParams

Returns

OpenAIAgentWorker

Defined in

packages/core/src/agent/openai/worker.ts:95

Properties

_getTools

Private _getTools: (input: string) => Promise<BaseTool[]>

Type declaration

▸ (input): Promise<BaseTool[]>

Parameters
NameType
inputstring
Returns

Promise<BaseTool[]>

Defined in

packages/core/src/agent/openai/worker.ts:93


llm

Private llm: OpenAI

Defined in

packages/core/src/agent/openai/worker.ts:88


maxFunctionCalls

Private maxFunctionCalls: number = 5

Defined in

packages/core/src/agent/openai/worker.ts:89


prefixMessages

prefixMessages: { content: MessageContent ; options?: Record<string, unknown> ; role: MessageType }[]

Defined in

packages/core/src/agent/openai/worker.ts:91

Methods

_getAgentResponse

_getAgentResponse(task, mode, llmChatParams): Promise<AgentChatResponse | StreamingAgentChatResponse>

Parameters

NameType
taskTask
modeChatResponseMode
llmChatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, Record<string, unknown>>

Returns

Promise<AgentChatResponse | StreamingAgentChatResponse>

Defined in

packages/core/src/agent/openai/worker.ts:220


_getLlmChatParams

_getLlmChatParams(task, openaiTools, toolChoice?): LLMChatParamsBase<OpenAIAdditionalChatOptions, Record<string, unknown>>

Parameters

NameTypeDefault value
taskTaskundefined
openaiToolsBaseTool[]undefined
toolChoiceChatCompletionToolChoiceOption"auto"

Returns

LLMChatParamsBase<OpenAIAdditionalChatOptions, Record<string, unknown>>

Defined in

packages/core/src/agent/openai/worker.ts:145


_getStreamAiResponse

_getStreamAiResponse(task, llmChatParams): Promise<AgentChatResponse | StreamingAgentChatResponse>

Parameters

NameType
taskTask
llmChatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, Record<string, unknown>>

Returns

Promise<AgentChatResponse | StreamingAgentChatResponse>

Defined in

packages/core/src/agent/openai/worker.ts:176


_processMessage

_processMessage(task, aiMessage): AgentChatResponse

Parameters

NameType
taskTask
aiMessageObject
aiMessage.contentMessageContent
aiMessage.options?Record<string, unknown>
aiMessage.roleMessageType

Returns

AgentChatResponse

Defined in

packages/core/src/agent/openai/worker.ts:164


_runStep

_runStep(step, task, mode?, toolChoice?): Promise<TaskStepOutput>

Parameters

NameTypeDefault value
stepTaskStepundefined
taskTaskundefined
modeChatResponseModeChatResponseMode.WAIT
toolChoiceChatCompletionToolChoiceOption"auto"

Returns

Promise<TaskStepOutput>

Defined in

packages/core/src/agent/openai/worker.ts:303


_shouldContinue

_shouldContinue(toolCalls, nFunctionCalls): boolean

Parameters

NameType
toolCallsnull | ChatCompletionMessageToolCall[]
nFunctionCallsnumber

Returns

boolean

Defined in

packages/core/src/agent/openai/worker.ts:284


callFunction

callFunction(tools, toolCall): Promise<CallFunctionOutput>

Parameters

NameType
toolsBaseTool[]
toolCallChatCompletionMessageToolCall

Returns

Promise<CallFunctionOutput>

Defined in

packages/core/src/agent/openai/worker.ts:242


finalizeTask

finalizeTask(task): void

Parameters

NameType
taskTask

Returns

void

Implementation of

AgentWorker.finalizeTask

Defined in

packages/core/src/agent/openai/worker.ts:371


getAllMessages

getAllMessages(task): { content: MessageContent ; options?: Record<string, unknown> ; role: MessageType }[]

Parameters

NameType
taskTask

Returns

{ content: MessageContent ; options?: Record<string, unknown> ; role: MessageType }[]

Defined in

packages/core/src/agent/openai/worker.ts:126


getLatestToolCalls

getLatestToolCalls(task): null | ChatCompletionMessageToolCall[]

Parameters

NameType
taskTask

Returns

null | ChatCompletionMessageToolCall[]

Defined in

packages/core/src/agent/openai/worker.ts:134


getTools

getTools(input): Promise<BaseTool[]>

Parameters

NameType
inputstring

Returns

Promise<BaseTool[]>

Defined in

packages/core/src/agent/openai/worker.ts:299


initializeStep

initializeStep(task): TaskStep

Parameters

NameType
taskTask

Returns

TaskStep

Implementation of

AgentWorker.initializeStep

Defined in

packages/core/src/agent/openai/worker.ts:263


runStep

runStep(step, task, chatParams): Promise<TaskStepOutput>

Parameters

NameType
stepTaskStep
taskTask
chatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, Record<string, unknown>>

Returns

Promise<TaskStepOutput>

Implementation of

AgentWorker.runStep

Defined in

packages/core/src/agent/openai/worker.ts:353


streamStep

streamStep(step, task, chatParams): Promise<TaskStepOutput>

Parameters

NameType
stepTaskStep
taskTask
chatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, Record<string, unknown>>

Returns

Promise<TaskStepOutput>

Implementation of

AgentWorker.streamStep

Defined in

packages/core/src/agent/openai/worker.ts:362