Class: GigaChat::Client
Constant Summary collapse
- CONFIG_KEYS =
%i[ api_type api_version client_base64 log_errors uri_base uri_auth request_timeout extra_headers ].freeze
Instance Method Summary collapse
- #chat(parameters: {}) ⇒ Object
- #embeddings(parameters: {}) ⇒ Object
-
#initialize(config = {}, &faraday_middleware) ⇒ Client
constructor
A new instance of Client.
- #models ⇒ Object
Methods included from HTTP
#delete, #get, #json_post, #multipart_post, #post
Methods included from HTTPHeaders
Constructor Details
#initialize(config = {}, &faraday_middleware) ⇒ Client
Returns a new instance of Client.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gigachat/client.rb', line 17 def initialize(config = {}, &faraday_middleware) CONFIG_KEYS.each do |key| # Set instance variables like client_id. Fall back to global config # if not present. instance_variable_set( "@#{key}", config[key].nil? ? GigaChat.configuration.send(key) : config[key] ) end @faraday_middleware = faraday_middleware end |
Instance Method Details
#chat(parameters: {}) ⇒ Object
33 34 35 |
# File 'lib/gigachat/client.rb', line 33 def chat(parameters: {}) json_post(path: "/chat/completions", parameters: parameters) end |
#embeddings(parameters: {}) ⇒ Object
37 38 39 |
# File 'lib/gigachat/client.rb', line 37 def (parameters: {}) json_post(path: "/embeddings", parameters: parameters) end |