Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 4676025

Browse files
committed
FEATURE: Support srv records for OpenAI compatible LLMs
1 parent c1fa84a commit 4676025

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/completions/endpoints/open_ai.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ def perform_completion!(
4848
private
4949

5050
def model_uri
51-
URI(llm_model.url)
51+
if llm_model.url.to_s.starts_with?("srv://")
52+
service = DiscourseAi::Utils::DnsSrv.lookup(llm_model.url.sub("srv://", ""))
53+
api_endpoint = "https://#{service.target}:#{service.port}/v1/chat/completions"
54+
else
55+
api_endpoint = llm_model.url
56+
end
57+
58+
@uri ||= URI(api_endpoint)
5259
end
5360

5461
def prepare_payload(prompt, model_params, dialect)

0 commit comments

Comments
 (0)