FEATURE: support Chat with AI Persona via a DM (#488)

Add support for chat with AI personas

- Allow enabling chat for AI personas that have an associated user
- Add new setting `allow_chat` to AI persona to enable/disable chat
- When a message is created in a DM channel with an allowed AI persona user, schedule a reply job
- AI replies to chat messages using the persona's `max_context_posts` setting to determine context
- Store tool calls and custom prompts used to generate a chat reply on the `ChatMessageCustomPrompt` table
- Add tests for AI chat replies with tools and context

At the moment unlike posts we do not carry tool calls in the context.

No @mention support yet for ai personas in channels, this is future work
This commit is contained in:
Sam
2024-05-06 09:49:02 +10:00
committed by GitHub
parent 8875830f6a
commit e4b326c711
21 changed files with 575 additions and 86 deletions
@@ -53,6 +53,7 @@ module("Discourse AI | Unit | Model | ai-persona", function () {
rag_chunk_overlap_tokens: 10,
rag_conversation_chunks: 10,
question_consolidator_llm: "Question Consolidator LLM",
allow_chat: false,
};
const aiPersona = AiPersona.create({ ...properties });
@@ -92,6 +93,7 @@ module("Discourse AI | Unit | Model | ai-persona", function () {
rag_chunk_overlap_tokens: 10,
rag_conversation_chunks: 10,
question_consolidator_llm: "Question Consolidator LLM",
allow_chat: false,
};
const aiPersona = AiPersona.create({ ...properties });