Class: Deepseek::Client
- Inherits:
-
Object
- Object
- Deepseek::Client
- Defined in:
- lib/deepseek/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #chat(messages:, model: 'deepseek-chat', **params) ⇒ Object
-
#initialize(api_key: nil, **options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key: nil, **options) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 |
# File 'lib/deepseek/client.rb', line 9 def initialize(api_key: nil, **) @config = Configuration.new @config.api_key = api_key if api_key .each do |key, value| @config.send("#{key}=", value) if @config.respond_to?("#{key}=") end @config.validate! # This will raise ConfigurationError if no API key is set end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/deepseek/client.rb', line 7 def config @config end |
Instance Method Details
#chat(messages:, model: 'deepseek-chat', **params) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/deepseek/client.rb', line 18 def chat(messages:, model: 'deepseek-chat', **params) post('/v1/chat/completions', { model: model, messages: , **params }) rescue Faraday::Error => e handle_error_response(e.response) if e.response raise e end |