AI bot - Personas

:bookmark: This guide explains how to set up and manage Personas for Discourse AI - AI bot.

:person_raising_hand: Required user level: Administrator

The Discourse AI bot includes a flexible system for managing Personas. This guide covers:

  • Interaction methods for AI Personas
  • Configuration options
  • Advanced settings
  • Supported commands
  • Customization possibilities

:link: Learn about the AI bot and how to enable it in this guide.

What are personas?

Personas are a powerful feature that allows you to customize the behavior of the AI engine in your Discourse forum. They act as a ‘system message’ that guides the AI’s responses and interactions, helping to create a more personalized and engaging user experience.

Why use personas?

With personas, you can tailor the AI’s behavior to better fit the context and tone of your forum. Whether you want the AI to be more formal for a professional setting, more casual for a community forum, or even embody a specific character for a role-playing game, personas give you the flexibility to do so.

Group-specific access to personas

Moreover, you can set it up so that certain user groups have access to specific personas. This means you can have different AI behaviors for different sections of your forum, further enhancing the diversity and richness of your community’s interactions.

Interacting with Personas

Personas can be interacted with in multiple ways:

  1. Private message (PM)
  2. Chat direct message (DM)
  3. Chat channel mentions
  4. Mention in a public topic via @examle_bot_username

Administrators can control which interaction methods are allowed for each persona.

Configuration

To configure Personas, navigate to discourse.example.com/admin/plugins/discourse-ai/ai-personas.

Key configuration options include:

  • System prompt: Steers the conversation
  • Vision support: Enable for Vision powered LLMs, i.e- GPT-4 Turbo, Claude 3
  • Default model: Required for mentionable personas
  • Allowed groups: Define permissions using Discourse group security
  • Uploads: Index text files for additional knowledge (using RAG - Retrieval-Augmented Generation)
  • Enabled commands: Control access to specific commands
  • Allow chat: Enable chat via DM (requires chat plugin, a default large language model (LLM), and a user)

Here’s a look at a complete AI persona configuration screen:

Advanced configuration options

The persona editor offers several advanced options:

  • Temperature and top_p (nucleus sampling): Control creativity vs. predictability
  • Max context posts: Limit the number of posts supplied to the LLM for history - fewer posts will reduce costs, but cause the AI to “forget” about older content
  • Upload options:
    • Chunk tokens: Control document splitting
    • Chunk overlap tokens: Set overlap between chunks
    • Search conversation chunks: Number of document fragments added to user queries
    • Question consolidator LLM: Choose the LLM for determining user questions

Prerequisites for upload support

To use upload support:

  1. Enable the ai_embeddings_enabled setting
  2. Configure an ai_embeddings_model

Discourse AI supports various embedding models. Hosted customers get free access to the bge-large-en model.

:information_source: Self-hosters or people wanting more choice can self host an embedding model or use models by Open AI, Google (Gemini), and more.

Text splitting in Discourse AI

Discourse uses a Recursive Character Text Splitter to keep paragraphs, lines, and words together when splitting text. You can control text splitting using the [[metadata YOUR METADATA HERE]] separator:

[[metadata about cats]]
a long story about cats
[[metadata about dogs]]
a long story about dogs

This method prevents “chunk contamination” by ensuring only relevant data is included in each chunk.

Debugging AI personas

To debug your persona:

  1. Add users to the group specified in the ai bot debugging enabled groups setting
  2. Users in this group will see an AI debugging button at the bottom of AI posts
  3. Click the button to access the debugging UI modal

:warning: Remember: If you provide vague or unhelpful information to an LLM, it will have great difficulty converting it into useful information.

Supported commands

Discourse AI supports various commands, including:

  • Categories
  • Tags
  • Search
  • Web Browser
  • GitHub integration (Search Code, Pull Request Diff, File Content)
    • Requires the ai bot github access token setting to be filled
  • Search Meta Discourse
  • Random Picker
  • Read
  • Time
  • Google search
    • Requires the ai google custom search api key and ai google custom search cx settings to be filled
  • Image generation via DALL-E
    • Requires an open_ai key
  • Image generation via Stable Diffusion
    • Requires the ai stability api key setting to be filled
    • The ai stability engine setting controls the image generation algorithm
  • Schema
  • Search Settings
  • Setting Context

Some commands require additional configuration or API keys.

Custom tool support

You can create your own tools using custom tool support.

Customizing system personas

  1. Create a new persona
  2. Copy and paste the system prompt from the persona you wish to customize
  3. Modify as needed
  4. Optionally disable the original system persona to avoid duplication

Customizing search

To customize search for a new persona:

  1. Create a new persona
  2. Add the “search” command
  3. Configure search options, including:

This allows you to delegate search permissions, increase the number of results, or restrict search to specific sections of your site.

Last edited by @martin 2024-11-18T06:30:47Z

Check documentPerform check on document:
7 Likes

A post was split to a new topic: Can I provide an image generator function to Discourse AI

What exactly does the Read tool do?

Also, mentions on posts are currently broken per this bug report.

In a nutshell it allows the LLM the ability to read topics and posts on your forum.

1 Like

Basically it reads a topic/post when url, name or ID is given and otherwise, or still, it uses embeds and what, when, why and how depends model itself, prompting etc?

1 Like

Oh sorry was replying to a different post :slight_smile:

It uses topic ID or topic ID + Post Number to find the raw markdown for a topic/post with some guards for max length.

Does not depend on embedding.

4 Likes

A bit off-topic, but because I don’t have anything to ask and you guys will clean these topics every now and then, I don’t care.

Automatic titles in PMs with AI are now in the right language. Not a biggie, but its psychological value is big. Thanks!

4 Likes

is there any way to add the Bot users to a group? I basically want to add an avatar flair to those users, but when adding them to a group, they don’t show up

They don’t show up, but are still there. You can be sure by trying add an AI person second time. Or you see needed group on settings of those pseudo users.

1 Like

Which part of the Discourse AI repo should I check out if I want to precisely know how the AI bot’s tools work?

Tool, Playground, Bot are all good areas to start with.

See this for example: Understanding Tools in Discourse AI System - AI Conversation - Discourse Meta