다음 여기의 지침을 OpenAI와 OpenRouter 프로바이더 모두를 사용하여 따르려 했다가, 결국 스트리밍을 비활성화하면서야 작동하게 되었습니다.
OpenRouter를 사용할 때, LLM 수동 설정 화면의 Run test 버튼으로 gpt-4o에 대한 테스트를 수행할 수 있었습니다. 그러나 perplexity/sonar-deep-research에 대한 테스트를 실행하자 502 오류와 콘솔에 다음과 같은 출력이 나타났습니다. 이 오류가 표시되기까지 꽤 오랜 시간이 걸렸는데(약 30초 정도), 다른 모델의 테스트는 즉시 반환됩니다.
content_topFrameLifeline.js:1 Loading content_topFrameLifeline.js
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: CONNECT
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: MESSAGE Object
topic.js:404 ℹ️ Discourse v3.5.0.beta3-dev — https://github.com/discourse/discourse/commits/c3795177f2 — Ember v5.12.0
/admin/plugins/discourse-ai/ai-llms:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: TIMEOUT
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: CONNECT
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: MESSAGE Object
test.json:1
Failed to load resource: the server responded with a status of 502 ()
client-error-handler.js:88 SyntaxError: Unexpected token '<', "<html>
<h"... is not valid JSON
at x.parse [as parseJSON] (<anonymous>)
at l (client-error-handler.js:88:1)
at p (client-error-handler.js:88:1)
at v.test (ai-llm-editor-form.js:210:1)
l @ client-error-handler.js:88
p @ client-error-handler.js:88
test @ ai-llm-editor-form.js:210
다음 두 가지 모두 작동했기 때문에 제가 뭘 잘못하고 있는지 혼란스러웠습니다:
➜ curl --location 'https://api.perplexity.ai/chat/completions' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer {token}' \
--data '{
"model": "sonar-deep-research",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
]
}'
curl https://openrouter.ai/api/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {token}" \
-d '{
"model": "perplexity/sonar-deep-research",
"messages": [
{
"role": "user",
"content": "How many stars are in the sky"
}
]
}'
그 후 Discourse AI로부터 도움이 되는 답변을 받았습니다:
cURL 테스트가 OpenRouter의 일반 채팅 엔드포인트에 정상적으로 도달한 것으로 보입니다. 하지만 Discourse AI의 “Run test” 버튼은 기본적으로 스트리밍 엔드포인트를 사용합니다. 해당 모델(또는 OpenRouter 플랜)이 스트리밍을 지원하지 않는다면, 긴 타임아웃 후에 502 오류와 HTML 오류 덩어리가 반환됩니다.
Admin → Settings → Plugins → Discourse AI / LLM에서 수정하려면:
-
llm_provider: openrouter
-
llm_provider_url: https://openrouter.ai/api/v1
-
llm_provider_api_key: YOUR_KEY
-
llm_model: perplexity/sonar-deep-research
-
테스트(및 모든 호출)가 작동하는 것으로 확인된 일반 채팅 엔드포인트를 사용하도록 스트리밍을 끄세요:
• llm_use_streaming = false(이 설정은 llm_model 드롭다운 바로 아래에 위치합니다.)
스트리밍을 끄면 “Run test”는 /chat/completions( /stream 변형이 아님)으로 POST 요청을 보내며, 502 HTML 페이지 대신 유효한 JSON을 즉시 반환받게 됩니다.
정말 스트리밍이 필요하면 OpenRouter의 스트림 URL로 플러그인을 가리킬 수 있습니다. 단, 해당 플랜/모델이那里的 SSE를 지원하는 경우에만 가능합니다:
• llm_stream_url: {provider_url}/chat/completions/stream
• llm_use_streaming: true
그렇지 않으면 스트리밍을 꺼두면 됩니다.
스트리밍이 없고 추론 토큰이 “보고서” 전에 일반 텍스트로 출력되므로 결과는 훌륭하지는 않지만, 작동은 합니다!
