Class: FastDeepseek::Client
- Inherits:
-
Object
- Object
- FastDeepseek::Client
- Defined in:
- lib/fast_deepseek/client.rb
Constant Summary collapse
- DEFAULT_HOST =
'http://localhost:11434/api'.freeze
Instance Method Summary collapse
- #chat(prompt, model:, options: {}) ⇒ Object
-
#initialize(api_key: nil, base_url: DEFAULT_HOST) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key: nil, base_url: DEFAULT_HOST) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fast_deepseek/client.rb', line 11 def initialize(api_key: nil, base_url: DEFAULT_HOST) @api_key = api_key || ENV['DEEPSEEK_API_KEY'] raise "DEEPSEEK_API_KEY is missing! Set it in the .env file or pass it explicitly." unless @api_key @base_url = base_url @logger = Logger.new($stdout) @conn = Faraday.new(url: base_url) do |faraday| faraday.adapter Faraday.default_adapter faraday.headers['Content-Type'] = 'application/json' end end |
Instance Method Details
#chat(prompt, model:, options: {}) ⇒ Object
24 25 26 |
# File 'lib/fast_deepseek/client.rb', line 24 def chat(prompt, model: , options: {}) request('chat', { model: model, messages: [{ role: 'user', content: prompt }], stream: false }.merge()) end |