Discourse AI Persona Guide

Discourse AI Bot ships with a flexible system for managing Bot Personas.

AI Personas can be interacted with in multiple ways:

  • Via a Discourse Message.
  • Via a Chat DM
  • Via a mention in a public topic

As an adminstrator you can control which modalities are allowed.

The UI to control it is at: /admin/plugins/discourse-ai/ai-personas

AI Personas allow you to define many aspects of the AI Bot behavior including:

  • System Prompt - the prompt used to steer the conversation
  • Vision support - GPT-4 Turbo and Anthropic Claude 3 models support vision, you can enable vision support for a particular persona.
  • Default model - If you wish to make your persona mentionable (either accept PMs to user or be mentionable from public topics), it will need a model specified and you will need to create a user for it using the UI.
  • Allowed Groups - Each persona can be customized so only part of your community have access, you can use Discourse group security to define permissions.
  • Uploads - Personas can index text file and use it as extra knowledge to answer user questions. Discourse implements an RAG (Retrieval-Augmented Generation). Uploads are chunked and then sections included in your persona depending on the query the user makes.
  • Enabled Commands - Commands let you interact with external systems and perform actions such as image generation, search, web browsing and more. Each persona can have access to specific commands.
  • Allow Chat - enable chat with the persona via a DM (requires chat, a default LLM and a user)

Advanced Configuration Options

The Persona editor has many advanced options to better control your persona:

  • You can control temperature and top_p (nucleus sampling) to produces either more creative results or more predictable results. By default Discourse AI does not specify these params.

  • You can control the Max Context Posts - which is the amount of posts supplied to the LLM for history. To save costs you can reduce this number (bot will appear forgetful about posts not in the context)

  • You can control Upload options:

    • Chunk Tokens - to control how document is split up
    • Chunk overlap tokens - to control how much overlap there is between chunks
    • Search conversation chunks - which is the number of document fragments which will be added to the users query
    • Question consolidator LLM - to control which LLM will “figure out” what question the user was asking so we can perform a vector similarity. Often you can use cheaper models for this.

Pre-requisites for upload support

For the option to operate you will need to have ai_embeddings_enabled and an ai_embeddings_model configured.

Discourse AI supports a very large amount of embedding models.

Our hosted customers get free access to state of the art bge-large-en model.

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

How does Discourse AI split up bodies of text?

Discourse uses a Recursive Character Text Splitter, this attempts to keep paragraphs, then lines and finally words together when splitting.

Additionally, Discourse gives you extra control over how your text will be split up.

The [[metadata YOUR METADATA HERE]] separator can be used to split up large bodies of text and properly highlight what each section covers.

For example:

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

This allows a single text document to cover a large variety of content and protects you from “chunk contamination”. You are guaranteed that only data about cats will be included in cats chunks and dogs in dog chunks.

How do I debug my persona?

Discourse AI ships with the site setting ai bot debugging enabled groups, users in this group have access to AI debugging:

AI debugging button at the bottom of AI posts by the AI bot

The AI debugging screens can help you get a window into the information we send the AI.

:warning: Garbage in - Garbage out If you provide useless or vague information to an LLM it can not convert it magically to useful information

This screen can help you better decide how big your chunks should be or if you are including too many or too few chunks.

What commands does Discourse AI support?

Personas support:

  • Categories: can look up the category list on your forum (non secured categories)
  • Tags: can look up tags in your forum
  • Search: is able to search your forum using keywords, optionally you can specify both a “filter” and “maximum results” to hone the command. Meaning you can define a search command that will search documentation only.
  • Web Browser: is able to extract content from arbitrary web pages
  • GitHub Search Code: (requires ai bot github access token ) allows you to search through a GitHub code repository
  • GitHub Pull Request Diff: consume content of a pull request on GitHub
  • GitHub File Content: view content on a file on GitHub
  • Search Meta Discourse: Perform a search on https://meta.discourse.org (for documentation / help)
  • Random Picker: select a random number or pick a random element in a list
  • Read: read content of a public post or topic
  • Time: figure out current time in any timezone
  • Google: to search google - requires ai google custom search api key and ai google custom search cx settings
  • DallE: generate images via Dall E 3 - requires open_ai key
  • Image: generate images via Stable Diffusion (supports sd3 and sdxl) - requires ai stability api key (ai stability engine controls the image generation algorithm)
  • Schema: read schema on current database for a particular set of tables
  • Search Settings: search site settings on current instance (public information only, no actual setting values are provided)
  • Setting Context: provide rich source level context for a specific site setting

Customizing existing personas

When you visit the persona UI you will notice that system personas have limited options when it comes to editing them.

You can not amend the system prompt, change the name or description or customize commands.

That said, your forum may benefit heavily from a customized persona.

To do so you can simply create a new persona and copy and paste the system prompt from the persona you wish to customize. You can also disable any of the system supplied personas to avoid duplication.

Customizing search

The Forum Helper persona uses the Search command. That said given the persona is controlled by the system you can not edit the options on search.

If you create a new persona and add the “search” command you will see all the following options:

This will allow you to delegate permission to perform searches on behalf of the user, increase the amount of results search can find or restrict search to a sub section of your site (such as documentation)

4 Likes

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