plexus.scores.nodes.MultiClassClassifier module

class plexus.scores.nodes.MultiClassClassifier.MultiClassClassifier(**parameters)

Bases: BaseNode

A node that classifies text input as one of multiple classes based on the provided prompt.

class ClassificationOutputParser(valid_classes: List[str], fuzzy_match: bool = False, fuzzy_match_threshold: float = 0.8, parse_from_start: bool = False)

Bases: BaseOutputParser

A parser that classifies the output as one of the valid classes.

__init__(valid_classes: List[str], fuzzy_match: bool = False, fuzzy_match_threshold: float = 0.8, parse_from_start: bool = False)
fuzzy_match: bool
fuzzy_match_threshold: float
model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

parse(output: str) Dict[str, Any]

Parse a single string model output into some structure.

Args:

text: String output of a language model.

Returns:

Structured output.

parse_from_start: bool
valid_classes: List[str]
class GraphState(*, text: str, metadata: dict | None = None, results: dict | None = None, messages: ~typing.List[~typing.Dict[str, ~typing.Any]] | None = None, is_not_empty: bool | None = None, value: str | None = None, explanation: str | None, reasoning: str | None = None, chat_history: ~typing.List[~typing.Any] = <factory>, completion: str | None = None, classification: str | None, confidence: float | None = None, retry_count: int | None = 0, at_llm_breakpoint: bool | None = False, good_call: str | None = None, good_call_explanation: str | None = None, non_qualifying_reason: str | None = None, non_qualifying_explanation: str | None = None, **extra_data: ~typing.Any)

Bases: GraphState

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

classification: str | None
explanation: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'validate_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

retry_count: int | None
class Parameters(*, model_provider: ~typing.Literal['ChatOpenAI', 'AzureChatOpenAI', 'BedrockChat', 'ChatVertexAI'] = 'AzureChatOpenAI', model_name: str | None = None, base_model_name: str | None = None, model_region: str | None = None, temperature: float | None = 0, top_p: float | None = 0.03, max_tokens: int | None = 500, input: dict | None = None, output: dict | None = None, system_message: str | None = None, user_message: str | None = None, example_refinement_message: str | None = None, single_line_messages: bool = False, name: str | None = None, fuzzy_match: bool = False, fuzzy_match_threshold: float = 0.8, valid_classes: ~typing.List[str] = <factory>, explanation_message: str | None = None, explanation_model: ~typing.Dict[str, ~typing.Any] | None = None, maximum_retry_count: int = 3, parse_from_start: bool | None = False)

Bases: Parameters

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

explanation_message: str | None
explanation_model: Dict[str, Any] | None
fuzzy_match: bool
fuzzy_match_threshold: float
maximum_retry_count: int
model_config: ClassVar[ConfigDict] = {'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

parse_from_start: bool | None
valid_classes: List[str]
__init__(**parameters)
add_core_nodes(workflow: StateGraph) StateGraph

Build and return a core LangGraph workflow. The node name is available as self.node_name when needed.

get_classifier_node() LambdaType