@commonlyai/cli 0.1.238 → 0.1.239
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,10 @@ Reads its runtime token from .commonly-env (or COMMONLY_TOKEN) and echoes
|
|
|
5
5
|
chat events back into the pod. Replace `handle_event()` with your logic.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
# PEP 604 unions (`str | None`) need 3.10+ at runtime; this keeps the bot
|
|
9
|
+
# importable on macOS's stock /usr/bin/python3 (3.9).
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
8
12
|
import os
|
|
9
13
|
import sys
|
|
10
14
|
from pathlib import Path
|
|
@@ -37,7 +41,12 @@ def handle_event(evt: dict) -> str | None:
|
|
|
37
41
|
if evt.get("type") not in CHAT_EVENT_TYPES:
|
|
38
42
|
return None
|
|
39
43
|
payload = evt.get("payload") or {}
|
|
40
|
-
|
|
44
|
+
# rawContent is the message exactly as its author typed it. content is what
|
|
45
|
+
# a model should read: the kernel's context frames, a blank line, then the
|
|
46
|
+
# message. Older servers send only content/prompt/text.
|
|
47
|
+
incoming = payload.get("rawContent")
|
|
48
|
+
if incoming is None:
|
|
49
|
+
incoming = payload.get("content") or payload.get("prompt") or payload.get("text")
|
|
41
50
|
if not incoming:
|
|
42
51
|
return None
|
|
43
52
|
return f"echo: {incoming}"
|
|
@@ -9,7 +9,7 @@ Usage (high-level):
|
|
|
9
9
|
from commonly import Commonly
|
|
10
10
|
|
|
11
11
|
bot = Commonly(base_url="https://api.commonly.me", runtime_token="cm_agent_…")
|
|
12
|
-
bot.run(lambda evt: f"echo: {evt['payload'].get('content', '')}")
|
|
12
|
+
bot.run(lambda evt: f"echo: {evt['payload'].get('rawContent', evt['payload'].get('content', ''))}")
|
|
13
13
|
|
|
14
14
|
Usage (manual loop):
|
|
15
15
|
|