Skip to content

chatomon.studio.server

Start the studio for an atom.

Functions:

Name Description
serve

Open the studio for an atom and block until interrupted.

Attributes:

Name Type Description
DEFAULT_PORT

The studio's port: oxygen-16, the most common oxygen atom (8 protons, 8 neutrons).

DEFAULT_PORT module-attribute

DEFAULT_PORT = 8016

The studio's port: oxygen-16, the most common oxygen atom (8 protons, 8 neutrons).

The "o" of chatomon is the letter the atom replaces in the wordmark, and chatomon has 8 letters. It also avoids the ports of similar tools: Gradio 7860, ADK 8000, Microsoft Agent Framework DevUI 8080, clai web 7932.

serve

serve(
    atom: Atom[Any] | Callable[[], Atom[Any]],
    *,
    host: str = "127.0.0.1",
    port: int = DEFAULT_PORT,
    open_browser: bool = True,
    preset: str | PathLike[str] | None = None
) -> None

Open the studio for an atom and block until interrupted.

The studio runs a copy of the atom with capture_content="full" and its own turn callback and tracer; the atom you pass is not changed. It writes to stderr the chatomon wordmark, the atom and its chains, and the link of this run, which carries its access token; then a line of labels, never content, for each action of the page.

Parameters:

Name Type Description Default
atom Atom[Any] | Callable[[], Atom[Any]]

The atom, or a function with no arguments that builds it.

required
host str

The address to listen on; another machine's address only with care.

'127.0.0.1'
port int

The port to listen on.

DEFAULT_PORT
open_browser bool

Whether to open the link in the browser.

True
preset str | PathLike[str] | None

The path of a preset exported from the studio, applied to the atom before the page opens. What differs from the exported session is printed as notes.

None

Raises:

Type Description
ChatomonConfigError

If the atom is invalid or unsupported, the host is a bind-all address, the port is in use, or the preset cannot be read or applied; the message has one line for each problem of the preset.

Examples:

from chatomon.studio import serve

from speedypack.app import atom

serve(atom)  # open the printed link, then chat with the atom

Start with the orbital changes of an earlier session:

from chatomon.studio import serve

from speedypack.app import atom

serve(atom, preset="speedypack.preset.json")
Source code in src/chatomon/studio/server.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def serve(
    atom: Atom[Any] | Callable[[], Atom[Any]],
    *,
    host: str = "127.0.0.1",
    port: int = DEFAULT_PORT,
    open_browser: bool = True,
    preset: str | os.PathLike[str] | None = None,
) -> None:
    """Open the studio for an atom and block until interrupted.

    The studio runs a copy of the atom with `capture_content="full"` and its
    own turn callback and tracer; the atom you pass is not changed. It writes
    to stderr the chatomon wordmark, the atom and its chains, and the link of
    this run, which carries its access token; then a line of labels, never
    content, for each action of the page.

    Args:
        atom: The atom, or a function with no arguments that builds it.
        host: The address to listen on; another machine's address only with care.
        port: The port to listen on.
        open_browser: Whether to open the link in the browser.
        preset: The path of a preset exported from the studio, applied to the atom
            before the page opens. What differs from the exported session is
            printed as notes.

    Raises:
        ChatomonConfigError: If the atom is invalid or unsupported, the host is a
            bind-all address, the port is in use, or the preset cannot be read or
            applied; the message has one line for each problem of the preset.

    Examples:
        ```{.python test="skip"}
        from chatomon.studio import serve

        from speedypack.app import atom

        serve(atom)  # open the printed link, then chat with the atom
        ```

        Start with the orbital changes of an earlier session:

        ```{.python test="skip"}
        from chatomon.studio import serve

        from speedypack.app import atom

        serve(atom, preset="speedypack.preset.json")
        ```
    """  # noqa: DOC502 - raised by resolve() and _start()
    _start(
        resolve(atom, label="the atom given to serve()"),
        source="serve()",
        host=host,
        port=port,
        open_browser=open_browser,
        preset=preset,
    )