Discourse unterstützt keine strukturierten Inhaltsantworten von Mistral

Beim Moderieren eines Beitrags tritt der folgende Fehler auf

LlmAgentTriage.handle : TypeError : no implicit conversion of Hash into String

Discourse v2026.10.1

Modell: mistral-large-4

-[ RECORD 2 ]------------+----------------------------------------------
id                       | 5
display_name             | Mistral Large 4
name                     | mistral-large-4
provider                 | mistral
tokenizer                | DiscourseAi::Tokenizer::MistralTokenizer
max_prompt_tokens        | 8000
created_at               | 2026-11-17 16:54:32.819593
updated_at               | 2026-11-17 16:54:32.819593
url                      | https://api.eu.mistral.ai/v1/chat/completions
api_key                  |
user_id                  |
enabled_chat_bot         | f
provider_params          | {"disable_native_tools": null}
vision_enabled           | f
input_cost               |
cached_input_cost        |
output_cost              |
max_output_tokens        | 2000
cache_write_cost         | 0
allowed_attachment_types | {}
ai_secret_id             | 1
vision_llm_model_id      |

Beim Moderieren eines Beitrags passiert Folgendes:


Error responding to: /t/testing-7-17-11-2026/2437/3 in LlmAgentTriage.handle : TypeError : no implicit conversion of Hash into String


Backtrace

/var/www/discourse/plugins/discourse-ai/lib/ai_bot/playground.rb:889:in 'block in DiscourseAi::AiBot::Playground#reply_to_unlocked'
/var/www/discourse/plugins/discourse-ai/lib/agents/bot.rb:461:in 'block in DiscourseAi::Agents::Bot#reply'
/var/www/discourse/plugins/discourse-ai/lib/completions/llm.rb:381:in 'block in DiscourseAi::Completions::Llm#generate'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:799:in 'block in DiscourseAi::Completions::Endpoints::Base#streaming_partial_handler'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:835:in 'block (3 levels) in DiscourseAi::Completions::Endpoints::Base#streaming_response'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:835:in 'Array#each'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:835:in 'block (2 levels) in DiscourseAi::Completions::Endpoints::Base#streaming_response'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:823:in 'Array#each'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:823:in 'block in DiscourseAi::Completions::Endpoints::Base#streaming_response'
net-protocol-0.4.0/lib/net/protocol.rb:604:in 'Net::ReadAdapter#call_block'
net-protocol-0.4.0/lib/net/protocol.rb:595:in 'Net::ReadAdapter#<<'
net-protocol-0.4.0/lib/net/protocol.rb:205:in 'Net::BufferedIO#read'
net-http-0.10.0/lib/net/http/response.rb:657:in 'Net::HTTPResponse#read_chunked'
net-http-0.10.0/lib/net/http/response.rb:616:in 'block in Net::HTTPResponse#read_body_0'
net-http-0.10.0/lib/net/http/response.rb:609:in 'Net::HTTPResponse#inflater'
net-http-0.10.0/lib/net/http/response.rb:614:in 'Net::HTTPResponse#read_body_0'
net-http-0.10.0/lib/net/http/response.rb:384:in 'Net::HTTPResponse#read_body'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:818:in 'DiscourseAi::Completions::Endpoints::Base#streaming_response'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:571:in 'block (3 levels) in DiscourseAi::Completions::Endpoints::Base#perform_completion_request_with_retries'
net-http-0.10.0/lib/net/http.rb:2520:in 'block in Net::HTTP#transport_request'
net-http-0.10.0/lib/net/http/response.rb:341:in 'Net::HTTPResponse#reading_body'
net-http-0.10.0/lib/net/http.rb:2517:in 'Net::HTTP#transport_request'
net-http-0.10.0/lib/net/http.rb:2463:in 'Net::HTTP#request'
rack-mini-profiler-5.0.0/lib/patches/net_patches.rb:19:in 'block in Net::HTTP#request_with_mini_profiler'
rack-mini-profiler-5.0.0/lib/mini_profiler/profiling_methods.rb:51:in 'Rack::MiniProfiler::ProfilingMethods#step'
rack-mini-profiler-5.0.0/lib/patches/net_patches.rb:18:in 'Net::HTTP#request_with_mini_profiler'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:522:in 'block (2 levels) in DiscourseAi::Completions::Endpoints::Base#perform_completion_request_with_retries'
net-http-0.10.0/lib/net/http.rb:1634:in 'Net::HTTP#start'
net-http-0.10.0/lib/net/http.rb:1068:in 'Net::HTTP.start'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:503:in 'block in DiscourseAi::Completions::Endpoints::Base#perform_completion_request_with_retries'
:168:in 'Kernel#loop'

In den Protokollen steht Folgendes:


raw_response_payload | data: {"id":"bbda4b362069470e9c57d735628e0bbe","object":"chat.completion.chunk","created":1794935117,"model":"mistral-large-4","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             +
                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    +
                     | data: {"id":"bbda4b362069470e9c57d735628e0bbe","object":"chat.completion.chunk","created":1794935117,"model":"mistral-large-4","choices":[{"index":0,"delta":{"content":[{"type":"thinking","thinking":[{"type":"text","text":"The user is asking"}],"closed":true}]},"finish_reason":null}],"p":"abcdefghijklmnopqrstuvwxyz012"} 
                     

Das Streaming-Format von OpenAI verwendet einen String für delta.content:

{
  "choices": [{
    "delta": {
      "content": "The answer is..."
    }
  }]
}

Mistral Large 4 gibt stattdessen strukturierte Inhaltsblöcke zurück:

"delta": {
  "content": [
    {
      "type": "thinking",
      "thinking": [
        {
          "type": "text",
          "text": "The user is asking"
        }
      ],
      "closed": true
    }
  ]
}

Es können anschließend auch type: "text"-Blöcke innerhalb derselben Struktur zurückgegeben werden. Siehe Reasoning | Mistral Docs

Discourse kann dies nicht verarbeiten. Die strukturierten Inhalte sollten im Mistral-Endpunkt normalisiert werden, indem type: "text"-Chunks extrahiert und type: "thinking" separat behandelt werden, anstatt sie wie einen String zu behandeln.

1 „Gefällt mir“

Moment, sie geben die strukturierte Ausgabe innerhalb des Thinking-Blocks zurück!?

Was passiert, wenn man Reasoning deaktiviert?

1 „Gefällt mir“

Das Deaktivieren des Reasonings ist bei Mistral 4 nicht möglich.

HAL 9000: Ich fürchte, das kann ich nicht

1 „Gefällt mir“

Mir ist klar, dass dies nicht direkt auf die ursprüngliche Frage eingeht, aber LiteLLM kann als Proxy verwendet werden. Es ist die Lösung, die ich in ähnlichen Situationen und bei anderen Modellen gefunden habe, die bestimmte Elemente in den von Discourse gesendeten Prompts entweder nicht akzeptierten oder erforderlich hatten.

Es ist eher ein Hack als eine Umgehungslösung.

Kannst du die anderen Zeilen auch teilen? Es scheint, als ob diese nicht final sind, da "finish_reason":null steht.

Es stürzte nach dieser Zeile ab, daher wurde die weitere Ausgabe des Modells nicht mehr empfangen und protokolliert.

Passt das für dich, @RGJ?

1 „Gefällt mir“