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:
BaseModelMessage 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:
BaseModelMessage containing a validation response from the client.
- origin: Literal['user']#
- kind: Literal['validation_response']#
- rejected: bool#
- validation: Validation#
- 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:
BaseModelMessage containing a solve response from the user.
- origin: Literal['user']#
- kind: Literal['solve_response']#
- rejected: bool#
- validation: Validation#
- 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:
BaseModelSystem 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:
BaseModelResponse 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:
BaseModelA 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']#
- class decision_ai.ToolData(*, name: str, args: dict, id: str | None = None, preface: str | None = None)#
Bases:
BaseModelRepresents 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:
BaseModelNon-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:
BaseModelCritical 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:
BaseModelMessage 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:
BaseModelMessage 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:
BaseModelMessage requesting validation of code.
- origin: Literal['assistant']#
- kind: Literal['ask_for_validation']#
- code: str#
- changes: ModelChanges#
- class decision_ai.AskForSolve(*, origin: Literal['assistant'] = 'assistant', kind: Literal['ask_for_solve'] = 'ask_for_solve', code: str, tool_origin: ToolData)#
Bases:
BaseModelMessage requesting to solve a problem with the provided code.
- origin: Literal['assistant']#
- kind: Literal['ask_for_solve']#
- code: str#
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:
BaseModelA 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:
BaseModelMessage 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:
BaseModelMessage 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:
BaseModelMessage 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’)]
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:
BaseModelRepresents 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:
BaseModelSnapshot 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:
BaseModelRepresents 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:
BaseModelSnapshot 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:
BaseModelRepresents 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:
BaseModelSnapshot 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:
BaseModelRepresents 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#