@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
32 lines • 1.83 kB
TypeScript
import type { UIMessage } from 'ai';
import type { MessageFeedback, MessageFeedbackValue } from '../../../index.js';
import { type AgentBackend } from '../backend.js';
export interface UseMessageFeedbackOptions {
/** Default: the enclosing `<AgentProvider>`'s. Must implement `setMessageFeedback`. */
backend?: AgentBackend;
/**
* The thread the messages belong to — `useAgentChat(...).getThreadId`, or an id. Needed to rate a
* message streamed in this session: its id is the client's own, so the persisted row it became is
* looked up by the run that wrote it.
*/
threadId?: string | (() => string | undefined);
}
export interface MessageFeedbackState {
/** The rating to show: the one set in this session, else the persisted one, else `null`. */
feedbackOf: (message: UIMessage) => MessageFeedback | null;
/** A rating for this message is on its way to the server. */
isPending: (message: UIMessage) => boolean;
/** Set `'up'`/`'down'` (optionally with a comment), or clear with `null`. Optimistic. */
rate: (message: UIMessage, value: MessageFeedbackValue | null, comment?: string) => Promise<void>;
/** Thumbs-button semantics: the same value again clears it, another value replaces it. */
toggle: (message: UIMessage, value: MessageFeedbackValue) => Promise<void>;
/** The last failure; cleared by the next successful rating. */
error: Error | null;
}
/**
* Thumbs-up/down (+ comment) on assistant messages, over `POST <base>/messages/:id/feedback`.
* Headless: it holds the state and the calls, the host draws the buttons. A rating shows at once
* and rolls back if the server refuses it.
*/
export declare function useMessageFeedback(options?: UseMessageFeedbackOptions): MessageFeedbackState;
//# sourceMappingURL=use-message-feedback.d.ts.map