langchain.agents.output_parsers.self_ask.SelfAskOutputParser¶
class langchain.agents.output_parsers.self_ask.SelfAskOutputParser[source]¶
Bases: AgentOutputParser
Parses self-ask style LLM calls.
Expects output to be in one of two formats.
If the output signals that an action should be taken,
should be in the below format. This will result in an AgentAction
being returned.
`
Thoughts go here...
Follow up: what is the temperature in SF?
`
If the output signals that a final answer should be given,
should be in the below format. This will result in an AgentFinish
being returned.
`
Thoughts go here...
So the final answer is: The temperature is 100 degrees
`
param finish_string: str = 'So the final answer is: '¶
param followups: Sequence[str] = ('Follow up:', 'Followup:')¶
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶
Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
async ainvoke(input: str | langchain_core.messages.base.BaseMessage, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → T¶
Default implementation of ainvoke, calls invoke from a thread.
The default implementation allows usage of async code even if
the runnable did not implement a native async version of invoke.
Subclasses should override this method if they can run asynchronously.