Class: ActiveGenie::Providers::DeepseekProvider
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- ActiveGenie::Providers::DeepseekProvider
- Defined in:
- lib/active_genie/providers/deepseek_provider.rb
Defined Under Namespace
Classes: InvalidResponseError
Constant Summary
Constants inherited from BaseProvider
BaseProvider::DEFAULT_HEADERS, BaseProvider::DEFAULT_MAX_RETRIES, BaseProvider::DEFAULT_OPEN_TIMEOUT, BaseProvider::DEFAULT_RETRY_DELAY, BaseProvider::DEFAULT_TIMEOUT
Instance Method Summary collapse
-
#function_calling(messages, function) ⇒ Hash?
Requests structured JSON output from the Deepseek model based on a schema.
Methods inherited from BaseProvider
#delete, #get, #initialize, #post, #put
Constructor Details
This class inherits a constructor from ActiveGenie::Providers::BaseProvider
Instance Method Details
#function_calling(messages, function) ⇒ Hash?
Requests structured JSON output from the Deepseek model based on a schema.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_genie/providers/deepseek_provider.rb', line 19 def function_calling(, function) payload = { messages:, tools: [function_to_tool(function)], tool_choice: { type: 'function', function: { name: function[:name] } }, stream: false, model: } response = retry_with_backoff do request(payload) end raise InvalidResponseError, "Invalid response: #{response}" if response.keys.empty? raise InvalidResponseError, 'Invalid response: empty' if response.nil? ActiveGenie.logger.call({ code: :function_calling, fine_tune: true, payload:, response: }, config: @config) response end |