Discourse 聊天机器人 🤖

:information_source: 摘要 Discourse 的原创 AI 聊天机器人
:hammer_and_wrench: 仓库链接 GitHub - merefield/discourse-chatbot: An AI bot with RAG capability for Topics, Chat & Customer Support in Discourse, currently powered by OpenAI · GitHub
:open_book: 安装指南 如何在 Discourse 中安装插件
:heart: 赞助支持 请考虑成为我开源工作的长期赞助商,选择适合您或您所在组织资源和需求的赞助级别,以确保该插件获得应有的维护,并继续为您的站点提供服务。

喜欢这个插件吗?请在 GitHub 上给它一个 :star: 吧!:pray:

:information_source: 由于这是一个独立贡献的插件,请在此主题中提出支持、错误、用户体验和功能请求。注意:该插件提供在 Discourse.org 的托管服务上。如果您是自建托管,则可以安装它;如果您使用第三方托管,也可能可以安装(但请先咨询您的提供商)。

Discourse 的原创 AI 聊天机器人

Chatbot 将可配置的 AI 对话引入到主题(Topics)、私信(Personal Messages)、聊天频道(Chat channels)和聊天线程(Chat threads)中。您可以为机器人设定一个适合您社区的角色,决定哪些用户组可以使用它,并为低信任度、中信任度和高信任度用户选择不同的模型和工具。

它可以:

  • 根据当前对话正常回答;
  • 使用语义搜索或混合搜索检索选定的论坛内容;
  • 搜索维基百科、最新新闻和网络;
  • 抓取远程页面并获取当日收盘市场数据;
  • 执行可靠的基于表达式的计算;
  • 查看上传的图片并可选地读取 PDF;
  • 生成和编辑图片;
  • 在私密对话中收集未填写的可编辑用户字段(User Fields);
  • 将私密聊天对话升级给配置好的员工组;
  • 自动回复选定分类(Categories)中的新主题;以及
  • 接受由其他插件提供的额外工具。

有关实际的支持工作流程,请参阅构建技术支持聊天机器人

启用本地论坛搜索后,机器人可以基于您社区的内容来回答:

对于更简单的对话,可以暴露更少或没有工具,以减少调用、延迟和成本:

提供商支持

您可以独立为回复、嵌入(embeddings)、视觉(vision)和图片生成选择提供商。每种功能都重用所选提供商的 API 密钥。

功能 OpenAI Anthropic Google Gemini xAI
LLM 回复和工具 :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
嵌入 :white_check_mark: :white_check_mark: :white_check_mark:
视觉 :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
图片生成 :white_check_mark: :white_check_mark: :white_check_mark:
图片编辑 GPT Image 模型 :white_check_mark:
PDF 对话输入 :white_check_mark:

如果未设置自定义 URL,Chatbot 将使用所选提供商的内置官方端点。自定义模型名称和 URL 支持 Azure OpenAI、Ollama、代理以及实现受支持提供商 API 格式的其他服务。

仅当该提供商处于激活状态时,才会显示特定的提供商模型下拉菜单。回复模型可以根据信任级别有所不同,而嵌入、视觉和图片生成各自拥有独立的提供商和模型选择器。

阅读完整的提供商和自定义端点指南

访问权限、配额和工具

在您将用户组分配给 Chatbot 的低、中或高信任级别设置之前,没有人拥有访问权限。用户将继承其最高匹配 Chatbot 信任级别的配额、模型和工具允许列表。配额可以按查询次数或令牌(tokens)来衡量。

内置工具针对每个信任级别独立选择。凭据和支持性设置仍然控制运行时可用性,因此,如果选择了网络工具但未提供其 API 密钥,该工具将不会暴露出来。

阅读关于访问权限和配额以及信任级别工具的文档。

本地论坛搜索和隐私

:biohazard: 请在启用本地论坛搜索之前了解嵌入的范围。

默认的 benchmark_user 策略会嵌入在配置的信任级别下对合适用户可见的内容。categories 策略会嵌入从明确选择的分类中获取的内容。语义搜索针对速度进行了优化,不会为每个向机器人提问的人重复执行可见性检查,因此,如果范围包含受限内容,匹配的内容可能会在其原始受众之外被共享。

私信永远不会被嵌入。请保持基准信任级别较低,除非其内容可以披露给每个 Chatbot 用户,否则避免使用私密分类,并从不应使用它的信任级别中移除 local_forum_search

所选提供商可能会接收对话内容、上传文件、嵌入的搜索匹配结果和工具结果。请审查其数据保留和使用条款,并在您的论坛条款和隐私声明中披露此处理过程。

阅读完整的嵌入、范围和隐私指南

快速开始

  1. 使用标准的自建插件程序安装该插件。
  2. 选择 chatbot_llm_provider,输入该提供商的 API 密钥,并为每个信任级别选择模型。
  3. 将用户组添加到低、中或高信任访问设置中,并配置配额。
  4. 选择每个信任级别可用的内置工具。
  5. 如果您启用了 local_forum_search,请配置其嵌入提供商并仔细审查其范围。
  6. 提及机器人、回复它、使用快速访问按钮,或配置分类自动回复提示词。

快速 OpenAI 示例

  1. 创建一个 OpenAI API 密钥 并确保已启用 API 计费。
  2. chatbot_llm_provider 设置为 OpenAI,并将密钥粘贴到 chatbot_open_ai_token 中。
  3. 保持自定义 URL 为空,为您打算使用的每个信任级别选择一个 OpenAI 模型,并将您的测试组添加到匹配的 Chatbot 访问设置中。
  4. 在允许的主题、私信或聊天中提及机器人以进行测试。

仓库的 README 是前提条件、所有主要设置组、特定提供商行为、自定义端点、嵌入维护、提示词自定义、调试、扩展开发和卸载的权威来源:

:books: 打开完整的 README

精选 UI 功能

分类可以欢迎新主题并询问机器人搜索相关的社区内容:

可选的快速访问按钮可以打开与机器人的直接聊天或私信:

用户字段工具可以私密地收集受支持的空白字段:

用户字段收集

支持和赞助

请在此 Meta 主题中报告支持请求、错误、用户体验反馈和功能创意。请包含提供商、模型名称、相关设置、HTTP 状态和提供商响应体,同时移除 API 密钥和私密内容。

这项工作依赖于社区的支持。如果该插件对您的站点有价值,请赞助其持续维护

项目赞助商

赞助商 级别 网站
Surety Silver Plus suretyhome.com

免责声明

LLM 可能会产生看似正确但实际错误的输出。请针对您社区的需求测试该插件,了解隐私和成本影响,并应用适当的审核措施。生成输出的条款因提供商和司法管辖区而异;请审查您启用的每个提供商的条款。

104 个赞
Building a technical support chatbot
Answer feature
Webhooks on chat messages?
How to check what prevents rake migrate?
Weekly Summary of AI topics
Advice on a support bot for a technical support forum (Discourse AI vs Discourse Chatbot)
Interact with discourse from Python?
Sidekiq not working
Locations Plugin :earth_africa:
Lessons from Colossal Caves
Issue after Rebuilding Discourse on Digital Ocean Droplet
Locations Plugin :earth_africa:
I have error when upgrade new version of discourse
I have error when upgrade new version of discourse
Site down after upgrade via SSH - how to fix?
2023: The Year in Review
Character count when writing description
Advice on a support bot for a technical support forum (Discourse AI vs Discourse Chatbot)
Is there an option to use Discourse Chat as a customer service type of chat?
Configure AI Chatbot for Trust Level 0 Access
Creating bot on discourse
AI Helper Plugin
Copy custom file in discourse container while build
Voice to text integration
Allow specifiy user different from guardian.user in chat services such as Chat::CreateMessage
How to add a ChatGPT trained AI to discourse?
Cannot get the js in my component to compile SyntaxError: Private field must be used in an enclosing class
Allow ChatBot to read PDFs so it can join in a group discussion
How to create a custom ChatGPT based bot?
Discourse and Coveo
Link for new DM / personal chat message with pre-filled information
UX IPhone issues
How to respond to automatic topics with AI
Comparison between discourse-ai AI Bot and merefield/discourse-chatbot
Allow multiple ‘new topic’ drafts
I have error when upgrade the latest discourse
Two different answers from gpt4o - one right, one wrong.. !?
Is the shortcut to start AI conversation a user setting or not?
Setting Form Templates with a tag
Recommendation: chatbot to support discussion in threads
Photography Mentor Bot
Grouped Site Settings under Headings in Plugins
Update Not Completed and Discourse not opening
Recommendation: chatbot to support discussion in threads
Discourse AI Topic Summary :robot:
Discourse AI Topic Summary :robot:
Hubot Adapter for Discourse
Hubot Adapter for Discourse
Verbose log
Making the case for a hard cap feature on user group AI usage for AI bots and AI Helper
LLMs and the impact on customer support
2024: The Year in Review
How to respond to automatic topics with AI
What User Information is Exposed to LLMs in Discourse AI
Advice on a support bot for a technical support forum (Discourse AI vs Discourse Chatbot)
Configure AI Chatbot for Trust Level 0 Access
Auto responder using AI
Locations Plugin :earth_africa:
Discourse AI Topic Summary :robot:
Discourse Chat Bridge (Telegram)
AI personas integration of the chat plugin: It would be great if site users could chat with AI personas
What's the best way to store data with a plugin?
Locations Plugin :earth_africa:
Locations Plugin :earth_africa:
Is there any built-in chatbot or conversational assistant available in Discourse?
ChatGPT Assistant Integration
Create posts with AI
Multisite vs multiple containers
Training a model on a site's posts?
How are we all feeling about ChatGPT and other LLMs and how they'll impact forums?
GPT-4 with vision available
Use AI to request summary and others things from topic
Upgrading from /admin/upgrade takes *very* long
Embed additional explainer text in Form Template
We need prompt chains: Allow custom AI persona tools to access LangChain.js and/or longer execution time
Advice on a support bot for a technical support forum (Discourse AI vs Discourse Chatbot)
Advice on a support bot for a technical support forum (Discourse AI vs Discourse Chatbot)
Advice on a support bot for a technical support forum (Discourse AI vs Discourse Chatbot)
Configure AI Chatbot for Trust Level 0 Access
Enabling AI Bot in Chat
When I start a conversation with the AI, it gives two answers to my question
Balancing Costs and Functionality in AI-Powered Forums
Advice on a support bot for a technical support forum (Discourse AI vs Discourse Chatbot)

我已将 Jina.ai 添加到支持的 API 列表中,可用于网络搜索和网络爬行。一个密钥同时服务于这两项功能。如果您不删除现有 API 的密钥,它们将被使用。

主要有两个原因:

  • 爬行性能似乎非常好
  • 他们提供按使用量付费的模式,而不是按月收费,这适合我,也可能适合您。

设置中的链接。

感谢您对 Discourse Chatbot 的关注。

以下两点可能与您相关:

  • 如果在一个只有一名用户的帖子里调用该机器人,它将回复该帖子的每一楼层,直到有更多人加入该帖子。
  • 您可以设置让聊天机器人回复每个新帖子,并可以为其提供特殊指令,这些指令由您在分类设置中配置的特定于分类的提示来管理。

如果您 @ 提及该机器人,它将始终被调用,所以我不知道您是否也可以利用该功能。

1 个赞

“每一”条帖子?还是仅那些包含关键词的帖子?这是两个不同的要求吗?

也许你可以在预定义回复中提到 Chatbot,然后由机器人跟进?这意味着需要两条帖子,但或许可行。

所以,如果你的预定义回复是“@Chatbot(或你重命名的任何名称)请处理此事”,那么 Chatbot 就会跟进。显然,你可以定制该回复。

请注意,Chatbot 也可以回复私信(如果你这样配置),因此如果预定义回复是在私信中,普通用户只会看到 Chatbot 的回复,这样看起来可能更整洁。

如果你希望雇佣我来扩展 Chatbot 的功能,我是持开放态度的,前提是我们能想出一个足够通用的解决方案,对其他人也有用。但我觉得利用现有功能更有意义?

我在想,这里最好的做法是否为 AI 帖子分类器添加私信功能?你可以雇佣某人提交相关 PR,或者将其作为 Contribute > Feature 提出,希望它能被优先处理。这无疑会具有广泛的实用性?

我通过利用添加到 OpenAI API 的一项功能进行了一些代码简化。如果遇到任何问题,请告知我。

我决定是时候称之为 1.0.0 了 :champagne: :tada: :partying_face:

4 个赞

添加了在单独的插件中添加其他函数的功能,因此您不必维护 Chatbot 仓库的 fork。

示例函数插件在此处:

当然,您可以将其添加到任何插件中……

PR:

4 个赞

@Festinger 你解决这个问题了吗?

帖子嵌入:出现了一个问题,但会重试直到达到限制:nil 的未定义方法 `destroy!’

上次更新后,我开始收到上述错误。我尤其在处理图片时会收到此错误。我的视觉模式设置为:直接。以前我没有收到过此类错误。

您是否记得在创建帖子(或主题)后不久将其删除?

如果您在创建帖子后,在它有机会创建嵌入之前就将其删除,就会出现此错误。因此,当您删除它时,Chatbot 会尝试删除一个不存在的嵌入,这会产生一条烦人的日志消息,但不会造成损害 :wink:

如果您能想到更好的方法,欢迎提交 PR。

1 个赞

它像这样在用户发送的问题中给出了一个错误。这不是我删除的东西。

用户是如何看到这个的?这只会在日志中显示吗?

我在日志中看到了。我跟踪了一天,特别是这个问题发生在长期会员的用户帖子中。如果新会员用图片开一个帖子,通常没有问题,也不会收到错误。当老用户用图片开一个帖子时,就会出现问题。

请分享一下堆栈跟踪信息?

那用户为什么还给你发问题?他们跟你说了什么?用户不应该知道有任何问题,问题只应该出现在日志里?

听起来像是你的“老会员”可能会删除他们最近发布的新主题或帖子(因为他们知道怎么做)?

你是否部署了任何类型的自动化?

发布包含图片的帖子时不会发生破坏,所以我不太清楚这怎么会发生。

更新:我刚刚将一张图片上传到一个网站,无法重现。

1 个赞

SerpAPI 没问题,它们的统计数据显示已发出 Google 请求,但 Chatbot 声称无法使用 Google。这种情况已经持续了一段时间,但我没有做出反应,因为当时 DAI 也不想使用 Google。

没有错误消息。

1 个赞

如果您说“在网上搜索…”会发生什么?

内部提示是通用的,因此不假定使用 Google…

让我向您展示这项强大功能的绝佳演示:

(尽管这使用了捆绑的替代方案 jina.ai

我试过了。系统提示中有“当用户要求使用谷歌进行搜索时,用户实际上是指您应该使用您能够访问的网络搜索功能”。我删除了那部分,然后在我的用户提示中尝试了网络搜索措辞——毕竟,它并没有使用谷歌的 API。但没有成功,答案也差不多:我无法进行网络搜索……

这是我找到的唯一信息,但它没有打开这个:

{
  "id": "chatcmpl-A1wT9Dp1fCIVSzRsVPhr3NnNCcPjW",
  "object": "chat.completion",
  "created": 1725026447,
  "model": "gpt-4o-2024-05-13",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_MvzexRPsDj6EGuXhuiFcmtrd",
            "type": "function",
            "function": {
              "name": "web_search",
              "arguments": "{\"query\":\"International Dog Day date, reason, and history\"}"
            }
          }
        ],
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1203,
    "completion_tokens": 20,
    "total_tokens": 1223
  },
  "system_fingerprint": "fp_157b3831f5"
}
2 个赞

我可以不使用它,因为我的目标是使用聊天机器人作为内部问答机器人,而 Jina 可能会解决我使用(通过 WordPress)主内容网站的问题。

但当我从外部世界搜索时,结果并不理想。

1 个赞

我看看是否能重现

1 个赞

它通过 Serp API 或 Jina.ai 都能为我工作。

您能否提供 PM 的机器人“内心想法”?

内心想法
[
  {
    "role": "assistant",
    "content": "",
    "tool_calls": [
      {
        "id": "call_mKY7pfG54xRduRKCz5xee9E0",
        "type": "function",
        "function": {
          "name": "web_search",
          "arguments": "{\"query\":\"list of English butterflies\"}"
        }
      }
    ]
  },
  {
    "role": "tool",
    "tool_call_id": "call_mKY7pfG54xRduRKCz5xee9E0",
    "content": "A-Z of butterflies · A. Adonis Blue · B Black Hairstreak · Brimstone · Brown Argus · Brown Hairstreak · C Chalk Hill Blue · Chequered Skipper · Clouded Yellow · D."
  }
]
1 个赞

我们应该用PM来做这件事吗?我们现在只是在污染这个话题。

但是:

[
  {
    "role": "assistant",
    "content": "",
    "tool_calls": [
      {
        "id": "call_4xitHqRBJ8Wc1HI546r3Wj1U",
        "type": "function",
        "function": {
          "name": "web_search",
          "arguments": "{\"query\":\"International Dog Day date and history\"}"
        }
      }
    ]
  },
  {
    "role": "tool",
    "tool_call_id": "call_4xitHqRBJ8Wc1HI546r3Wj1U",
    "content": "国际狗日日期和历史:我在网上搜索此信息失败。"
  }
]