Просмотр исходного кода

Tell the model that Chatto can carry files

The agent was shelling out to a CLI to deliver an image, because nothing
ever told it the channel could do that itself. Hermes feeds plugin
platforms into the system prompt via platform_registry's platform_hint
(agent/system_prompt.py:693), and ours described markdown and mentions
but never media — while every built-in hint spells out MEDIA:/path and
![alt](url).

The delivery machinery was already in place and generic: extract_images
and extract_local_files sit on BaseAdapter, and run.py routes what they
find to send_image_file / send_video / send_document regardless of
platform. Only the invitation was missing.
Paul Klumpp 1 неделя назад
Родитель
Сommit
31fd1549ce
2 измененных файлов с 16 добавлено и 1 удалено
  1. 7 1
      adapter.py
  2. 9 0
      test_adapter.py

+ 7 - 1
adapter.py

@@ -2076,6 +2076,12 @@ def register(ctx) -> None:
             "You are chatting in Chatto (a self-hosted or cloud-hosted team or community chat server). "
             "You are chatting in Chatto (a self-hosted or cloud-hosted team or community chat server). "
             "Markdown is supported. Users _may_ address you by @-mentioning your name. If configured, " \
             "Markdown is supported. Users _may_ address you by @-mentioning your name. If configured, " \
             "you also react without a @-mention. Direct messages reach you without a mention."
             "you also react without a @-mention. Direct messages reach you without a mention."
-            "Keep responses conversational."
+            "Keep responses conversational. "
+            "You can send media files natively — never shell out to a CLI to deliver a file. "
+            "To send a local file, include MEDIA:/absolute/path/to/file in your response: images "
+            "(.png, .jpg, .gif, .webp) arrive as inline pictures, videos (.mp4, .mov, .webm) as "
+            "video attachments, audio as a voice bubble, anything else as a downloadable document. "
+            "Image URLs in markdown format ![alt](url) are downloaded and uploaded as attachments too. "
+            "Several images in one response are bundled into a single message."
         ),
         ),
     )
     )

+ 9 - 0
test_adapter.py

@@ -251,6 +251,15 @@ class TestRegistration:
         assert ctx.registered_kwargs["label"] == ChattoConstants.PLATFORM_LABEL
         assert ctx.registered_kwargs["label"] == ChattoConstants.PLATFORM_LABEL
         assert ctx.registered_kwargs["max_message_length"] == _MAX_MESSAGE_LENGTH
         assert ctx.registered_kwargs["max_message_length"] == _MAX_MESSAGE_LENGTH
 
 
+    def test_platform_hint_advertises_media_sending(self):
+        """This hint is the only thing telling the model the channel can carry
+        files — without it the agent shells out to a CLI to deliver an image."""
+        ctx = _MockPluginContext()
+        register(ctx)
+        hint = ctx.registered_kwargs["platform_hint"]
+        assert "MEDIA:/absolute/path/to/file" in hint
+        assert "![alt](url)" in hint
+
     def test_check_requirements(self):
     def test_check_requirements(self):
         assert check_requirements() is True
         assert check_requirements() is True