Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,46 @@ GEM
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
ast (2.4.3)
bigdecimal (3.1.9)
crack (1.0.0)
bigdecimal
rexml
hashdiff (1.1.2)
json (2.10.1)
json (2.10.2)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
minitest (5.25.4)
minitest (5.25.5)
parallel (1.26.3)
parser (3.3.7.1)
parser (3.3.7.4)
ast (~> 2.4.1)
racc
prism (1.4.0)
public_suffix (6.0.1)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.10.0)
rexml (3.4.1)
rubocop (1.73.1)
rubocop (1.75.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.1)
parser (>= 3.3.1.0)
rubocop-ast (1.44.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
ruby-progressbar (1.13.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
webmock (3.25.0)
webmock (3.25.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand All @@ -62,4 +64,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.6.5
2.6.7
16 changes: 8 additions & 8 deletions lib/dify/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ def message_feedback(message_id, rating, user)
rating: rating,
user: user
}
_send_request("POST", "/messages/#{message_id}/feedbacks", data)
_send_request("POST", "/messages/#{message_id}/feedbacks", data, stream: false)
end

def get_application_parameters(user)
params = { user: user }
_send_request("GET", "/parameters", nil, params)
_send_request("GET", "/parameters", nil, params, stream: false)
end

def update_api_key(new_key)
Expand All @@ -27,7 +27,7 @@ def update_api_key(new_key)

private

def _send_request(method, endpoint, data = nil, params = nil, _stream: false)
def _send_request(method, endpoint, data = nil, params = nil, stream: false)
uri = URI.parse("#{@base_url}#{endpoint}")

http = Net::HTTP.new(uri.host, uri.port)
Expand Down Expand Up @@ -58,7 +58,7 @@ def create_completion_message(inputs, query, response_mode, user)
response_mode: response_mode,
user: user
}
_send_request("POST", "/completion-messages", data, nil, response_mode == "streaming")
_send_request("POST", "/completion-messages", data, nil, stream: response_mode == "streaming")
end
end

Expand All @@ -72,7 +72,7 @@ def create_chat_message(inputs, query, user, response_mode = "blocking", convers
}
data[:conversation_id] = conversation_id if conversation_id

_send_request("POST", "/chat-messages", data, nil, response_mode == "streaming")
_send_request("POST", "/chat-messages", data, nil, stream: response_mode == "streaming")
end

def get_conversation_messages(user, conversation_id = nil, first_id = nil, limit = nil)
Expand All @@ -81,16 +81,16 @@ def get_conversation_messages(user, conversation_id = nil, first_id = nil, limit
params[:first_id] = first_id if first_id
params[:limit] = limit if limit

_send_request("GET", "/messages", nil, params)
_send_request("GET", "/messages", nil, params, stream: false)
end

def get_conversations(user, last_id = nil, limit = nil, pinned = nil)
params = { user: user, last_id: last_id, limit: limit, pinned: pinned }
_send_request("GET", "/conversations", nil, params)
_send_request("GET", "/conversations", nil, params, stream: false)
end

def rename_conversation(conversation_id, name, user)
data = { name: name, user: user }
_send_request("POST", "/conversations/#{conversation_id}/name", data)
_send_request("POST", "/conversations/#{conversation_id}/name", data, stream: false)
end
end
Loading