Interface ConversationalApplication

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ConversationalApplication
Functional interface representing an application that can engage in multi-turn conversations.

This interface wraps the application under test, allowing it to receive conversation context and generate responses. Implementations typically delegate to a chat client or LLM service.

Example usage with Spring AI:


 ConversationalApplication app = trajectory -> {
     String response = chatClient.prompt()
             .messages(formatMessages(trajectory))
             .call()
             .content();
     return Message.assistant(response);
 };
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Generates a response to the current conversation state.
  • Method Details

    • respond

      Message respond(ConversationTrajectory trajectory)
      Generates a response to the current conversation state.

      The implementation should process the entire trajectory to maintain context awareness and generate an appropriate assistant response.

      Parameters:
      trajectory - the current conversation trajectory
      Returns:
      the assistant's response message