haive.agents.reasoning_and_critique.tot.models ============================================== .. py:module:: haive.agents.reasoning_and_critique.tot.models .. autoapi-nested-parse:: Tree of Thoughts (ToT) models and data structures. This module defines the core data models for the Tree of Thoughts reasoning algorithm, including candidate solutions and structured output models. Classes ------- .. autoapisummary:: haive.agents.reasoning_and_critique.tot.models.Candidate haive.agents.reasoning_and_critique.tot.models.CandidateEvaluation haive.agents.reasoning_and_critique.tot.models.CandidateGeneration haive.agents.reasoning_and_critique.tot.models.Equation haive.agents.reasoning_and_critique.tot.models.EquationGeneration haive.agents.reasoning_and_critique.tot.models.Score haive.agents.reasoning_and_critique.tot.models.ScoredCandidate Functions --------- .. autoapisummary:: haive.agents.reasoning_and_critique.tot.models.update_candidates Module Contents --------------- .. py:class:: Candidate(/, **data) Bases: :py:obj:`pydantic.BaseModel`, :py:obj:`Generic`\ [\ :py:obj:`T`\ ] A candidate solution in the Tree of Thoughts algorithm. This represents an unscored candidate solution generated by the LLM. 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. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: CandidateEvaluation(/, **data) Bases: :py:obj:`pydantic.BaseModel` Structured output model for evaluating a candidate solution. This model is used when the evaluator LLM produces structured output. 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. .. py:method:: to_score() Convert to a Score object. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: CandidateGeneration(/, **data) Bases: :py:obj:`pydantic.BaseModel`, :py:obj:`Generic`\ [\ :py:obj:`T`\ ] Structured output model for generating multiple candidate solutions. This model is used when the generator LLM produces structured output. 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. .. py:method:: to_candidates() Convert candidate contents to Candidate objects. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: Equation(/, **data) Bases: :py:obj:`pydantic.BaseModel` An equation in reverse-polish notation that combines numbers to reach a target value. This is one possible implementation of a solution type for mathematical problems. 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. .. py:method:: compute() Compute the result of the equation. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: EquationGeneration(/, **data) Bases: :py:obj:`pydantic.BaseModel` Specialized candidate generation for equation problems. This is a structured output model for equation-specific generation. 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. .. py:method:: to_candidates() Convert equations to Candidate objects. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: Score(/, **data) Bases: :py:obj:`pydantic.BaseModel` A score with feedback. This represents the evaluation of a candidate solution. 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. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: ScoredCandidate(/, **data) Bases: :py:obj:`pydantic.BaseModel`, :py:obj:`Generic`\ [\ :py:obj:`T`\ ] A candidate solution with its evaluation score. This combines a candidate solution with its score and feedback. 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. .. py:property:: content :type: T Get the content of the candidate. .. py:property:: feedback :type: str | None Get the feedback if any. .. py:property:: metadata :type: dict[str, Any] Get the metadata of the candidate. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:property:: value :type: float Get the numerical score value. .. py:function:: update_candidates(existing = None, updates = None) Update candidate list, handling special cases like clearing. :param existing: Current list of candidates :param updates: New candidates to add, or "clear" to empty the list :returns: Updated list of candidates