Class: Deepseek::Client
- Inherits:
-
Object
- Object
- Deepseek::Client
- Defined in:
- lib/deepseek-ruby/client.rb
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
- #chat_completions(params) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
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
.configuration ⇒ Object
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
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 |