Copyright | (c) 2025 Tushar Adhatrao |
---|---|
License | MIT |
Maintainer | Tushar Adhatrao <[email protected]> |
Safe Haskell | None |
Language | Haskell2010 |
Langchain.Agents.Core
Description
Agents use LLMs as reasoning engines to determine actions dynamically.
Synopsis
- data AgentAction = AgentAction {
- actionToolName :: Text
- actionInput :: Text
- actionLog :: Text
- data AgentFinish = AgentFinish {}
- data AgentStep
- class Agent a where
- planNextAction :: BaseMemory m => a -> AgentState m -> IO (Either String AgentStep)
- agentPrompt :: a -> IO PromptTemplate
- agentTools :: a -> IO [AnyTool]
- data AnyTool = Tool a => AnyTool {
- anyTool :: a
- textToInput :: Text -> Input a
- outputToText :: Output a -> Text
- data BaseMemory m => AgentState m = AgentState {
- agentMemory :: m
- agentToolResults :: [(Text, Text)]
- agentSteps :: [AgentAction]
- runAgent :: (Agent a, BaseMemory m) => a -> AgentState m -> Text -> IO (Either String AgentFinish)
- runAgentLoop :: (Agent a, BaseMemory m) => a -> AgentState m -> Int -> Int -> IO (Either String AgentFinish)
- executeTool :: [AnyTool] -> Text -> Text -> IO (Either String Text)
- runSingleStep :: (Agent a, BaseMemory m) => a -> AgentState m -> IO (Either String AgentStep)
- customAnyTool :: Tool a => a -> (Text -> Input a) -> (Output a -> Text) -> AnyTool
Documentation
data AgentAction Source #
Represents an action to be taken by the agent
Constructors
AgentAction | |
Fields
|
Instances
Show AgentAction Source # | |
Defined in Langchain.Agents.Core Methods showsPrec :: Int -> AgentAction -> ShowS # show :: AgentAction -> String # showList :: [AgentAction] -> ShowS # | |
Eq AgentAction Source # | |
Defined in Langchain.Agents.Core |
data AgentFinish Source #
Represents that agent has finished work with final value
Constructors
AgentFinish | |
Instances
Show AgentFinish Source # | |
Defined in Langchain.Agents.Core Methods showsPrec :: Int -> AgentFinish -> ShowS # show :: AgentFinish -> String # showList :: [AgentFinish] -> ShowS # | |
Eq AgentFinish Source # | |
Defined in Langchain.Agents.Core |
Type that will be return from LLM Could be either Continue, making another call to LLM or Finish with final value
Constructors
Continue AgentAction | |
Finish AgentFinish |
Typeclass for Agent
Methods
planNextAction :: BaseMemory m => a -> AgentState m -> IO (Either String AgentStep) Source #
agentPrompt :: a -> IO PromptTemplate Source #
agentTools :: a -> IO [AnyTool] Source #
Instances
LLM llm => Agent (ReactAgent llm) Source # | |
Defined in Langchain.Agents.React Methods planNextAction :: BaseMemory m => ReactAgent llm -> AgentState m -> IO (Either String AgentStep) Source # agentPrompt :: ReactAgent llm -> IO PromptTemplate Source # agentTools :: ReactAgent llm -> IO [AnyTool] Source # |
A type that helps various types of Tools
It encapsulates the Tool, and conversion functions
to and from Text for Tool input and output since Agent takes and returns Text.
If Tool takes or returns Text type itself you can use id
at these places.
Constructors
Tool a => AnyTool | |
Fields
|
data BaseMemory m => AgentState m Source #
Type for maintaining state of the agent
Constructors
AgentState | |
Fields
|
Instances
(BaseMemory m, Show m) => Show (AgentState m) Source # | |
Defined in Langchain.Agents.Core Methods showsPrec :: Int -> AgentState m -> ShowS # show :: AgentState m -> String # showList :: [AgentState m] -> ShowS # | |
(BaseMemory m, Eq m) => Eq (AgentState m) Source # | |
Defined in Langchain.Agents.Core |
runAgent :: (Agent a, BaseMemory m) => a -> AgentState m -> Text -> IO (Either String AgentFinish) Source #
Function that *starts* the agent process.
runAgentLoop :: (Agent a, BaseMemory m) => a -> AgentState m -> Int -> Int -> IO (Either String AgentFinish) Source #
Helper function for runAgent
executeTool :: [AnyTool] -> Text -> Text -> IO (Either String Text) Source #
Execute a single tool call Handles tool lookup and input/output conversion.
runSingleStep :: (Agent a, BaseMemory m) => a -> AgentState m -> IO (Either String AgentStep) Source #
Alias for planNextAction