primus.cli.score_chat.repl module

Implementation of a Rich-based REPL for the Primus score chat command.

This module provides an interactive REPL interface for working with Primus scores, using Rich for beautiful terminal output and command history.

class primus.cli.score_chat.repl.ScoreChatREPL(scorecard: str | None = None, score: str | None = None)

Bases: object

Interactive REPL for working with Primus scores.

__init__(scorecard: str | None = None, score: str | None = None)
handle_command(command: str)

Handle explicit commands.

handle_natural_language(user_input: str)

Handle natural language input from the user.

initialize_system_message()

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

list_scorecards()

List available scorecards.

load_score(scorecard: str, score: str)

Load a score’s configuration.

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.

run()

Run the REPL.

show_help()

Show available commands.

class primus.cli.score_chat.repl.StreamingCallbackHandler(console: Console)

Bases: BaseCallbackHandler

Callback handler for streaming LLM responses.

__init__(console: Console)
on_llm_end(*args, **kwargs)

Called when the LLM finishes generating.

on_llm_error(error: Exception, *args, **kwargs)

Called when the LLM encounters an error.

on_llm_new_token(token: str, *args, **kwargs)

Called when a new token is generated.

on_llm_start(*args, **kwargs)

Called when the LLM starts generating.

on_tool_end(output: str, **kwargs: Any) → None

Called when a tool finishes being used.

on_tool_start(serialized: Dict[str, Any], input_str: str, **kwargs: Any) → None

Called when a tool starts being used.