# Discourse AI：需移除 JSON 响应才能使 Anthropic Sonnet 5 在语义搜索等场景中正常工作

**URL:** <https://meta.discourse.org/t/discourse-ai-need-to-remove-json-response-to-get-antrophic-sonnet-5-working-in-e-g-semantic-search/407117>\
**Category:** Support\
**Tags:** ai\
**Created:** [2026年七月8日 23:20 UTC](https://meta.discourse.org/t/discourse-ai-need-to-remove-json-response-to-get-antrophic-sonnet-5-working-in-e-g-semantic-search/407117 "2026-07-08T23:20:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![janbolmeson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janbolmeson/32/192162_2.png) [@janbolmeson](https://meta.discourse.org/u/janbolmeson)\
**Post date:** [2026年七月8日 23:20 UTC](https://meta.discourse.org/t/discourse-ai-need-to-remove-json-response-to-get-antrophic-sonnet-5-working-in-e-g-semantic-search/407117/1 "2026-07-08T23:20:26Z")

</div>

我可能完全搞错了，而且这对除了我以外的所有人来说都是常识……如果是这样，我很抱歉。但我在安装过程中遇到了一些奇怪的错误，例如：

```plaintext
DiscourseAi::Completions::Endpoints::Anthropic: status: 400 - body: 

```

```json
{
“type”:“error”,
“error”:{“type”:“invalid_request_error”,
“message”:“此模型不支持助手消息预填充。对话必须以用户消息结尾。”},“request_id”:“req_011CcqMN6eswEfRHPmQmPLC4”
}

```

这很奇怪，因为其他大多数与 AI 相关的功能都正常工作。这主要发生在我使用的摘要工具和搜索功能中，例如：

`https://..../forum/discourse-ai/embeddings/semantic-search?q=search_term`

这会返回 500 错误。

当我检查日志时，得到了以下信息：

```json
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "此模型不支持助手消息预填充。对话必须以用户消息结尾。"
  },
  "request_id": "req_011CcqQvXPAHSfvoUeu92gf9"
}

```

我追溯到了“内容创建”角色（Persona）。

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/d/f/7df87dfed3b14030b682ea7a207efcdab0403055.png)

错误似乎出在这一部分：

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/7/3/973977b1c6266c640e224a80662a93817e128896.png)

因为当我通过克隆该角色并将此设置应用于克隆体来移除它时（在此特定角色上无法直接移除）

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/8/6/58676642a3f93ae3dbfab40b245eba4245280c99.png)

语义搜索开始正常工作。我需要在例如我的摘要工具中执行类似的操作。

你们是否也遇到过这种情况？

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [2026年七月8日 23:36 UTC](https://meta.discourse.org/t/discourse-ai-need-to-remove-json-response-to-get-antrophic-sonnet-5-working-in-e-g-semantic-search/407117/2 "2026-07-08T23:36:49Z")

</div>

你能展示一下在你的实例上 Sonnet 5 是如何配置的吗？

你碰巧启用了 `禁用原生结构化输出（改为使用助手消息预填充，Claude 3.x 及更早版本必需）` 吗？

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2026年七月9日 13:28 UTC](https://meta.discourse.org/t/discourse-ai-need-to-remove-json-response-to-get-antrophic-sonnet-5-working-in-e-g-semantic-search/407117/3 "2026-07-09T13:28:59Z")

</div>

> [@Falco](#):
>
> 你能展示一下你的实例上 Sonnet 5 是如何配置的吗？
> 
> 你碰巧启用了 `禁用原生结构化输出（改为使用助手消息预填充，Claude 3.x 及更早版本必需）` 这个选项吗？

该论坛运行的是 2026.1.5 ESR 版本，而这个选项是在 2026.1 之后添加的，所以我想那里可能缺少许多针对 Claude 的特定逻辑。

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [2026年七月9日 15:35 UTC](https://meta.discourse.org/t/discourse-ai-need-to-remove-json-response-to-get-antrophic-sonnet-5-working-in-e-g-semantic-search/407117/4 "2026-07-09T15:35:06Z")

</div>

哦，谢谢分享！

试图在旧版 Discourse 上使用新模型并不是一个明智的策略 😃。

供应商们不断更改 API 格式、参数等。我们尽力保持与数千种模型的兼容性，但这需要持续的更新才能跟上步伐，尤其是当你想跟上那些比 Discourse 版本早半年发布（在 AI 领域这可是几个世纪）的模型时。

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2026年八月8日 15:35 UTC](https://meta.discourse.org/t/discourse-ai-need-to-remove-json-response-to-get-antrophic-sonnet-5-working-in-e-g-semantic-search/407117/5 "2026-08-08T15:35:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
