Class: Langchain::LLM::Azure
- Defined in:
- lib/langchain/llm/azure.rb
Overview
LLM interface for Azure OpenAI Service APIs: learn.microsoft.com/en-us/azure/ai-services/openai/
Gem requirements:
gem "ruby-openai", "~> 6.3.0"
Usage:
llm = Langchain::LLM::Azure.new(api_key:, llm_options: {}, embedding_deployment_url: chat_deployment_url:)
Constant Summary
Constants inherited from OpenAI
OpenAI::DEFAULTS, OpenAI::EMBEDDING_SIZES
Instance Attribute Summary collapse
-
#chat_client ⇒ Object
readonly
Returns the value of attribute chat_client.
-
#embed_client ⇒ Object
readonly
Returns the value of attribute embed_client.
Attributes inherited from Base
Instance Method Summary collapse
- #chat ⇒ Object
- #complete ⇒ Object
- #embed ⇒ Object
-
#initialize(api_key:, llm_options: {}, default_options: {}, embedding_deployment_url: nil, chat_deployment_url: nil) ⇒ Azure
constructor
A new instance of Azure.
Methods inherited from OpenAI
#default_dimensions, #summarize
Methods inherited from Base
#chat_parameters, #default_dimension, #default_dimensions, #summarize
Methods included from DependencyHelper
Constructor Details
#initialize(api_key:, llm_options: {}, default_options: {}, embedding_deployment_url: nil, chat_deployment_url: nil) ⇒ Azure
Returns a new instance of Azure.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/langchain/llm/azure.rb', line 16 def initialize( api_key:, llm_options: {}, default_options: {}, embedding_deployment_url: nil, chat_deployment_url: nil ) depends_on "ruby-openai", req: "openai" @embed_client = ::OpenAI::Client.new( access_token: api_key, uri_base: , ** ) @chat_client = ::OpenAI::Client.new( access_token: api_key, uri_base: chat_deployment_url, ** ) @defaults = DEFAULTS.merge() chat_parameters.update( model: {default: @defaults[:chat_model]}, logprobs: {}, top_logprobs: {}, n: {default: @defaults[:n]}, temperature: {default: @defaults[:temperature]}, user: {}, response_format: {default: @defaults[:response_format]} ) chat_parameters.ignore(:top_k) end |
Instance Attribute Details
#chat_client ⇒ Object (readonly)
Returns the value of attribute chat_client.
14 15 16 |
# File 'lib/langchain/llm/azure.rb', line 14 def chat_client @chat_client end |
#embed_client ⇒ Object (readonly)
Returns the value of attribute embed_client.
13 14 15 |
# File 'lib/langchain/llm/azure.rb', line 13 def @embed_client end |
Instance Method Details
#chat ⇒ Object
57 58 59 60 |
# File 'lib/langchain/llm/azure.rb', line 57 def chat(...) @client = @chat_client super end |
#complete ⇒ Object
52 53 54 55 |
# File 'lib/langchain/llm/azure.rb', line 52 def complete(...) @client = @chat_client super end |
#embed ⇒ Object
47 48 49 50 |
# File 'lib/langchain/llm/azure.rb', line 47 def (...) @client = @embed_client super end |