Module: Legion::Extensions::AzureAi::Helpers::Client

Included in:
Runners::Chat, Runners::ContentSafety, Runners::Embeddings, Runners::Models
Defined in:
lib/legion/extensions/azure_ai/helpers/client.rb

Class Method Summary collapse

Class Method Details

.client(api_key:, endpoint:, _api_version: '2024-10-21') ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/legion/extensions/azure_ai/helpers/client.rb', line 13

def client(api_key:, endpoint:, _api_version: '2024-10-21', **)
  Faraday.new(url: "https://#{endpoint}.openai.azure.com") do |conn|
    conn.request :json
    conn.response :json, content_type: /\bjson$/
    conn.headers['api-key'] = api_key
    conn.headers['Content-Type'] = 'application/json'
  end
end

.content_safety_client(api_key:, endpoint:) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/legion/extensions/azure_ai/helpers/client.rb', line 22

def content_safety_client(api_key:, endpoint:, **)
  Faraday.new(url: "https://#{endpoint}.cognitiveservices.azure.com") do |conn|
    conn.request :json
    conn.response :json, content_type: /\bjson$/
    conn.headers['Ocp-Apim-Subscription-Key'] = api_key
    conn.headers['Content-Type'] = 'application/json'
  end
end