Skip to content

Commit

Permalink
docs(CallAgent.java): add comprehensive Javadoc comments and method d…
Browse files Browse the repository at this point in the history
…escriptions
  • Loading branch information
bsorrentino committed Dec 15, 2024
1 parent 3e861ce commit 48c6c8c
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,31 @@

import java.util.Map;

/**
* The CallAgent class implements the NodeAction interface for handling
* actions related to an AgentExecutor's state.
*/
@Slf4j
public class CallAgent implements NodeAction<AgentExecutor.State> {

final Agent agent;

/**
* Constructs a CallAgent with the specified agent.
*
* @param agent the agent to be associated with this CallAgent
*/
public CallAgent( Agent agent ) {
this.agent = agent;
}

/**
* Maps the result of the response from an AI message to a structured format.
*
* @param response the response containing the AI message
* @return a map containing the agent's outcome
* @throws IllegalStateException if the finish reason of the response is unsupported
*/
private Map<String,Object> mapResult( Response<AiMessage> response ) {

var content = response.content();
Expand All @@ -44,6 +60,13 @@ private Map<String,Object> mapResult( Response<AiMessage> response ) {
throw new IllegalStateException("Unsupported finish reason: " + response.finishReason() );
}

/**
* Applies the action to the given state and returns the result.
*
* @param state the state to which the action is applied
* @return a map containing the agent's outcome
* @throws IllegalArgumentException if no input is provided in the state
*/
@Override
public Map<String,Object> apply( AgentExecutor.State state ) {
log.trace( "callAgent" );
Expand Down

0 comments on commit 48c6c8c

Please sign in to comment.