Class: ChatAgent
agents.ChatAgent
Agent for the MRKL chain.
Hierarchy
↳
ChatAgent
Constructors
constructor
• new ChatAgent(input
)
Parameters
Name | Type |
---|---|
input | AgentInput |
Overrides
Defined in
langchain/src/agents/chat/index.ts:32
Properties
llmChain
• llmChain: LLMChain
Inherited from
Defined in
langchain/src/agents/agent.ts:158
Accessors
allowedTools
• get
allowedTools(): undefined
| string
[]
Returns
undefined
| string
[]
Inherited from
Agent.allowedTools
Defined in
langchain/src/agents/agent.ts:162
inputKeys
• get
inputKeys(): string
[]
Returns
string
[]
Inherited from
Agent.inputKeys
Defined in
langchain/src/agents/agent.ts:166
returnValues
• get
returnValues(): string
[]
Returns
string
[]
Inherited from
Agent.returnValues
Defined in
langchain/src/agents/agent.ts:31
Methods
_agentType
▸ _agentType(): "zero-shot-react-description"
Return the string type key uniquely identifying this class of agent.
Returns
"zero-shot-react-description"
Overrides
Defined in
langchain/src/agents/chat/index.ts:36
_stop
▸ _stop(): string
[]
Returns
string
[]
Overrides
Defined in
langchain/src/agents/chat/index.ts:48
constructScratchPad
▸ constructScratchPad(steps
): string
Construct a scratchpad to let the agent continue its thought process
Parameters
Name | Type |
---|---|
steps | AgentStep [] |
Returns
string
Overrides
Defined in
langchain/src/agents/chat/index.ts:62
extractToolAndInput
▸ extractToolAndInput(text
): Promise
<null
| { input
: string
; tool
: string
}>
Extract tool and tool input from LLM output.
Parameters
Name | Type |
---|---|
text | string |
Returns
Promise
<null
| { input
: string
; tool
: string
}>
Overrides
Defined in
langchain/src/agents/chat/index.ts:107
finishToolName
▸ finishToolName(): string
Name of tool to use to terminate the chain.
Returns
string
Inherited from
Defined in
langchain/src/agents/agent.ts:238
llmPrefix
▸ llmPrefix(): string
Prefix to append the LLM call with.
Returns
string
Overrides
Defined in
langchain/src/agents/chat/index.ts:44
observationPrefix
▸ observationPrefix(): string
Prefix to append the observation with.
Returns
string
Overrides
Defined in
langchain/src/agents/chat/index.ts:40
plan
▸ plan(steps
, inputs
): Promise
<AgentAction
| AgentFinish
>
Decide what to do given some input.
Parameters
Name | Type | Description |
---|---|---|
steps | AgentStep [] | Steps the LLM has taken so far, along with observations from each. |
inputs | ChainValues | User inputs. |
Returns
Promise
<AgentAction
| AgentFinish
>
Action specifying what tool to use.
Inherited from
Defined in
langchain/src/agents/agent.ts:297
prepareForOutput
▸ prepareForOutput(_returnValues
, _steps
): Promise
<Record
<string
, any
>>
Prepare the agent for output, if needed
Parameters
Name | Type |
---|---|
_returnValues | Record <string , any > |
_steps | AgentStep [] |
Returns
Promise
<Record
<string
, any
>>
Inherited from
Defined in
langchain/src/agents/agent.ts:67
returnStoppedResponse
▸ returnStoppedResponse(earlyStoppingMethod
, steps
, inputs
): Promise
<AgentFinish
>
Return response when agent has been stopped due to max iterations
Parameters
Name | Type |
---|---|
earlyStoppingMethod | StoppingMethod |
steps | AgentStep [] |
inputs | ChainValues |
Returns
Promise
<AgentFinish
>
Inherited from
Defined in
langchain/src/agents/agent.ts:307
createPrompt
▸ Static
createPrompt(tools
, args?
): ChatPromptTemplate
Create prompt in the style of the zero shot agent.
Parameters
Name | Type | Description |
---|---|---|
tools | Tool [] | List of tools the agent will have access to, used to format the prompt. |
args? | CreatePromptArgs | Arguments to create the prompt with. |
Returns
Overrides
Defined in
langchain/src/agents/chat/index.ts:78
deserialize
▸ Static
deserialize(data
): Promise
<Agent
>
Load an agent from a json-like object describing it.
Parameters
Name | Type |
---|---|
data | Object |
Returns
Promise
<Agent
>
Inherited from
Defined in
langchain/src/agents/agent.ts:347
fromLLMAndTools
▸ Static
fromLLMAndTools(llm
, tools
, args?
): ChatAgent
Construct an agent from an LLM and a list of tools
Parameters
Name | Type |
---|---|
llm | BaseLanguageModel |
tools | Tool [] |
args? | CreatePromptArgs |
Returns
Overrides
Defined in
langchain/src/agents/chat/index.ts:93
validateTools
▸ Static
validateTools(tools
): void
Validate that appropriate tools are passed in
Parameters
Name | Type |
---|---|
tools | Tool [] |
Returns
void
Overrides
Defined in
langchain/src/agents/chat/index.ts:52