@@ -52,31 +52,33 @@ class AgentAction(Serializable):
5252 """The input to pass in to the Tool."""
5353 log : str
5454 """Additional information to log about the action.
55- This log can be used in a few ways. First, it can be used to audit
56- what exactly the LLM predicted to lead to this (tool, tool_input).
57- Second, it can be used in future iterations to show the LLMs prior
58- thoughts. This is useful when (tool, tool_input) does not contain
59- full information about the LLM prediction (for example, any `thought`
60- before the tool/tool_input)."""
55+
56+ This log can be used in a few ways. First, it can be used to audit what exactly the
57+ LLM predicted to lead to this `(tool, tool_input)`.
58+
59+ Second, it can be used in future iterations to show the LLMs prior thoughts. This is
60+ useful when `(tool, tool_input)` does not contain full information about the LLM
61+ prediction (for example, any `thought` before the tool/tool_input).
62+ """
6163 type : Literal ["AgentAction" ] = "AgentAction"
6264
6365 # Override init to support instantiation by position for backward compat.
6466 def __init__ (self , tool : str , tool_input : str | dict , log : str , ** kwargs : Any ):
65- """Create an AgentAction.
67+ """Create an ` AgentAction` .
6668
6769 Args:
6870 tool: The name of the tool to execute.
69- tool_input: The input to pass in to the Tool.
71+ tool_input: The input to pass in to the ` Tool` .
7072 log: Additional information to log about the action.
7173 """
7274 super ().__init__ (tool = tool , tool_input = tool_input , log = log , ** kwargs )
7375
7476 @classmethod
7577 def is_lc_serializable (cls ) -> bool :
76- """AgentAction is serializable.
78+ """` AgentAction` is serializable.
7779
7880 Returns:
79- True
81+ ` True`
8082 """
8183 return True
8284
@@ -98,19 +100,23 @@ def messages(self) -> Sequence[BaseMessage]:
98100class AgentActionMessageLog (AgentAction ):
99101 """Representation of an action to be executed by an agent.
100102
101- This is similar to AgentAction, but includes a message log consisting of
102- chat messages. This is useful when working with ChatModels, and is used
103- to reconstruct conversation history from the agent's perspective.
103+ This is similar to `AgentAction`, but includes a message log consisting of
104+ chat messages.
105+
106+ This is useful when working with `ChatModels`, and is used to reconstruct
107+ conversation history from the agent's perspective.
104108 """
105109
106110 message_log : Sequence [BaseMessage ]
107- """Similar to log, this can be used to pass along extra
108- information about what exact messages were predicted by the LLM
109- before parsing out the (tool, tool_input). This is again useful
110- if (tool, tool_input) cannot be used to fully recreate the LLM
111- prediction, and you need that LLM prediction (for future agent iteration).
111+ """Similar to log, this can be used to pass along extra information about what exact
112+ messages were predicted by the LLM before parsing out the `(tool, tool_input)`.
113+
114+ This is again useful if `(tool, tool_input)` cannot be used to fully recreate the
115+ LLM prediction, and you need that LLM prediction (for future agent iteration).
116+
112117 Compared to `log`, this is useful when the underlying LLM is a
113- chat model (and therefore returns messages rather than a string)."""
118+ chat model (and therefore returns messages rather than a string).
119+ """
114120 # Ignoring type because we're overriding the type from AgentAction.
115121 # And this is the correct thing to do in this case.
116122 # The type literal is used for serialization purposes.
@@ -132,19 +138,22 @@ def messages(self) -> Sequence[BaseMessage]:
132138
133139
134140class AgentFinish (Serializable ):
135- """Final return value of an ActionAgent.
141+ """Final return value of an ` ActionAgent` .
136142
137- Agents return an AgentFinish when they have reached a stopping condition.
143+ Agents return an ` AgentFinish` when they have reached a stopping condition.
138144 """
139145
140146 return_values : dict
141147 """Dictionary of return values."""
142148 log : str
143149 """Additional information to log about the return value.
150+
144151 This is used to pass along the full LLM prediction, not just the parsed out
145- return value. For example, if the full LLM prediction was
146- `Final Answer: 2` you may want to just return `2` as a return value, but pass
147- along the full string as a `log` (for debugging or observability purposes).
152+ return value.
153+
154+ For example, if the full LLM prediction was `Final Answer: 2` you may want to just
155+ return `2` as a return value, but pass along the full string as a `log` (for
156+ debugging or observability purposes).
148157 """
149158 type : Literal ["AgentFinish" ] = "AgentFinish"
150159
@@ -154,7 +163,7 @@ def __init__(self, return_values: dict, log: str, **kwargs: Any):
154163
155164 @classmethod
156165 def is_lc_serializable (cls ) -> bool :
157- """Return True as this class is serializable."""
166+ """Return ` True` as this class is serializable."""
158167 return True
159168
160169 @classmethod
@@ -202,7 +211,7 @@ def _convert_agent_observation_to_messages(
202211 observation: Observation to convert to a message.
203212
204213 Returns:
205- AIMessage that corresponds to the original tool invocation.
214+ ` AIMessage` that corresponds to the original tool invocation.
206215 """
207216 if isinstance (agent_action , AgentActionMessageLog ):
208217 return [_create_function_message (agent_action , observation )]
@@ -225,7 +234,7 @@ def _create_function_message(
225234 observation: the result of the tool invocation.
226235
227236 Returns:
228- FunctionMessage that corresponds to the original tool invocation.
237+ ` FunctionMessage` that corresponds to the original tool invocation.
229238 """
230239 if not isinstance (observation , str ):
231240 try :
0 commit comments