Class: Dify::CompletionClient

Inherits:
Client
  • Object
show all
Defined in:
lib/dify/completion_client.rb

Instance Method Summary collapse

Methods inherited from Client

#_send_request, #get_application_parameters, #initialize, #message_feedback

Constructor Details

This class inherits a constructor from Dify::Client

Instance Method Details

#create_completion_message(parameters = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
# File 'lib/dify/completion_client.rb', line 5

def create_completion_message(parameters = {}, &block)
  raise ArgumentError, "Invalid parameters" unless parameters.is_a?(Hash)
  raise ArgumentError, "Invalid user" unless parameters[:user]
  raise ArgumentError, "Invalid inputs" unless parameters[:inputs]

  parameters[:response_mode] ||= "streaming"
  stream = parameters[:response_mode] == "streaming"
  _send_request("POST", "/completion-messages", parameters, nil, stream, &block)
end