yera.dsl.workspace

An app's memory: chat history and programmatic state.

Symbols

class Workspace — An app's memory: chat history and programmatic state.

Workspace

An app's memory: chat history and programmatic state.

Each app has a single workspace, shared across any nested model
contexts the app contains. The workspace holds both the LLM's
conversation history — what [`chat`](/docs/yera/reference/api/chat/) and
[`Struct.fill`](/docs/yera/reference/api/struct/#fill) see and append to — and
a dict-style variable store the app's Python code can read and
write.

The variable store is for Python-side state the app threads
through its own logic. The LLM does not see these variables by
default; future versions will allow apps to opt into reading
workspace variables as part of their context.

Sub-apps do not share their parent's workspace by default.

The module-level ``workspace`` singleton is the entry point; apps
do not construct ``Workspace`` instances directly.

Example:

        workspace["customer_name"] = "Alice"
        ...
        name = workspace["customer_name"]

Methods

get — Get a value from workspace, returning default if key doesn't exist.
set — Set a value in workspace.
__getitem__ — Get a value from workspace, raising KeyError if key doesn't exist.
__setitem__ — Set a value in workspace.
__contains__ — Check if a key exists in workspace.

Workspace.get

get(
    key: str,
    default: object = None,
) → object

Get a value from workspace, returning default if key doesn't exist.

Parameters

key
type: str

The workspace key to retrieve

default
type: object = None

Value to return if key doesn't exist (default: None)

Returns

type: object

The value associated with key, or default if key doesn't exist

Workspace.set

set(
    key: str,
    value: object,
) → None

Set a value in workspace.

Parameters

key
type: str

The workspace key to set

value
type: object

The value to store

Workspace.__getitem__

__getitem__(
    key: str,
) → object

Get a value from workspace, raising KeyError if key doesn't exist.

Parameters

key
type: str

The workspace key to retrieve

Returns

type: object

The value associated with key

Raises

KeyError

If the key doesn't exist in workspace

Workspace.__setitem__

__setitem__(
    key: str,
    value: object,
) → None

Set a value in workspace.

Parameters

key
type: str

The workspace key to set

value
type: object

The value to store

Workspace.__contains__

__contains__(
    key: str,
) → bool

Check if a key exists in workspace.

Parameters

key
type: str

The workspace key to check

Returns

type: bool

True if key exists, False otherwise