Files
outline/server/chat/ChatAnswerProvider.ts
Tom Moor 6659590438 Merge remote-tracking branch 'origin/main' into tommoor/chat-provider-interface
# Conflicts:
#	plugins/slack/server/api/hooks.ts
#	plugins/slack/server/auth/slack.ts
#	plugins/slack/server/processors/SlackProcessor.ts
#	server/context.ts
#	server/routes/api/index.ts
#	shared/i18n/locales/en_US/translation.json
2026-11-25 21:27:38 -05:00

36 lines
1.2 KiB
TypeScript

import type { Document } from "@server/models";
import type { Context } from "@server/types";
import type { ChatMarkdown } from "./types";
/** An answer to a question, with the documents that it came from. */
export interface ChatAnswer {
/** The answer, or an empty string if no answer was found. */
answer: ChatMarkdown;
/** The documents that the answer came from. */
documents: Document[];
}
/**
* Answers questions asked from a chat platform. Register an implementation
* with `Hook.ChatAnswerProvider` to answer questions in place of a search.
*/
export interface ChatAnswerProvider {
/**
* Returns true if the text is a question that the provider can answer.
*
* @param ctx the context of the user that asked, for one team.
* @param text the text that the user typed.
* @returns true if the provider can answer.
*/
canAnswer(ctx: Context, text: string): boolean;
/**
* Answers a question with the permissions of the user in the context.
*
* @param ctx the context of the user that asked, for one team.
* @param question the question.
* @returns the answer and its source documents.
*/
answer(ctx: Context, question: string): Promise<ChatAnswer>;
}