Skip to content

ai_application

marvin.components.ai_application

AIApplication

An AI application is a stateful, autonomous, natural language interface to an application.

Attributes:

Name Type Description
name Optional[str]

The name of the application.

description Optional[str]

A description of the application.

state BaseModel

The application's state - this can be any JSON-serializable object.

plan AppPlan

The AI's plan in service of the application - this can be any JSON-serializable object.

tools list[Union[Tool, Callable[..., Any]]]

A list of tools that the AI can use to interact with application or outside world.

history History

A history of all messages sent and received by the AI.

additional_prompts list[Prompt]

A list of additional prompts that will be added to the prompt stack for rendering.

Example

Create a simple todo app where AI manages its own state and plan.

from marvin import AIApplication

todo_app = AIApplication(
    name="Todo App",
    description="A simple todo app.",
)

todo_app("I need to go to the store.")

print(todo_app.state, todo_app.plan)

AppPlan

The AI's plan in service of the application.

Attributes:

Name Type Description
tasks list[Task]

A list of tasks the AI is working on.

notes list[str]

A list of notes the AI has taken.

FreeformState

A freeform state object that can be used to store any JSON-serializable data.

Attributes:

Name Type Description
state dict[str, Any]

The state object.

JSONPatchModel

A JSON Patch document.

Attributes:

Name Type Description
op str

The operation to perform.

path str

The path to the value to update.

value Union[str, float, int, bool, list, dict, None]

The value to update the path to.

from_ Optional[str]

The path to the value to copy from.

TaskState

The state of a task.

Attributes:

Name Type Description
PENDING

The task is pending and has not yet started.

IN_PROGRESS

The task is in progress.

COMPLETED

The task is completed.

FAILED

The task failed.

SKIPPED

The task was skipped.

UpdatePlan

A Tool that updates the apps plan using JSON Patch documents.

UpdateState

A Tool that updates the apps state using JSON Patch documents.