Chat Messages#

API Reference > Chat > Chat Connection

This section documents the various message types used for communication with the DecisionAI assistant.

User Messages#

Messages sent from the user to the assistant.

class decision_ai.Prompt(*, origin: Literal['user'] = 'user', kind: Literal['prompt'] = 'prompt', prompt: str)#

Bases: BaseModel

Message containing a prompt from the user.

Parameters:
  • origin (Literal["user"], optional) – The originator of the message, used for message discrimination. Defaults to “user”.

  • kind (Literal["prompt"], optional) – The type of the message, used for message discrimination. Defaults to “prompt”.

  • prompt (str) – The text of the prompt.

origin: Literal['user']#
kind: Literal['prompt']#
prompt: str#
classmethod validate_prompt_not_empty(v: str) str#

Validate that prompt is not empty or whitespace-only.

class decision_ai.ValidationResponse(*, origin: Literal['user'] = 'user', kind: Literal['validation_response'] = 'validation_response', rejected: bool, validation: ValidationSucceeded | FormulationValidationFailed | InputDataSchemaValidationFailed, tool_origin: ToolData, rejection_message: str | None = None, changes: Annotated[ConstraintDiff | ObjectiveDiff | OptInputDataDiff | OptInputDataSchemaDiff | VariableDiff, FieldInfo(annotation=NoneType, required=True, discriminator='kind')] | None = None)#

Bases: BaseModel

Message containing a validation response from the client.

origin: Literal['user']#
kind: Literal['validation_response']#
rejected: bool#
validation: Validation#
tool_origin: ToolData#
rejection_message: str | None#
changes: ModelChanges | None#
class decision_ai.SolveResponse(*, origin: Literal['user'] = 'user', kind: Literal['solve_response'] = 'solve_response', rejected: bool, validation: ValidationSucceeded | FormulationValidationFailed | InputDataSchemaValidationFailed, tool_origin: ToolData, solving: Annotated[SolveSucceeded | SolveFailed, FieldInfo(annotation=NoneType, required=True, discriminator='kind')] | None = None, rejection_message: str | None = None)#

Bases: BaseModel

Message containing a solve response from the user.

origin: Literal['user']#
kind: Literal['solve_response']#
rejected: bool#
validation: Validation#
tool_origin: ToolData#
solving: Solving | None#
rejection_message: str | None#

Assistant Messages#

Messages sent from the assistant to the user.

class decision_ai.SystemPrompt(*, origin: Literal['assistant'] = 'assistant', kind: Literal['system_prompt'] = 'system_prompt', content: str)#

Bases: BaseModel

System prompt message from the assistant.

origin: Literal['assistant']#
kind: Literal['system_prompt']#
content: str#
class decision_ai.ChatResponse(*, origin: Literal['assistant'] = 'assistant', kind: Literal['chat_response'] = 'chat_response', response: str)#

Bases: BaseModel

Response message from the chat system.

Parameters:
  • origin (Literal["assistant"], optional) – The originator of the message, used for message discrimination. Defaults to “assistant”.

  • kind (Literal["chat_response"], optional) – The type of the message, used for message discrimination. Defaults to “chat_response”.

  • response (str) – The response data.

origin: Literal['assistant']#
kind: Literal['chat_response']#
response: str#
class decision_ai.ToolCall(*, origin: Literal['assistant'] = 'assistant', kind: Literal['tool_call'] = 'tool_call', tool_data: list[ToolData])#

Bases: BaseModel

A message indicating a tool call is being made.

Parameters:
  • origin (Literal["assistant"], optional) – The originator of the message, used for message discrimination. Defaults to “assistant”.

  • kind (Literal["tool_call"], optional) – The type of the message, used for message discrimination. Defaults to “tool_call”.

  • tool_data (list[ToolData]) – A list of tool calls.

origin: Literal['assistant']#
kind: Literal['tool_call']#
tool_data: list[ToolData]#
class decision_ai.ToolData(*, name: str, args: dict, id: str | None = None, preface: str | None = None)#

Bases: BaseModel

Represents the data for a tool call.

Parameters:
  • name (str) – The name of the tool to be called.

  • args (dict) – The arguments for the tool.

  • id (str | None) – An optional ID for the tool call.

  • preface (str | None) – A message to be displayed before the tool call.

name: str#
args: dict#
id: str | None#
preface: str | None#
class decision_ai.UncriticalErrorMessage(*, origin: Literal['assistant'] = 'assistant', kind: Literal['error'] = 'error', error: str)#

Bases: BaseModel

Non-critical error message.

origin: Literal['assistant']#
kind: Literal['error']#
error: str#
class decision_ai.CriticalErrorMessage(*, origin: Literal['assistant'] = 'assistant', kind: Literal['critical_error'] = 'critical_error', error: str)#

Bases: BaseModel

Critical error message that requires attention.

origin: Literal['assistant']#
kind: Literal['critical_error']#
error: str#
class decision_ai.AskForPrompt(*, origin: Literal['assistant'] = 'assistant', kind: Literal['ask_for_prompt'] = 'ask_for_prompt')#

Bases: BaseModel

Message requesting a prompt from the user.

origin: Literal['assistant']#
kind: Literal['ask_for_prompt']#
class decision_ai.AskForFeedback(*, origin: Literal['assistant'] = 'assistant', kind: Literal['ask_for_feedback'] = 'ask_for_feedback')#

Bases: BaseModel

Message requesting feedback from the user.

origin: Literal['assistant']#
kind: Literal['ask_for_feedback']#
class decision_ai.AskForValidation(*, origin: Literal['assistant'] = 'assistant', kind: Literal['ask_for_validation'] = 'ask_for_validation', code: str, changes: ConstraintDiff | ObjectiveDiff | OptInputDataDiff | OptInputDataSchemaDiff | VariableDiff, tool_origin: ToolData)#

Bases: BaseModel

Message requesting validation of code.

origin: Literal['assistant']#
kind: Literal['ask_for_validation']#
code: str#
changes: ModelChanges#
tool_origin: ToolData#
class decision_ai.AskForSolve(*, origin: Literal['assistant'] = 'assistant', kind: Literal['ask_for_solve'] = 'ask_for_solve', code: str, tool_origin: ToolData)#

Bases: BaseModel

Message requesting to solve a problem with the provided code.

origin: Literal['assistant']#
kind: Literal['ask_for_solve']#
code: str#
tool_origin: ToolData#

Tool Messages#

Messages related to tool execution.

class decision_ai.ToolOutput(*, origin: Literal['tool'] = 'tool', kind: Literal['tool_output'] = 'tool_output', tool_id: str, tool_output: str)#

Bases: BaseModel

A message containing the output of a tool.

Parameters:
  • origin (Literal["tool"], optional) – The originator of the message, used for message discrimination. Defaults to “tool”.

  • kind (Literal["tool_output"], optional) – The type of the message, used for message discrimination. Defaults to “tool_output”.

  • tool_id (str) – The ID of the tool call this is an output for.

  • tool_output (str) – The output of the tool.

origin: Literal['tool']#
kind: Literal['tool_output']#
tool_id: str#
tool_output: str#

Validation Messages#

Messages related to validation processes.

decision_ai.Validation#

alias of Annotated[ValidationSucceeded | FormulationValidationFailed | InputDataSchemaValidationFailed, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)]

class decision_ai.ValidationSucceeded(*, kind: Literal['validation_succeeded'] = 'validation_succeeded')#

Bases: BaseModel

Message indicating that validation has succeeded.

kind: Literal['validation_succeeded']#
decision_ai.ValidationFailed#

alias of FormulationValidationFailed | InputDataSchemaValidationFailed

class decision_ai.FormulationValidationFailed(*, kind: Literal['formulation_validation_failed'] = 'formulation_validation_failed', error: str | FormulationErrorReport)#

Bases: BaseModel

Message indicating that formulation validation has failed.

kind: Literal['formulation_validation_failed']#
error: str | FormulationErrorReport#
class decision_ai.InputDataSchemaValidationFailed(*, kind: Literal['input_data_instance_validation_failed'] = 'input_data_instance_validation_failed', input_data_class_name: str, error: str)#

Bases: BaseModel

Message indicating that input data instance validation has failed.

kind: Literal['input_data_instance_validation_failed']#
input_data_class_name: str#
error: str#

Solving Messages#

Messages related to solving processes.

decision_ai.Solving#

alias of Annotated[SolveSucceeded | SolveFailed, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)]

class decision_ai.SolveSucceeded(*, kind: Literal['solve_succeeded'] = 'solve_succeeded', solution_str: str, solution_status: str)#

Bases: BaseModel

Message indicating that solving has succeeded.

kind: Literal['solve_succeeded']#
solution_str: str#
solution_status: str#
class decision_ai.SolveFailed(*, kind: Literal['solve_failed'] = 'solve_failed', status: Literal['infeasible', 'error'], error: str | None = None)#

Bases: BaseModel

Message indicating that solving has failed.

kind: Literal['solve_failed']#
status: Literal['infeasible', 'error']#
error: str | None#

Model Changes#

Messages related to model changes and diffs.

decision_ai.ModelChanges#

alias of Annotated[ConstraintDiff | ObjectiveDiff | OptInputDataDiff | OptInputDataSchemaDiff | VariableDiff, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)]

class decision_ai.ConstraintDiff(*, kind: Literal['constraint_diff'] = 'constraint_diff', removed: ConstraintSnapshot | None = None, added: ConstraintSnapshot | None = None)#

Bases: BaseModel

Represents changes to a constraint between two states.

Parameters:
  • kind (Literal["constraint_diff"], optional) – Type discriminator for constraint differences. Defaults to “constraint_diff”.

  • removed (ConstraintSnapshot | None, optional) – Previous state of the constraint, None if constraint was added. Defaults to None.

  • added (ConstraintSnapshot | None, optional) – New state of the constraint, None if constraint was removed. Defaults to None.

kind: Literal['constraint_diff']#
removed: ConstraintSnapshot | None#
added: ConstraintSnapshot | None#
class decision_ai.ConstraintSnapshot(*, constraint_id: str, code: str, math_formulation: str, description: str)#

Bases: BaseModel

Snapshot of a constraint at a specific point in time.

Parameters:
  • constraint_id (str) – Unique identifier for the constraint.

  • code (str) – Python code representation of the constraint.

  • math_formulation (str) – Mathematical formulation of the constraint.

  • description (str) – Human-readable description of the constraint.

constraint_id: str#
code: str#
math_formulation: str#
description: str#
class decision_ai.ObjectiveDiff(*, kind: Literal['objective_function_diff'] = 'objective_function_diff', removed: ObjectiveSnapshot | None = None, added: ObjectiveSnapshot | None = None)#

Bases: BaseModel

Represents changes to an objective function between two states.

Parameters:
  • kind (Literal["objective_function_diff"], optional) – Type discriminator for objective function differences. Defaults to “objective_function_diff”.

  • removed (ObjectiveSnapshot | None, optional) – Previous state of the objective function, None if objective was added. Defaults to None.

  • added (ObjectiveSnapshot | None, optional) – New state of the objective function, None if objective was removed. Defaults to None.

kind: Literal['objective_function_diff']#
removed: ObjectiveSnapshot | None#
added: ObjectiveSnapshot | None#
class decision_ai.ObjectiveSnapshot(*, code: str, math_formulation: str, description: str)#

Bases: BaseModel

Snapshot of an objective function at a specific point in time.

Parameters:
  • code (str) – Python code representation of the objective function.

  • math_formulation (str) – Mathematical formulation of the objective function.

  • description (str) – Human-readable description of the objective function.

code: str#
math_formulation: str#
description: str#
class decision_ai.OptInputDataDiff(*, kind: Literal['input_data_diff'] = 'input_data_diff', removed: OptInputDataSnapshot | None = None, added: OptInputDataSnapshot | None = None)#

Bases: BaseModel

Represents changes to optimization input data between two states.

Parameters:
  • kind (Literal["input_data_diff"], optional) – Type discriminator for input data differences. Defaults to “input_data_diff”.

  • removed (OptInputDataSnapshot | None, optional) – Previous state of the input data, None if data was added. Defaults to None.

  • added (OptInputDataSnapshot | None, optional) – New state of the input data, None if data was removed. Defaults to None.

kind: Literal['input_data_diff']#
removed: OptInputDataSnapshot | None#
added: OptInputDataSnapshot | None#
class decision_ai.OptInputDataSnapshot(*, opt_input_data_id: str, json_data: str)#

Bases: BaseModel

Snapshot of optimization input data at a specific point in time.

Parameters:
  • opt_input_data_id (str) – Unique identifier for the optimization input data.

  • json_data (str) – JSON string representation of the input data.

opt_input_data_id: str#
json_data: str#
class decision_ai.OptInputDataSchemaDiff(*, kind: Literal['input_data_schema_diff'] = 'input_data_schema_diff', removed: OptInputDataSchemaSnapshot | None = None, added: OptInputDataSchemaSnapshot | None = None)#

Bases: BaseModel

Represents changes to optimization input data schema between two states.

Parameters:
  • kind (Literal["input_data_schema_diff"], optional) – Type discriminator for input data schema differences. Defaults to “input_data_schema_diff”.

  • removed (OptInputDataSchemaSnapshot | None, optional) – Previous state of the schema, None if schema was added. Defaults to None.

  • added (OptInputDataSchemaSnapshot | None, optional) – New state of the schema, None if schema was removed. Defaults to None.

kind: Literal['input_data_schema_diff']#
removed: OptInputDataSchemaSnapshot | None#
added: OptInputDataSchemaSnapshot | None#
class decision_ai.OptInputDataSchemaSnapshot(*, input_data_classes: list[str])#

Bases: BaseModel

Snapshot of optimization input data schema at a specific point in time.

Parameters:

input_data_classes (list[str]) – List of input data class definitions.

input_data_classes: list[str]#

Message Containers & Unions#

These are utility types for handling messages.

class decision_ai.MessageContainer(*, chat_session_id: str, message: ~types.Annotated[~decision_ai.client.schemas.chat_messages.chat.Prompt | ~decision_ai.client.schemas.chat_messages.protocol.ValidationResponse | ~decision_ai.client.schemas.chat_messages.protocol.SolveResponse, FieldInfo(annotation=NoneType, required=True, discriminator='kind')] | ~types.Annotated[~decision_ai.client.schemas.chat_messages.chat.SystemPrompt | ~decision_ai.client.schemas.chat_messages.chat.ChatResponse | ~decision_ai.client.schemas.chat_messages.chat.Reasoning | ~decision_ai.client.schemas.chat_messages.tool.ToolCall | ~decision_ai.client.schemas.chat_messages.error.UncriticalErrorMessage | ~decision_ai.client.schemas.chat_messages.error.CriticalErrorMessage | ~decision_ai.client.schemas.chat_messages.protocol.AskForPrompt | ~decision_ai.client.schemas.chat_messages.protocol.AskForFeedback | ~decision_ai.client.schemas.chat_messages.protocol.AskForValidation | ~decision_ai.client.schemas.chat_messages.protocol.AskForSolve, FieldInfo(annotation=NoneType, required=True, discriminator='kind')] | ~decision_ai.client.schemas.chat_messages.tool.Annotated[~decision_ai.client.schemas.chat_messages.tool.ToolOutput, FieldInfo(annotation=NoneType, required=True, discriminator='kind')], timestamp: int | None = None, message_id: str = <factory>)#

Bases: BaseModel

A container for a chat message.

Parameters:
  • chat_session_id (str) – The ID of the chat session.

  • message (ChatMessage) – The chat message.

  • timestamp (int, optional) – The timestamp of the message. Defaults to None.

  • message_id (str, optional) – The ID of the message. Defaults to a random UUID.

chat_session_id: str#
message: ChatMessage#
timestamp: int | None#
message_id: str#
decision_ai.UserMessage(*args, **kwargs)#

Runtime representation of an annotated type.

At its core ‘Annotated[t, dec1, dec2, …]’ is an alias for the type ‘t’ with extra annotations. The alias behaves like a normal typing alias. Instantiating is the same as instantiating the underlying type; binding it to types is also the same.

The metadata itself is stored in a ‘__metadata__’ attribute as a tuple.

alias of Annotated[Prompt | ValidationResponse | SolveResponse, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)]

decision_ai.AssistantMessage(*args, **kwargs)#

Runtime representation of an annotated type.

At its core ‘Annotated[t, dec1, dec2, …]’ is an alias for the type ‘t’ with extra annotations. The alias behaves like a normal typing alias. Instantiating is the same as instantiating the underlying type; binding it to types is also the same.

The metadata itself is stored in a ‘__metadata__’ attribute as a tuple.

alias of Annotated[SystemPrompt | ChatResponse | Reasoning | ToolCall | UncriticalErrorMessage | CriticalErrorMessage | AskForPrompt | AskForFeedback | AskForValidation | AskForSolve, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)]

decision_ai.ToolMessage(*args, **kwargs)#

Runtime representation of an annotated type.

At its core ‘Annotated[t, dec1, dec2, …]’ is an alias for the type ‘t’ with extra annotations. The alias behaves like a normal typing alias. Instantiating is the same as instantiating the underlying type; binding it to types is also the same.

The metadata itself is stored in a ‘__metadata__’ attribute as a tuple.

alias of Annotated[ToolOutput, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)]

decision_ai.ChatMessage(*args, **kwargs)#

Runtime representation of an annotated type.

At its core ‘Annotated[t, dec1, dec2, …]’ is an alias for the type ‘t’ with extra annotations. The alias behaves like a normal typing alias. Instantiating is the same as instantiating the underlying type; binding it to types is also the same.

The metadata itself is stored in a ‘__metadata__’ attribute as a tuple.

alias of Annotated[Annotated[Prompt | ValidationResponse | SolveResponse, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)] | Annotated[SystemPrompt | ChatResponse | Reasoning | ToolCall | UncriticalErrorMessage | CriticalErrorMessage | AskForPrompt | AskForFeedback | AskForValidation | AskForSolve, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)] | Annotated[ToolOutput, FieldInfo(annotation=NoneType, required=True, discriminator=’kind’)], FieldInfo(annotation=NoneType, required=True, discriminator=’origin’)]

decision_ai.ProtocolMessage = decision_ai.client.schemas.chat_messages.protocol.AskForPrompt | decision_ai.client.schemas.chat_messages.protocol.AskForFeedback | decision_ai.client.schemas.chat_messages.protocol.AskForValidation | decision_ai.client.schemas.chat_messages.protocol.AskForSolve | decision_ai.client.schemas.chat_messages.protocol.ValidationResponse | decision_ai.client.schemas.chat_messages.protocol.SolveResponse#

Represent a PEP 604 union type

E.g. for int | str

decision_ai.ProtocolRequestMessage = decision_ai.client.schemas.chat_messages.protocol.AskForPrompt | decision_ai.client.schemas.chat_messages.protocol.AskForFeedback | decision_ai.client.schemas.chat_messages.protocol.AskForValidation | decision_ai.client.schemas.chat_messages.protocol.AskForSolve#

Represent a PEP 604 union type

E.g. for int | str

decision_ai.ProtocolResponseMessage = decision_ai.client.schemas.chat_messages.protocol.ValidationResponse | decision_ai.client.schemas.chat_messages.protocol.SolveResponse#

Represent a PEP 604 union type

E.g. for int | str

Back to: API Reference (API Reference Overview)