Skip to content

Commit 3250f4b

Browse files
committed
Add support for listing models
1 parent 9b98721 commit 3250f4b

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

lib/ruby_llm/providers/azure_openai.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ module AzureOpenAI
88
extend OpenAI
99
extend AzureOpenAI::Chat
1010
extend AzureOpenAI::Streaming
11+
extend AzureOpenAI::Models
1112

1213
module_function
1314

1415
def api_base(config)
1516
# https://<ENDPOINT>/openai/deployments/<MODEL>/chat/completions?api-version=<APIVERSION>
16-
"#{config.azure_openai_api_base}/openai/deployments"
17+
"#{config.azure_openai_api_base}/openai"
1718
end
1819

1920
def headers(config)

lib/ruby_llm/providers/azure_openai/chat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def sync_response(connection, payload)
1717

1818
def completion_url
1919
# https://<ENDPOINT>/openai/deployments/<MODEL>/chat/completions?api-version=<APIVERSION>
20-
"#{@model_id}/chat/completions?api-version=#{@config.azure_openai_api_version}"
20+
"deployments/#{@model_id}/chat/completions?api-version=#{@config.azure_openai_api_version}"
2121
end
2222

2323
def render_payload(messages, tools:, temperature:, model:, stream: false)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
module RubyLLM
4+
module Providers
5+
module AzureOpenAI
6+
# Models methods of the OpenAI API integration
7+
module Models
8+
extend OpenAI::Models
9+
10+
module_function
11+
12+
def models_url
13+
'models?api-version=2024-10-21'
14+
end
15+
end
16+
end
17+
end
18+
end

lib/tasks/models_update.rake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ def configure_from_env
2424
config.deepseek_api_key = ENV.fetch('DEEPSEEK_API_KEY', nil)
2525
config.openrouter_api_key = ENV.fetch('OPENROUTER_API_KEY', nil)
2626
configure_bedrock(config)
27+
configure_azure_openai(config)
2728
config.request_timeout = 30
2829
end
2930
end
3031

32+
def configure_azure_openai(config)
33+
config.azure_openai_api_base = ENV.fetch('AZURE_OPENAI_ENDPOINT', nil)
34+
config.azure_openai_api_key = ENV.fetch('AZURE_OPENAI_API_KEY', nil)
35+
config.azure_openai_api_version = ENV.fetch('AZURE_OPENAI_API_VER', nil)
36+
end
37+
3138
def configure_bedrock(config)
3239
config.bedrock_api_key = ENV.fetch('AWS_ACCESS_KEY_ID', nil)
3340
config.bedrock_secret_key = ENV.fetch('AWS_SECRET_ACCESS_KEY', nil)

0 commit comments

Comments
 (0)