forked from NuQloud/nc-talk-ai
55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\EducAI\Talk;
|
|
|
|
/**
|
|
* Abstraction for how Talk AI delivers messages back into a Talk
|
|
* conversation during one invocation.
|
|
*
|
|
* The processing pipeline (TalkHandler) always talks to a ResponseSink so
|
|
* that message parsing, bot resolution, onboarding, RAG and model execution
|
|
* are completely independent of the transport the invocation arrived on:
|
|
*
|
|
* - NativeEventResponseSink: Talk 21+ native in-process bot events
|
|
* (OCA\Talk\Events\BotInvokeEvent). No HTTP round-trip into the instance.
|
|
* - WebhookResponseSink: the legacy signed Talk bot HTTP API, used by the
|
|
* webhook transport and for out-of-context sends (rate-limit queue, test
|
|
* rooms) where no active event exists.
|
|
*/
|
|
interface ResponseSink {
|
|
/**
|
|
* Bind the room this sink delivers to.
|
|
*
|
|
* Called once per invocation after the room token has been parsed from
|
|
* the invocation payload.
|
|
*/
|
|
public function bindRoom(string $roomToken): void;
|
|
|
|
/**
|
|
* Send a message into the bound room.
|
|
*
|
|
* @param string $message The message to deliver (markdown)
|
|
* @param int|bool $replyTo Message id to reply to, or false for no reply
|
|
* @param bool $silent Deliver without notification (where supported)
|
|
* @return bool True if the transport accepted the message
|
|
*/
|
|
public function send(string $message, int|bool $replyTo = false, bool $silent = false): bool;
|
|
|
|
/**
|
|
* React to the invoking message with an emoji (no-op where unsupported).
|
|
*/
|
|
public function react(string $emoji): void;
|
|
|
|
/**
|
|
* Whether this transport can deliver incremental streaming content as it
|
|
* arrives.
|
|
*
|
|
* Webhook/HTTP transports deliver each call immediately, while native
|
|
* events are posted by Talk only after the invocation completes - so the
|
|
* pipeline coalesces to final responses for those.
|
|
*/
|
|
public function supportsStreaming(): bool;
|
|
}
|