Aller au contenu principal

Class: ReActAgentWorker

ReAct agent worker.

Implements

Constructors

constructor

new ReActAgentWorker(«destructured»): ReActAgentWorker

Parameters

NameType
«destructured»ReActAgentWorkerParams

Returns

ReActAgentWorker

Defined in

packages/core/src/agent/react/worker.ts:76

Properties

_getTools

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

Type declaration

▸ (message): Promise<BaseTool[]>

Parameters
NameType
messagestring
Returns

Promise<BaseTool[]>

Defined in

packages/core/src/agent/react/worker.ts:74


callbackManager

callbackManager: CallbackManager

Defined in

packages/core/src/agent/react/worker.ts:72


llm

llm: LLM

Defined in

packages/core/src/agent/react/worker.ts:65


maxInteractions

maxInteractions: number = 10

Defined in

packages/core/src/agent/react/worker.ts:68


outputParser

outputParser: ReActOutputParser

Defined in

packages/core/src/agent/react/worker.ts:70


reactChatFormatter

reactChatFormatter: ReActChatFormatter

Defined in

packages/core/src/agent/react/worker.ts:69


verbose

verbose: boolean

Defined in

packages/core/src/agent/react/worker.ts:66

Methods

_getResponse

_getResponse(currentReasoning, sources): AgentChatResponse

Get response.

Parameters

NameTypeDescription
currentReasoningBaseReasoningStep[]current reasoning steps
sourcesToolOutput[]tool outputs

Returns

AgentChatResponse

  • agent chat response

Defined in

packages/core/src/agent/react/worker.ts:255


_getTaskStepResponse

_getTaskStepResponse(agentResponse, step, isDone): TaskStepOutput

Get task step response.

Parameters

NameTypeDescription
agentResponseAgentChatResponseagent chat response
stepTaskSteptask step
isDonebooleanwhether the task is done

Returns

TaskStepOutput

  • task step output

Defined in

packages/core/src/agent/react/worker.ts:285


_processActions

_processActions(task, tools, output, isStreaming?): Promise<[BaseReasoningStep[], boolean]>

Process actions.

Parameters

NameTypeDefault valueDescription
taskTaskundefinedtask
toolsBaseTool[]undefinedtools
outputChatResponseundefinedchat response
isStreamingbooleanfalsewhether the chat response is streaming

Returns

Promise<[BaseReasoningStep[], boolean]>

  • [reasoning steps, is done]

Defined in

packages/core/src/agent/react/worker.ts:192


_runStep

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

Run a task step.

Parameters

NameTypeDescription
stepTaskSteptask step
taskTasktask
kwargs?anykeyword arguments

Returns

Promise<TaskStepOutput>

  • task step output

Defined in

packages/core/src/agent/react/worker.ts:308


extractReasoningStep

extractReasoningStep(output, isStreaming): [string, BaseReasoningStep[], boolean]

Extract reasoning step from chat response.

Parameters

NameTypeDescription
outputChatResponsechat response
isStreamingbooleanwhether the chat response is streaming

Returns

[string, BaseReasoningStep[], boolean]

  • [message content, reasoning steps, is done]

Defined in

packages/core/src/agent/react/worker.ts:139


finalizeTask

finalizeTask(task, kwargs?): void

Finalize a task.

Parameters

NameTypeDescription
taskTasktask
kwargs?anykeyword arguments

Returns

void

Implementation of

AgentWorker.finalizeTask

Defined in

packages/core/src/agent/react/worker.ts:392


initializeStep

initializeStep(task, kwargs?): TaskStep

Initialize a task step.

Parameters

NameTypeDescription
taskTasktask
kwargs?anykeyword arguments

Returns

TaskStep

  • task step

Implementation of

AgentWorker.initializeStep

Defined in

packages/core/src/agent/react/worker.ts:112


runStep

runStep(step, task, kwargs?): Promise<TaskStepOutput>

Run a task step.

Parameters

NameTypeDescription
stepTaskSteptask step
taskTasktask
kwargs?anykeyword arguments

Returns

Promise<TaskStepOutput>

  • task step output

Implementation of

AgentWorker.runStep

Defined in

packages/core/src/agent/react/worker.ts:364


streamStep

streamStep(step, task, kwargs?): Promise<TaskStepOutput>

Run a task step.

Parameters

NameTypeDescription
stepTaskSteptask step
taskTasktask
kwargs?anykeyword arguments

Returns

Promise<TaskStepOutput>

  • task step output

Implementation of

AgentWorker.streamStep

Defined in

packages/core/src/agent/react/worker.ts:379