sebasslash / azureai_client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

azureai_client

AzureAIClient - the Ruby gem for the Azure OpenAI Service API

Azure OpenAI APIs for completions and search

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 2023-05-15
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build azureai_client.gemspec

Then either install the gem locally:

gem install ./azureai_client-1.0.0.gem

(for development, run gem install --dev ./azureai_client-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'azureai_client', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'azureai_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'azureai_client'

# Setup authorization
AzureAIClient.configure do |config|
  # Configure API key authorization: apiKey
  config.api_key['apiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKey'] = 'Bearer'

  # Configure OAuth2 access token for authorization: bearer
  config.access_token = 'YOUR ACCESS TOKEN'
  # Configure a proc to get access tokens in lieu of the static access_token configuration
  config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } 
end

api_instance = AzureAIClient::DefaultApi.new
deployment_id = 'deployment_id_example' # String | 
api_version = '2023-05-15' # String | 
chat_completions_create_request = AzureAIClient::ChatCompletionsCreateRequest.new({messages: [AzureAIClient::ChatCompletionsCreateRequestMessagesInner.new({role: 'system', content: 'content_example'})]}) # ChatCompletionsCreateRequest | 

begin
  #Creates a completion for the chat message
  result = api_instance.chat_completions_create(deployment_id, api_version, chat_completions_create_request)
  p result
rescue AzureAIClient::ApiError => e
  puts "Exception when calling DefaultApi->chat_completions_create: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://your-resource-name.openai.azure.com/openai

Class Method HTTP request Description
AzureAIClient::DefaultApi chat_completions_create POST /deployments/{deployment-id}/chat/completions Creates a completion for the chat message
AzureAIClient::DefaultApi completions_create POST /deployments/{deployment-id}/completions Creates a completion for the provided prompt, parameters and chosen model.
AzureAIClient::DefaultApi embeddings_create POST /deployments/{deployment-id}/embeddings Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

bearer

apiKey

  • Type: API key
  • API key parameter name: api-key
  • Location: HTTP header

About


Languages

Language:Ruby 99.3%Language:Shell 0.7%