Skip to content

AI Models

lumen.ai.models

LineEdit = Annotated[InsertLine | ReplaceLine | DeleteLine, Field(discriminator='op')] module-attribute

DeleteLine

Bases: BaseModel

line_no = Field(ge=1, description='The 1-based line number to delete.') class-attribute instance-attribute

op = 'delete' class-attribute instance-attribute

ErrorDescription

Bases: BaseModel

Represents a user-facing error explanation.

Style rules: - Do not use first-person pronouns (“I”, “we”). - All outputs must be written in neutral, system-level language.

Guidance: - If you think it's an internal error, indicate that the user should rerun. - Otherwise, ask the user to either replan OR clarify their questions. - You are given the error type, message, the user query, and the plan the planning agent came up with.

explanation = Field(description='A brief description of the error suitable for a non-technical user.', max_length=300) class-attribute instance-attribute

EscapeBaseModel

Bases: PartialBaseModel

insufficient_context = Field(description='True if lacking context, else False. If True, leave other fields empty.') class-attribute instance-attribute

insufficient_context_reason = Field(description="If lacking sufficient context, explain why; else use ''. Do not base off the user query; only from the data context provided.", examples=['A timeseries is requested but SQL only provides customer and order data; please include a time dimension', 'The previous result is one aggregated value; try a different aggregation or more dimensions', '']) class-attribute instance-attribute

model_post_init(__context)

After model initialization, check if insufficient_context. If it is, raise a MissingContextError with the provided explanation to stop further processing.

InsertLine

Bases: BaseModel

line = Field(min_length=1, description='Content for the new line (must be non-empty).') class-attribute instance-attribute

line_no = Field(ge=1, description='Insert BEFORE this 1-based line number. Use line_no == len(lines) to append at the end.') class-attribute instance-attribute

op = 'insert' class-attribute instance-attribute

MissingContextError

Bases: Exception

Raise to indicate missing context for a query.

PartialBaseModel

Bases: BaseModel, PartialLiteralMixin

ReplaceLine

Bases: BaseModel

line = Field(description='The new content for the line (empty string is allowed).') class-attribute instance-attribute

line_no = Field(ge=1, description='The 1-based line number to replace.') class-attribute instance-attribute

op = 'replace' class-attribute instance-attribute

RetrySpec

Bases: BaseModel

Represents a revision of text with its content and changes.

chain_of_thought = Field(description='In 1-2 sentences, explain the plan to revise the text based on the feedback provided.', examples=['The SQL query failed due to missing quotes around the column name. Will add double quotes to fix the syntax error.', 'The chart needs horizontal bars instead of vertical. Will swap x and y encodings.']) class-attribute instance-attribute

edits = Field(description='A list of line edits based on the chain_of_thought.') class-attribute instance-attribute

validate_indices_nonconflicting()

ThinkingYesNo

Bases: BaseModel

chain_of_thought = Field(description='In 1-2 sentences, explain your reasoning for yes or no.', examples=['The query asks for top 10 hosts which requires extending the existing aggregation from LIMIT 1 to LIMIT 10.', 'The data contains location and count columns needed for a bar chart visualization.']) class-attribute instance-attribute

yes = Field(description='True if yes, otherwise False.') class-attribute instance-attribute

YesNo

Bases: BaseModel

yes = Field(description='True if yes, otherwise False.') class-attribute instance-attribute