Chat Source Metadata Helper (chat/source.py)

opensquilla · src/opensquilla/chat/source.py · python · Apache-2.0
chat, infra, analytics, lang:python, tag:metadata

A utility function to generate standardized metadata for chat sources across different frontends. Use this to ensure consistent logging and tracking of chat origins.

# Source: https://github.com/TokenRhythm/opensquilla | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Chat source metadata helpers shared by frontends."""

from __future__ import annotations

from typing import Any

from opensquilla.run_mode import normalize_run_mode


def chat_source_metadata(
    *,
    caller_kind: str,
    channel_kind: str,
    channel_id: str,
    sender_id: str,
    source_kind: str,
    source_name: str,
    elevated: str | None = None,
    run_mode: str | None = None,
) -> dict[str, Any]:
    source: dict[str, Any] = {
        "caller_kind": caller_kind,
        "channel_kind": channel_kind,
        "channel_id": channel_id,
        "sender_id": sender_i

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key