plexus.cli.score_chat.service module

Implementation of a reusable service for the Plexus score chat command.

This module provides core chat functionality for working with Plexus scores, which can be used by different interfaces (CLI REPL, Celery worker, etc.).

class plexus.cli.score_chat.service.ScoreChatService(scorecard: str | None = None, score: str | None = None, callback_handler: BaseCallbackHandler | None = None, message_callback: Callable[[str], None] | None = None)

Bases: object

Core service for handling chat functionality for Plexus scores.

Initialize the chat service.

Args:

scorecard: Optional scorecard identifier score: Optional score identifier callback_handler: Optional callback handler for LLM streaming message_callback: Optional callback for receiving message outputs

__init__(scorecard: str | None = None, score: str | None = None, callback_handler: BaseCallbackHandler | None = None, message_callback: Callable[[str], None] | None = None)

Initialize the chat service.

Args:

scorecard: Optional scorecard identifier score: Optional score identifier callback_handler: Optional callback handler for LLM streaming message_callback: Optional callback for receiving message outputs

initialize_session()

Initialize a chat session with a score.

initialize_system_message()

Initialize the system message with the current score’s information.

load_score(scorecard: str, score: str)

Load a score’s configuration.

process_message(user_input: str)

Process a natural language message from the user.

Args:

user_input: The user’s message

Returns:

List of responses, which may include tool outputs

pull_score(scorecard: str, score: str)

Pull a score’s current version.

push_score(scorecard: str, score: str)

Push a score’s updated version.

recover_and_continue()

Recover from an error by creating a simplified chat history and continuing the conversation.