Chain of Thoughts API

ChatConfig field

chain_of_thought is a field on ractogateway._models.chat.ChatConfig.

class ractogateway._models.chat.ChatConfig(**data)[source]

Bases: BaseModel

Validated input for every chat / achat / stream / astream call.

Pass a single ChatConfig to any developer-kit method. Every field has a safe default so you only need to supply what you actually need.

Minimal example:

config = ChatConfig(user_message="Explain Python generators.")
response = kit.chat(config)

Vision / multimodal example:

from ractogateway.prompts.engine import RactoFile

config = ChatConfig(
    user_message="Describe this chart.",
    attachments=[RactoFile.from_path("sales_q4.png")],
)

Structured JSON output example:

class Sentiment(BaseModel):
    label: str
    score: float

config = ChatConfig(
    user_message="I love this library!",
    response_model=Sentiment,
)

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.

user_message: str
prompt: RactoPrompt | None
temperature: float
max_tokens: int
tools: ToolRegistry | None
auto_execute_tools: bool
max_tool_turns: int
response_model: type[BaseModel] | None
max_validation_retries: int
history: list[Message]
attachments: list[RactoFile] | None
chain_of_thought: bool
native_thinking: bool
thinking_budget: int
extra: dict[str, Any]
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

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

Helper function

Chain-of-thought prompt injection utility.

Internal helper used by every developer kit when ChatConfig(chain_of_thought=True) is set. The function is a pure transformation — it never mutates the original prompt.

ractogateway._cot.apply_chain_of_thought(prompt)[source]

Return a copy of prompt with a chain-of-thought constraint appended.

The original prompt is never mutated. The constraint is appended last so it appears at the bottom of the [CONSTRAINTS] section and is processed after all caller-defined rules.

Parameters:

prompt (RactoPrompt) – The RactoPrompt to augment.

Return type:

RactoPrompt

Returns:

RactoPrompt – A new instance with the CoT constraint added.