# 论坛意外崩溃？

**URL:** <https://forum.rdfzer.com/t/topic/4899>\
**Category:** 卮言\
**Created:** [2025 年2 月 14 日 12:23 UTC](https://forum.rdfzer.com/t/topic/4899 "2025-02-14T12:23:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

作者： ![RuletheWaves](https://forum.rdfzer.com/user_avatar/forum.rdfzer.com/rulethewaves/32/29332_2.png) [@RuletheWaves](https://forum.rdfzer.com/u/RuletheWaves)\
发布日期： [2025 年2 月 14 日 12:23 UTC](https://forum.rdfzer.com/t/topic/4899/1 "2025-02-14T12:23:25Z")

</div>

![Screenshot_20250214_201642](https://files.rdfzer.com/original/2X/5/5e634cc09706b49b6a072d55e244f108cec6d967.jpeg)  
开始时间不晚于(20250214)20:04(utc+8)，恢复时间不晚于20:19  
所以发生了什么 🧐

> Last edited by @RuletheWaves 2025-02-14T12:23:25Z

---

<div class="post-metadata">

作者： ![suen](https://forum.rdfzer.com/user_avatar/forum.rdfzer.com/suen/32/2665_2.png) [@suen](https://forum.rdfzer.com/u/suen)\
发布日期： [2025 年2 月 14 日 12:28 UTC](https://forum.rdfzer.com/t/topic/4899/2 "2025-02-14T12:28:57Z")

</div>

為了一個新功能

> <https://github.com/discourse/discourse-ai/commit/5e80f93e4c0767199e4d5fb0caff8b07ee1498db>
>
> This PR introduces several enhancements and refactorings to the AI Persona and R…AG (Retrieval-Augmented Generation) functionalities within the discourse-ai plugin. Here's a breakdown of the changes:
> 
> \*\*1. LLM Model Association for RAG and Personas:\*\*
> 
> \- \*\*New Database Columns:\*\* Adds \`rag\_llm\_model\_id\` to both \`ai\_personas\` and \`ai\_tools\` tables. This allows specifying a dedicated LLM for RAG indexing, separate from the persona's primary LLM. Adds \`default\_llm\_id\` and \`question\_consolidator\_llm\_id\` to \`ai\_personas\`.
> \- \*\*Migration:\*\* Includes a migration (\`20250210032345\_migrate\_persona\_to\_llm\_model\_id.rb\`) to populate the new \`default\_llm\_id\` and \`question\_consolidator\_llm\_id\` columns in \`ai\_personas\` based on the existing \`default\_llm\` and \`question\_consolidator\_llm\` string columns, and a post migration to remove the latter.
> \- \*\*Model Changes:\*\* The \`AiPersona\` and \`AiTool\` models now \`belong\_to\` an \`LlmModel\` via \`rag\_llm\_model\_id\`. The \`LlmModel.proxy\` method now accepts an \`LlmModel\` instance instead of just an identifier. \`AiPersona\` now has \`default\_llm\_id\` and \`question\_consolidator\_llm\_id\` attributes.
> \- \*\*UI Updates:\*\* The AI Persona and AI Tool editors in the admin panel now allow selecting an LLM for RAG indexing (if PDF/image support is enabled). The RAG options component displays an LLM selector.
> \- \*\*Serialization:\*\* The serializers (\`AiCustomToolSerializer\`, \`AiCustomToolListSerializer\`, \`LocalizedAiPersonaSerializer\`) have been updated to include the new \`rag\_llm\_model\_id\`, \`default\_llm\_id\` and \`question\_consolidator\_llm\_id\` attributes.
> 
> \*\*2. PDF and Image Support for RAG:\*\*
> 
> \- \*\*Site Setting:\*\* Introduces a new hidden site setting, \`ai\_rag\_pdf\_images\_enabled\`, to control whether PDF and image files can be indexed for RAG. This defaults to \`false\`.
> \- \*\*File Upload Validation:\*\* The \`RagDocumentFragmentsController\` now checks the \`ai\_rag\_pdf\_images\_enabled\` setting and allows PDF, PNG, JPG, and JPEG files if enabled. Error handling is included for cases where PDF/image indexing is attempted with the setting disabled.
> \- \*\*PDF Processing:\*\* Adds a new utility class, \`DiscourseAi::Utils::PdfToImages\`, which uses ImageMagick (\`magick\`) to convert PDF pages into individual PNG images. A maximum PDF size and conversion timeout are enforced.
> \- \*\*Image Processing:\*\* A new utility class, \`DiscourseAi::Utils::ImageToText\`, is included to handle OCR for the images and PDFs.
> \- \*\*RAG Digestion Job:\*\* The \`DigestRagUpload\` job now handles PDF and image uploads. It uses \`PdfToImages\` and \`ImageToText\` to extract text and create document fragments.
> \- \*\*UI Updates:\*\* The RAG uploader component now accepts PDF and image file types if \`ai\_rag\_pdf\_images\_enabled\` is true. The UI text is adjusted to indicate supported file types.
> 
> \*\*3. Refactoring and Improvements:\*\*
> 
> \- \*\*LLM Enumeration:\*\* The \`DiscourseAi::Configuration::LlmEnumerator\` now provides a \`values\_for\_serialization\` method, which returns a simplified array of LLM data (id, name, vision\_enabled) suitable for use in serializers. This avoids exposing unnecessary details to the frontend.
> \- \*\*AI Helper:\*\* The \`AiHelper::Assistant\` now takes optional \`helper\_llm\` and \`image\_caption\_llm\` parameters in its constructor, allowing for greater flexibility.
> \- \*\*Bot and Persona Updates:\*\* Several updates were made across the codebase, changing the string based association to a LLM to the new model based.
> \- \*\*Audit Logs:\*\* The \`DiscourseAi::Completions::Endpoints::Base\` now formats raw request payloads as pretty JSON for easier auditing.
> \- \*\*Eval Script:\*\* An evaluation script is included.
> 
> \*\*4. Testing:\*\*
> 
> \- The PR introduces a new eval system for LLMs, this allows us to test how functionality works across various LLM providers. This lives in \`/evals\`

臨時升個級，還沒結束⋯⋯

---

<div class="post-metadata">

作者： ![suen](https://forum.rdfzer.com/user_avatar/forum.rdfzer.com/suen/32/2665_2.png) [@suen](https://forum.rdfzer.com/u/suen)\
发布日期： [2025 年2 月 14 日 12:30 UTC](https://forum.rdfzer.com/t/topic/4899/3 "2025-02-14T12:30:36Z")

</div>

![The Discourse admin panel displays a successful update of the discourse-ai plugin, showing logs of server reload and database migrations. (Captioned by AI)](https://files.rdfzer.com/original/2X/5/555071b35a57c4801b012393606fc1a4251111d7.png)

---

<div class="post-metadata">

作者： ![suen](https://forum.rdfzer.com/user_avatar/forum.rdfzer.com/suen/32/2665_2.png) [@suen](https://forum.rdfzer.com/u/suen)\
发布日期： [2025 年2 月 14 日 13:18 UTC](https://forum.rdfzer.com/t/topic/4899/4 "2025-02-14T13:18:20Z")

</div>

> [@PDF，嗯，AI](https://forum.rdfzer.com/t/pdf-ai/4904):
>
> [the\_matrix.pdf](https://forum.rdfzer.com/uploads/short-url/6mR4bD78OJyeiXxnVOODyr7X3zZ.pdf) (260.1 KB) 你能閱讀這個文件了嗎，概述是什麼內容 Last edited by @suen 2025-02-14T13:17:57Z (UTC)
