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:
openai = 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, OpenAI::LENGTH_VALIDATOR
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 OpenAI
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
#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 |
# 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() 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
47 48 49 50 |
# File 'lib/langchain/llm/azure.rb', line 47 def chat(...) @client = @chat_client super(...) end |
#complete ⇒ Object
42 43 44 45 |
# File 'lib/langchain/llm/azure.rb', line 42 def complete(...) @client = @chat_client super(...) end |
#embed ⇒ Object
37 38 39 40 |
# File 'lib/langchain/llm/azure.rb', line 37 def (...) @client = @embed_client super(...) end |