Ana içeriğe geç

Class: OpenAIAgentWorker

Implements

Constructors

constructor

new OpenAIAgentWorker(«destructured»): OpenAIAgentWorker

Parameters

NameType
«destructured»OpenAIAgentWorkerParams

Returns

OpenAIAgentWorker

Defined in

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

Properties

_getTools

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

Type declaration

▸ (input): Promise<BaseTool<any>[]>

Parameters
NameType
inputstring
Returns

Promise<BaseTool<any>[]>

Defined in

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


llm

Private llm: OpenAI

Defined in

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


maxFunctionCalls

Private maxFunctionCalls: number = 5

Defined in

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


prefixMessages

prefixMessages: ChatMessage[]

Defined in

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

Methods

_getAgentResponse

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

Parameters

NameType
taskTask
modeChatResponseMode
llmChatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, ToolCallLLMMessageOptions>

Returns

Promise<AgentChatResponse | StreamingAgentChatResponse>

Defined in

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


_getLlmChatParams

_getLlmChatParams(task, tools, toolChoice?): LLMChatParamsBase<OpenAIAdditionalChatOptions, ToolCallLLMMessageOptions>

Parameters

NameTypeDefault value
taskTaskundefined
toolsBaseTool<any>[]undefined
toolChoiceChatCompletionToolChoiceOption"auto"

Returns

LLMChatParamsBase<OpenAIAdditionalChatOptions, ToolCallLLMMessageOptions>

Defined in

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


_getStreamAiResponse

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

Parameters

NameType
taskTask
llmChatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, ToolCallLLMMessageOptions>

Returns

Promise<AgentChatResponse | StreamingAgentChatResponse>

Defined in

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


_processMessage

_processMessage(task, aiMessage): AgentChatResponse

Parameters

NameType
taskTask
aiMessageChatMessage

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:329


_shouldContinue

_shouldContinue(toolCall, nFunctionCalls): toolCall is ToolCall

Parameters

NameType
toolCallnull | ToolCall
nFunctionCallsnumber

Returns

toolCall is ToolCall

Defined in

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


callFunction

callFunction(tools, toolCall): Promise<CallFunctionOutput>

Parameters

NameType
toolsBaseTool<any>[]
toolCallToolCall

Returns

Promise<CallFunctionOutput>

Defined in

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


finalizeTask

finalizeTask(task): void

Parameters

NameType
taskTask

Returns

void

Implementation of

AgentWorker.finalizeTask

Defined in

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


getAllMessages

getAllMessages(task): ChatMessage<ToolCallLLMMessageOptions>[]

Parameters

NameType
taskTask

Returns

ChatMessage<ToolCallLLMMessageOptions>[]

Defined in

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


getLatestToolCall

getLatestToolCall(task): null | ToolCall

Parameters

NameType
taskTask

Returns

null | ToolCall

Defined in

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


getTools

getTools(input): Promise<BaseTool<any>[]>

Parameters

NameType
inputstring

Returns

Promise<BaseTool<any>[]>

Defined in

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


initializeStep

initializeStep(task): TaskStep

Parameters

NameType
taskTask

Returns

TaskStep

Implementation of

AgentWorker.initializeStep

Defined in

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


runStep

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

Parameters

NameType
stepTaskStep
taskTask
chatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, object>

Returns

Promise<TaskStepOutput>

Implementation of

AgentWorker.runStep

Defined in

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


streamStep

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

Parameters

NameType
stepTaskStep
taskTask
chatParamsLLMChatParamsBase<OpenAIAdditionalChatOptions, object>

Returns

Promise<TaskStepOutput>

Implementation of

AgentWorker.streamStep

Defined in

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