Class: Mistral::ClientBase

Inherits:
Object
  • Object
show all
Defined in:
lib/mistral/client_base.rb

Direct Known Subclasses

Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint:, api_key: nil, max_retries: 5, timeout: 120) ⇒ ClientBase

Returns a new instance of ClientBase.

Raises:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mistral/client_base.rb', line 7

def initialize(endpoint:, api_key: nil, max_retries: 5, timeout: 120)
  @max_retries = max_retries
  @timeout = timeout

  api_key = ENV['MISTRAL_API_KEY'] if api_key.nil?

  raise Error, 'API key not provided. Please set MISTRAL_API_KEY environment variable.' if api_key.nil?

  @api_key = api_key
  @endpoint = endpoint
  @logger = config_logger

  # For azure endpoints, we default to the mistral model
  @default_model = 'mistral' if endpoint.include?('inference.azure.com')
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/mistral/client_base.rb', line 5

def api_key
  @api_key
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



5
6
7
# File 'lib/mistral/client_base.rb', line 5

def endpoint
  @endpoint
end

#max_retriesObject (readonly)

Returns the value of attribute max_retries.



5
6
7
# File 'lib/mistral/client_base.rb', line 5

def max_retries
  @max_retries
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



5
6
7
# File 'lib/mistral/client_base.rb', line 5

def timeout
  @timeout
end