Nhảy tới nội dung

Class: ReActAgent

An agent that uses OpenAI's API to generate text.

Hierarchy

  • AgentRunner

    ReActAgent

Constructors

constructor

new ReActAgent(«destructured»): ReActAgent

Parameters

NameType
«destructured»Partial<ReActAgentParams>

Returns

ReActAgent

Overrides

AgentRunner.constructor

Defined in

packages/core/src/agent/react/base.ts:24

Properties

agentWorker

agentWorker: AgentWorker<object>

Inherited from

AgentRunner.agentWorker

Defined in

packages/core/src/agent/runner/base.ts:44


defaultToolChoice

defaultToolChoice: string

Inherited from

AgentRunner.defaultToolChoice

Defined in

packages/core/src/agent/runner/base.ts:49


deleteTaskOnFinish

deleteTaskOnFinish: boolean

Inherited from

AgentRunner.deleteTaskOnFinish

Defined in

packages/core/src/agent/runner/base.ts:48


initTaskStateKwargs

initTaskStateKwargs: Record<string, any>

Inherited from

AgentRunner.initTaskStateKwargs

Defined in

packages/core/src/agent/runner/base.ts:47


memory

memory: BaseMemory<object>

Inherited from

AgentRunner.memory

Defined in

packages/core/src/agent/runner/base.ts:46


state

state: AgentState

Inherited from

AgentRunner.state

Defined in

packages/core/src/agent/runner/base.ts:45

Methods

_chat

_chat(«destructured»): Promise<AgentChatResponse>

Parameters

NameType
«destructured»ChatEngineAgentParams

Returns

Promise<AgentChatResponse>

Inherited from

AgentRunner._chat

Defined in

packages/core/src/agent/runner/base.ts:263

_chat(«destructured»): Promise<StreamingAgentChatResponse>

Parameters

NameType
«destructured»ChatEngineAgentParams & { stream: true }

Returns

Promise<StreamingAgentChatResponse>

Inherited from

AgentRunner._chat

Defined in

packages/core/src/agent/runner/base.ts:268


_getPromptModules

_getPromptModules(): string[]

Returns

string[]

Inherited from

AgentRunner._getPromptModules

Defined in

packages/core/src/agent/runner/base.ts:349


_getPrompts

_getPrompts(): string[]

Returns

string[]

Inherited from

AgentRunner._getPrompts

Defined in

packages/core/src/agent/runner/base.ts:353


chat

chat(«destructured»): Promise<AgentChatResponse>

Sends a message to the LLM and returns the response.

Parameters

NameType
«destructured»ChatEngineAgentParams & { stream?: false }

Returns

Promise<AgentChatResponse>

Inherited from

AgentRunner.chat

Defined in

packages/core/src/agent/runner/base.ts:311

chat(«destructured»): Promise<StreamingAgentChatResponse>

Parameters

NameType
«destructured»ChatEngineAgentParams & { stream: true }

Returns

Promise<StreamingAgentChatResponse>

Inherited from

AgentRunner.chat

Defined in

packages/core/src/agent/runner/base.ts:319


createTask

createTask(input, kwargs?): Task

Creates a task.

Parameters

NameType
inputstring
kwargs?any

Returns

Task

Inherited from

AgentRunner.createTask

Defined in

packages/core/src/agent/runner/base.ts:75


deleteTask

deleteTask(taskId): void

Deletes the task.

Parameters

NameType
taskIdstring

Returns

void

Inherited from

AgentRunner.deleteTask

Defined in

packages/core/src/agent/runner/base.ts:118


finalizeResponse

finalizeResponse(taskId, stepOutput, kwargs?): Promise<AgentChatResponse | StreamingAgentChatResponse>

Finalizes the response and returns it.

Parameters

NameType
taskIdstring
stepOutputTaskStepOutput
kwargs?any

Returns

Promise<AgentChatResponse | StreamingAgentChatResponse>

Inherited from

AgentRunner.finalizeResponse

Defined in

packages/core/src/agent/runner/base.ts:228


getCompletedStep

getCompletedStep(taskId, stepId, kwargs): TaskStepOutput

Parameters

NameType
taskIdstring
stepIdstring
kwargsany

Returns

TaskStepOutput

Inherited from

AgentRunner.getCompletedStep

Defined in

packages/core/src/agent/runner/base.ts:364


getCompletedSteps

getCompletedSteps(taskId): TaskStepOutput[]

Returns the completed steps in the task.

Parameters

NameType
taskIdstring

Returns

TaskStepOutput[]

Inherited from

AgentRunner.getCompletedSteps

Defined in

packages/core/src/agent/runner/base.ts:143


getTask

getTask(taskId): Task

Returns the task.

Parameters

NameType
taskIdstring

Returns

Task

Inherited from

AgentRunner.getTask

Defined in

packages/core/src/agent/runner/base.ts:134


getUpcomingSteps

getUpcomingSteps(taskId, kwargs): TaskStep[]

Returns the next steps in the task.

Parameters

NameType
taskIdstring
kwargsany

Returns

TaskStep[]

Inherited from

AgentRunner.getUpcomingSteps

Defined in

packages/core/src/agent/runner/base.ts:152


listTasks

listTasks(): Task[]

Returns the list of tasks.

Returns

Task[]

Inherited from

AgentRunner.listTasks

Defined in

packages/core/src/agent/runner/base.ts:125


query

query(params): Promise<AgentChatResponse | StreamingAgentChatResponse>

query is the main entrypoint for the agent. It takes a query and returns a response.

Parameters

NameType
paramsQueryEngineParamsNonStreaming

Returns

Promise<AgentChatResponse | StreamingAgentChatResponse>

Inherited from

AgentRunner.query

Defined in

packages/core/src/agent/types.ts:61


reset

reset(): void

Resets the agent.

Returns

void

Inherited from

AgentRunner.reset

Defined in

packages/core/src/agent/runner/base.ts:360


runStep

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

Runs the next step in the task.

Parameters

NameType
taskIdstring
input?null | string
step?TaskStep
kwargsany

Returns

Promise<TaskStepOutput>

Inherited from

AgentRunner.runStep

Defined in

packages/core/src/agent/runner/base.ts:194


streamStep

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

Runs the step and returns the response.

Parameters

NameType
taskIdstring
inputstring
step?TaskStep
kwargs?any

Returns

Promise<TaskStepOutput>

Inherited from

AgentRunner.streamStep

Defined in

packages/core/src/agent/runner/base.ts:211


undoStep

undoStep(taskId): void

Undoes the step.

Parameters

NameType
taskIdstring

Returns

void

Inherited from

AgentRunner.undoStep

Defined in

packages/core/src/agent/runner/base.ts:383