Skip to content

ThoughtProcesses

Pathos edited this page Jan 28, 2025 · 3 revisions

print("Importing basic_planner_thought_process.py") from src.logging import logging from pydantic import BaseModel, Field from src.thought_processes.branching_thought_process import BranchingThoughts, Question logging.info("Imported required libraries in basic_planner_thought_process.py")

thought_process_name = "basic_planner"

class ThoughtProcess(BaseModel): """The response format for characters is a schema that requires the assistant to respond in a specific way. The assistant must respond in a way that is consistent with the schema, and must follow the rules of the schema to respond to the user.""" why_is_the_user_saying_this: Question = Field(...,description="The question the character asks themselves to understand why the user is saying what they are saying. Should be at least a sentence long.",min_length=1) thought_branches: list[BranchingThoughts] = Field(...,min_items=1,max_items=5) questions: list[Question] = Field(...,min_items=1,max_items=5) plan: list[str] = Field(...,description="The plan the character makes to figure out how to respond to the user. Should be at least step item long and less than six steps total. Each step should be anywhere from a sentence to a paragraph in length.",min_items=1,max_items=5) response_to_user: str = Field(...,description="The final conclusion the character reaches and that is sent to the user as response to their initial query/prompt. Should be at least a paragraph long, but can be much longer as well, and consider everything that the character has thought about. It won't discuss the thought process but will summarize the character's final thoughts. Everything the character has thought about should be considered for inclusion in the conclusion, nothing else will be communicated to the end user.",min_length=1)

Thought Processes

Pantella has a system for enforcing Chain-of-Thought thinking for any LLM model using grammar restrained generation for local models, and for remote models this is done via response formats. Which, under the hood of their API is almost certainly a form of grammar restrained generation as well!

Thought Process Class

The thought process class is a pydantic model that defines the schema for the thought process. The thought process class should have the following fields:

  • response_to_user (string): The final conclusion the character reaches and that is sent to the user as response to their initial query/prompt. This is the only field in a throught process that must be included, and it typically should be included at the bottom of the thought process class to be used as the conclusion of the thought process.

Example of a Thought Process

There are several examples of a thought process in the ./src/thought_processes/ directory. This is a simple thought process that is used to plan out how a character will respond to a user query. The thought process has a ThoughtProcess class that is a pydantic model that defines the schema for the thought process. The field descriptions are required for the thought process to be valid, as they're parsed and sent to the LLM as instructions for how to generate the thought process.

print("Importing example_thought_process.py")
from src.logging import logging
from pydantic import BaseModel, Field
from src.thought_processes.branching_thought_process import BranchingThoughts, Question
logging.info("Imported required libraries in example_thought_process.py")

thought_process_name = "example"

class ThoughtProcess(BaseModel):
    """The response format for characters is a schema that requires the assistant to respond in a specific way. The assistant must respond in a way that is consistent with the schema, and must follow the rules of the schema to respond to the user."""
    why_is_the_user_saying_this: Question = Field(...,description="The question the character asks themselves to understand why the user is saying what they are saying. Should be at least a sentence long.",min_length=1)
    thought_branches: list[BranchingThoughts] = Field(...,min_items=1,max_items=5)
    questions: list[Question] = Field(...,min_items=1,max_items=5)
    plan: list[str] = Field(...,description="The plan the character makes to figure out how to respond to the user. Should be at least step item long and less than six steps total. Each step should be anywhere from a sentence to a paragraph in length.",min_items=1,max_items=5)
    response_to_user: str = Field(...,description="The final conclusion the character reaches and that is sent to the user as response to their initial query/prompt. Should be at least a paragraph long, but can be much longer as well, and consider everything that the character has thought about. It won't discuss the thought process but will summarize the character's final thoughts. Everything the character has thought about should be considered for inclusion in the conclusion, nothing else will be communicated to the end user.",min_length=1)

Clone this wiki locally