mirror of
https://github.com/hwchase17/langchain
synced 2024-10-29 17:07:25 +00:00
e7e5cb9d08
# [WIP] Tree of Thought introducing a new ToTChain. This PR adds a new chain called ToTChain that implements the ["Large Language Model Guided Tree-of-Though"](https://arxiv.org/pdf/2305.08291.pdf) paper. There's a notebook example `docs/modules/chains/examples/tot.ipynb` that shows how to use it. Implements #4975 ## Who can review? Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested: - @hwchase17 - @vowelparrot --------- Co-authored-by: Vadim Gubergrits <vgubergrits@outbox.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
22 lines
398 B
Python
22 lines
398 B
Python
from __future__ import annotations
|
|
|
|
from enum import Enum
|
|
from typing import Set
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ThoughtValidity(Enum):
|
|
VALID_INTERMEDIATE = 0
|
|
VALID_FINAL = 1
|
|
INVALID = 2
|
|
|
|
|
|
class Thought(BaseModel):
|
|
text: str
|
|
validity: ThoughtValidity
|
|
children: Set[Thought] = Field(default_factory=set)
|
|
|
|
def __hash__(self) -> int:
|
|
return id(self)
|