Erreur Interne du Serveur 500 - Configuration manuelle [Discourse AI]

J’ai un forum Discourse auto-hébergé et je rencontre une erreur interne du serveur lors de la configuration de Discourse AI et des LLM manuels. Comment puis-je résoudre ce problème ? Pourriez-vous partager des guides utiles pour m’aider davantage ?

Captures d’écran de l’erreur

Échec du chargement de la ressource : le serveur a répondu avec un statut de 500 ()

Étapes effectuées (captures d’écran) :




Vérifiez votre route /logs pour voir s’il y a plus d’informations sur l’erreur. Si ma mémoire est bonne, Ollama a besoin de quelque chose dans le champ de la clé API, même s’il n’est pas utilisé.

@Roman

Voici les journaux

Message d’information

NoMethodError (méthode non définie `-' pour nil)
app/controllers/application_controller.rb:428:in `block in with_resolved_locale'
app/controllers/application_controller.rb:428:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:35:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:415:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
lib/middleware/default_headers.rb:13:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/processing_request.rb:12:in `call'
lib/middleware/request_tracker.rb:410:in `call'

Backtrace

plugins/discourse-ai/lib/completions/dialects/chat_gpt.rb:47:in `max_prompt_tokens'
plugins/discourse-ai/lib/completions/dialects/dialect.rb:134:in `trim_messages'
plugins/discourse-ai/lib/completions/dialects/dialect.rb:83:in `translate'
plugins/discourse-ai/lib/completions/endpoints/base.rb:123:in `perform_completion!'
plugins/discourse-ai/lib/completions/endpoints/open_ai.rb:53:in `perform_completion!'
plugins/discourse-ai/lib/completions/llm.rb:415:in `generate'
plugins/discourse-ai/lib/configuration/llm_validator.rb:36:in `run_test'
plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llms_controller.rb:143:in `test'
actionpack (8.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:8:in `send_action'
actionpack (8.0.2.1) lib/abstract_controller/base.rb:226:in `process_action'
actionpack (8.0.2.1) lib/action_controller/metal/rendering.rb:193:in `process_action'
actionpack (8.0.2.1) lib/abstract_controller/callbacks.rb:261:in `block in process_action'
activesupport (8.0.2.1) lib/active_support/callbacks.rb:120:in `block in run_callbacks'
app/controllers/application_controller.rb:428:in `block in with_resolved_locale'
i18n (1.14.7) lib/i18n.rb:353:in `with_locale'
app/controllers/application_controller.rb:428:in `with_resolved_locale'
activesupport (8.0.2.1) lib/active_support/callbacks.rb:129:in `block in run_callbacks'
activesupport (8.0.2.1) lib/active_support/callbacks.rb:140:in `run_callbacks'
actionpack (8.0.2.1) lib/abstract_controller/callbacks.rb:260:in `process_action'
actionpack (8.0.2.1) lib/action_controller/metal/rescue.rb:27:in `process_action'
actionpack (8.0.2.1) lib/action_controller/metal/instrumentation.rb:76:in `block in process_action'
activesupport (8.0.2.1) lib/active_support/notifications.rb:210:in `block in instrument'
activesupport (8.0.2.1) lib/active_support/notifications/instrumenter.rb:58:in `instrument'
activesupport (8.0.2.1) lib/active_support/notifications.rb:210:in `instrument'
actionpack (8.0.2.1) lib/action_controller/metal/instrumentation.rb:75:in `process_action'
actionpack (8.0.2.1) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (8.0.2.1) lib/active_record/railties/controller_runtime.rb:39:in `process_action'
actionpack (8.0.2.1) lib/abstract_controller/base.rb:163:in `process'
actionview (8.0.2.1) lib/action_view/rendering.rb:40:in `process'
rack-mini-profiler (4.0.1) lib/mini_profiler/profiling_methods.rb:116:in `block in profile_method'
actionpack (8.0.2.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (8.0.2.1) lib/action_controller/metal.rb:335:in `dispatch'
actionpack (8.0.2.1) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (8.0.2.1) lib/action_dispatch/routing/route_set.rb:50:in `serve'
actionpack (8.0.2.1) lib/action_dispatch/routing/mapper.rb:32:in `block in <class:Constraints>'
actionpack (8.0.2.1) lib/action_dispatch/routing/mapper.rb:62:in `serve'
actionpack (8.0.2.1) lib/action_dispatch/journey/router.rb:53:in `block in serve'
actionpack (8.0.2.1) lib/action_dispatch/journey/router.rb:133:in `block in find_routes'
actionpack (8.0.2.1) lib/action_dispatch/journey/router.rb:126:in `each'
actionpack (8.0.2.1) lib/action_dispatch/journey/router.rb:126:in `find_routes'
actionpack (8.0.2.1) lib/action_dispatch/journey/router.rb:34:in `serve'
actionpack (8.0.2.1) lib/action_dispatch/routing/route_set.rb:908:in `call'
lib/middleware/omniauth_bypass_middleware.rb:35:in `call'
rack (2.2.17) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.17) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.17) lib/rack/head.rb:12:in `call'
actionpack (8.0.2.1) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:415:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
rack (2.2.17) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.17) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (8.0.2.1) lib/action_dispatch/middleware/cookies.rb:706:in `call'
actionpack (8.0.2.1) lib/action_dispatch/middleware/callbacks.rb:31:in `block in call'
activesupport (8.0.2.1) lib/active_support/callbacks.rb:100:in `run_callbacks'
actionpack (8.0.2.1) lib/action_dispatch/middleware/callbacks.rb:30:in `call'
actionpack (8.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:31:in `call'
actionpack (8.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:32:in `call'
logster (2.20.1) lib/logster/middleware/reporter.rb:40:in `call'
lib/middleware/default_headers.rb:13:in `call'
railties (8.0.2.1) lib/rails/rack/logger.rb:41:in `call_app'
railties (8.0.2.1) lib/rails/rack/logger.rb:29:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
actionpack (8.0.2.1) lib/action_dispatch/middleware/request_id.rb:34:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
rack (2.2.17) lib/rack/method_override.rb:24:in `call'
actionpack (8.0.2.1) lib/action_dispatch/middleware/executor.rb:16:in `call'
rack (2.2.17) lib/rack/sendfile.rb:110:in `call'
rack-mini-profiler (4.0.1) lib/mini_profiler.rb:334:in `call'
lib/middleware/processing_request.rb:12:in `call'
message_bus (4.4.1) lib/message_bus/rack/middleware.rb:60:in `call'
lib/middleware/request_tracker.rb:410:in `call'
actionpack (8.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:96:in `call'
railties (8.0.2.1) lib/rails/engine.rb:535:in `call'
railties (8.0.2.1) lib/rails/railtie.rb:226:in `public_send'
railties (8.0.2.1) lib/rails/railtie.rb:226:in `method_missing'
rack (2.2.17) lib/rack/urlmap.rb:74:in `block in call'
rack (2.2.17) lib/rack/urlmap.rb:58:in `each'
rack (2.2.17) lib/rack/urlmap.rb:58:in `call'
unicorn (6.1.0) lib/unicorn/http_server.rb:634:in `process_client'
unicorn (6.1.0) lib/unicorn/http_server.rb:739:in `worker_loop'
unicorn (6.1.0) lib/unicorn/http_server.rb:547:in `spawn_missing_workers'
unicorn (6.1.0) lib/unicorn/http_server.rb:143:in `start'
unicorn (6.1.0) bin/unicorn:128:in `<top (required)>'
vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `load'
vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `<main>'

Vous devez remplir tous les champs requis pour exécuter le test. L’erreur que vous avez partagée se produit parce que vous n’avez pas spécifié de fenêtre de contexte pour le modèle.

Message d’erreur :

Tentative de contact du modèle a renvoyé cette erreur : {"error":{"message":"[] est trop court - 'messages'","type":"invalid_request_error","param":null,"code":null}}


Journaux

Message (2 copies signalées)

DiscourseAi::Completions::Endpoints::OpenAi: status: 400 - body: {"error":{"message":"[] est trop court - 'messages'","type":"invalid_request_error","param":null,"code":null}}

Trace du backtrace

activesupport-8.0.2.1/lib/active_support/broadcast_logger.rb:134:in `block in error'
activesupport-8.0.2.1/lib/active_support/broadcast_logger.rb:231:in `block in dispatch'
activesupport-8.0.2.1/lib/active_support/broadcast_logger.rb:231:in `each'
activesupport-8.0.2.1/lib/active_support/broadcast_logger.rb:231:in `dispatch'
activesupport-8.0.2.1/lib/active_support/broadcast_logger.rb:134:in `error'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:170:in `block (2 levels) in perform_completion!'
net-http-0.6.0/lib/net/http.rb:2433:in `block in transport_request'
net-http-0.6.0/lib/net/http/response.rb:320:in `reading_body'
net-http-0.6.0/lib/net/http.rb:2430:in `transport_request'
net-http-0.6.0/lib/net/http.rb:2384:in `request'
rack-mini-profiler-4.0.1/lib/patches/net_patches.rb:19:in `block in request_with_mini_profiler'
rack-mini-profiler-4.0.1/lib/mini_profiler/profiling_methods.rb:45:in `step'
rack-mini-profiler-4.0.1/lib/patches/net_patches.rb:18:in `request_with_mini_profiler'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:168:in `block in perform_completion!'
net-http-0.6.0/lib/net/http.rb:1632:in `start'
net-http-0.6.0/lib/net/http.rb:1070:in `start'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:139:in `perform_completion!'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/open_ai.rb:53:in `perform_completion!'
/var/www/discourse/plugins/discourse-ai/lib/completions/llm.rb:415:in `generate'
/var/www/discourse/plugins/discourse-ai/lib/configuration/llm_validator.rb:36:in `run_test'
/var/www/discourse/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llms_controller.rb:143:in `test'
actionpack-8.0.2.1/lib/action_controller/metal/basic_implicit_render.rb:8:in `send_action'
actionpack-8.0.2.1/lib/abstract_controller/base.rb:226:in `process_action'
actionpack-8.0.2.1/lib/action_controller/metal/rendering.rb:193:in `process_action'
actionpack-8.0.2.1/lib/abstract_controller/callbacks.rb:261:in `block in process_action'
activesupport-8.0.2.1/lib/active_support/callbacks.rb:120:in `block in run_callbacks'
/var/www/discourse/app/controllers/application_controller.rb:428:in `block in with_resolved_locale'
i18n-1.14.7/lib/i18n.rb:353:in `with_locale'
/var/www/discourse/app/controllers/application_controller.rb:428:in `with_resolved_locale'
activesupport-8.0.2.1/lib/active_support/callbacks.rb:129:in `block in run_callbacks'
activesupport-8.0.2.1/lib/active_support/callbacks.rb:140:in `run_callbacks'
actionpack-8.0.2.1/lib/abstract_controller/callbacks.rb:260:in `process_action'
actionpack-8.0.2.1/lib/action_controller/metal/rescue.rb:27:in `process_action'
actionpack-8.0.2.1/lib/action_controller/metal/instrumentation.rb:76:in `block in process_action'
activesupport-8.0.2.1/lib/active_support/notifications.rb:210:in `block in instrument'
activesupport-8.0.2.1/lib/active_support/notifications/instrumenter.rb:58:in `instrument'
activesupport-8.0.2.1/lib/active_support/notifications.rb:210:in `instrument'
actionpack-8.0.2.1/lib/action_controller/metal/instrumentation.rb:75:in `process_action'
actionpack-8.0.2.1/lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord-8.0.2.1/lib/active_record/railties/controller_runtime.rb:39:in `process_action'
actionpack-8.0.2.1/lib/abstract_controller/base.rb:163:in `process'
actionview-8.0.2.1/lib/action_view/rendering.rb:40:in `process'
rack-mini-profiler-4.0.1/lib/mini_profiler/profiling_methods.rb:116:in `block in profile_method'
actionpack-8.0.2.1/lib/action_controller/metal.rb:252:in `dispatch'
actionpack-8.0.2.1/lib/action_controller/metal.rb:335:in `dispatch'
actionpack-8.0.2.1/lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack-8.0.2.1/lib/action_dispatch/routing/route_set.rb:50:in `serve'
actionpack-8.0.2.1/lib/action_dispatch/routing/mapper.rb:32:in `block in <class:Constraints>'
actionpack-8.0.2.1/lib/action_dispatch/routing/mapper.rb:62:in `serve'
actionpack-8.0.2.1/lib/action_dispatch/journey/router.rb:53:in `block in serve'
actionpack-8.0.2.1/lib/action_dispatch/journey/router.rb:133:in `block in find_routes'
actionpack-8.0.2.1/lib/action_dispatch/journey/router.rb:126:in `each'
actionpack-8.0.2.1/lib/action_dispatch/journey/router.rb:126:in `find_routes'
actionpack-8.0.2.1/lib/action_dispatch/journey/router.rb:34:in `serve'
actionpack-8.0.2.1/lib/action_dispatch/routing/route_set.rb:908:in `call'
/var/www/discourse/lib/middleware/omniauth_bypass_middleware.rb:35:in `call'
rack-2.2.17/lib/rack/tempfile_reaper.rb:15:in `call'
rack-2.2.17/lib/rack/conditional_get.rb:27:in `call'
rack-2.2.17/lib/rack/head.rb:12:in `call'
actionpack-8.0.2.1/lib/action_dispatch/http/permissions_policy.rb:38:in `call'
/var/www/discourse/lib/content_security_policy/middleware.rb:12:in `call'
/var/www/discourse/lib/middleware/anonymous_cache.rb:415:in `call'
/var/www/discourse/lib/middleware/csp_script_nonce_injector.rb:12:in `call'
/var/www/discourse/config/initializers/008-rack-cors.rb:14:in `call'
rack-2.2.17/lib/rack/session/abstract/id.rb:266:in `context'
rack-2.2.17/lib/rack/session/abstract/id.rb:260:in `call'
actionpack-8.0.2.1/lib/action_dispatch/middleware/cookies.rb:706:in `call'
actionpack-8.0.2.1/lib/action_dispatch/middleware/callbacks.rb:31:in `block in call'
activesupport-8.0.2.1/lib/active_support/callbacks.rb:100:in `run_callbacks'
actionpack-8.0.2.1/lib/action_dispatch/middleware/callbacks.rb:30:in `call'
actionpack-8.0.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:31:in `call'
actionpack-8.0.2.1/lib/action_dispatch/middleware/show_exceptions.rb:32:in `call'
logster-2.20.1/lib/logster/middleware/reporter.rb:40:in `call'
/var/www/discourse/lib/middleware/default_headers.rb:13:in `call'
railties-8.0.2.1/lib/rails/rack/logger.rb:41:in `call_app'
railties-8.0.2.1/lib/rails/rack/logger.rb:29:in `call'
/var/www/discourse/config/initializers/100-quiet_logger.rb:20:in `call'
/var/www/discourse/config/initializers/100-silence_logger.rb:29:in `call'
actionpack-8.0.2.1/lib/action_dispatch/middleware/request_id.rb:34:in `call'
/var/www/discourse/lib/middleware/enforce_hostname.rb:23:in `call'
rack-2.2.17/lib/rack/method_override.rb:24:in `call'
actionpack-8.0.2.1/lib/action_dispatch/middleware/executor.rb:16:in `call'
rack-2.2.17/lib/rack/sendfile.rb:110:in `call'
rack-mini-profiler-4.0.1/lib/mini_profiler.rb:334:in `call'
/var/www/discourse/lib/middleware/processing_request.rb:12:in `call'
message_bus-4.4.1/lib/message_bus/rack/middleware.rb:60:in `call'
/var/www/discourse/lib/middleware/request_tracker.rb:410:in `call'
actionpack-8.0.2.1/lib/action_dispatch/middleware/remote_ip.rb:96:in `call'
railties-8.0.2.1/lib/rails/engine.rb:535:in `call'
railties-8.0.2.1/lib/rails/railtie.rb:226:in `public_send'
railties-8.0.2.1/lib/rails/railtie.rb:226:in `method_missing'
rack-2.2.17/lib/rack/urlmap.rb:74:in `block in call'
rack-2.2.17/lib/rack/urlmap.rb:58:in `each'
rack-2.2.17/lib/rack/urlmap.rb:58:in `call'
unicorn-6.1.0/lib/unicorn/http_server.rb:634:in `process_client'
unicorn-6.1.0/lib/unicorn/http_server.rb:739:in `worker_loop'
unicorn-6.1.0/lib/unicorn/http_server.rb:547:in `spawn_missing_workers'
unicorn-6.1.0/lib/unicorn/http_server.rb:143:in `start'
unicorn-6.1.0/bin/unicorn:128:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `load'
/var/www/discourse/vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `<main>'

Salut @Roman

Je rencontre un nouveau problème.

Veuillez trouver les journaux dans les commentaires de suivi ci-dessus et suggérer les modifications nécessaires si besoin, ou quelle pourrait être la raison du problème.

Lorsque j’ai décoché l’option Activer l’API de réponse (nécessaire sur certains modèles OpenAI), le test a réussi.

1 « J'aime »

Voici la réponse cURL que nous avons reçue lorsque nous avons tenté l’action, indépendamment de Discourse.

curl -X POST http://localhost:11434/v1/chat/completions -H "Content-Type: application/json" -d '{
  "model": "deepseek-coder-v2:latest",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "What is the latest version of Conan as per 2025"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 200
}'

{"id":"chatcmpl-940","object":"chat.completion","created":1757057197,"model":"deepseek-coder-v2:latest","system_fingerprint":"fp_ollama","choices":[{"index":0,"message":{"role":"assistant","content":" D'après ma dernière mise à jour début 2023, il n'y a pas d'informations spécifiques sur \"Conan\" après 2025, car je n'ai pas de capacités de prédiction future ni de données en temps réel. Cependant, je peux vous donner quelques conseils généraux sur la façon de trouver la dernière version de Conan, qui est un gestionnaire de paquets pour la gestion des dépendances C/C++ :\n\n1. **Visitez le site officiel :** Le moyen le plus fiable d'obtenir des informations sur la dernière version de Conan est de visiter le site officiel à l'adresse https://conan.io/. Vous y trouverez généralement les dernières notes de version et la documentation relative à la dernière version.\n\n2. **Consultez le dépôt GitHub :** Le code source de Conan est hébergé sur GitHub, vous pouvez donc également consulter le dépôt (https://github.com/conan-io/conan) pour les versions ou les tags qui correspondent aux différentes versions. Le dépôt inclut souvent des notes de version sous forme de commits et de pull requests.\n\n3"},"finish_reason":"length"}],"usage":{"prompt_tokens":30,"completion_tokens":200,"total_tokens":230}}

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