Class: Deepseek::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/deepseek-ruby/client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



24
25
26
27
28
29
30
31
32
33
# File 'lib/deepseek-ruby/client.rb', line 24

def initialize
  @conn = Faraday.new(url: self.class.configuration.base_url) do |f|
    f.request :json
    f.response :json
    f.adapter self.class.configuration.http_adapter
    f.headers['Content-Type'] = 'application/json'
    f.headers['Accept'] = 'application/json'
    f.headers['Authorization'] = "Bearer #{self.class.configuration.api_key}"
  end
end

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



16
17
18
# File 'lib/deepseek-ruby/client.rb', line 16

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



19
20
21
22
# File 'lib/deepseek-ruby/client.rb', line 19

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

Instance Method Details

#chat_completions(params) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/deepseek-ruby/client.rb', line 35

def chat_completions(params)
  validate_params(params)
  response = @conn.post('/chat/completions') do |req|
    req.body = params.to_json
  end
  handle_response(response)
end