Decision-making and action selection in LLM-based agents
To improve the agent’s decision-making capabilities, we can introduce a more structured approach to action selection, evaluating potential actions based on multiple factors.
We first define the ActionEvaluator
class, which uses the LLM to evaluate actions based on three key criteria: relevance to the current goal, probability of success, and potential impact. These evaluations help the agent choose the best possible action:
import numpy as np class ActionEvaluator: def __init__(self, llm): self.llm = llm def evaluate_action( self, action: str, context: str ) -> Dict[str, float]: prompt = f""" Context: {context} ...