Welcome to the DifyClient gem! This gem provides a Ruby client for interacting with the Dify.ai API. It allows you to perform various actions such as sending requests, providing feedback, creating completion messages, managing conversations, and more.
Add this line to your application's Gemfile:
gem 'dify_client'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install dify_client
To use the DifyClient gem, follow these steps:
1 Require the gem:
require 'dify_client'
2 Create a new client instance:
api_key = 'YOUR_API_KEY'
client = DifyClient::Client.new(api_key)
3 Use the available methods to interact with the Dify.ai API. Here are the methods provided by the DifyClient::Client class:
client.message_feedback(message_id, rating, user)
Submits feedback for a specific message identified by message_id
. The rating
parameter should be the rating value, and user
is the user identifier.
client.get_application_parameters(user)
client.create_completion_message(inputs, query, user, stream = false)
Creates a completion message with the provided inputs
, query
, and user
. The stream parameter is optional and set to false
by default. Set it to true
to enable streaming response mode.
client.create_chat_message(inputs, query, user, stream = false, conversation_id = nil)
Creates a chat message with the provided inputs
, query
, and user
. The stream parameter is optional and set to false
by default. Set it to true
to enable streaming response mode. The conversation_id
parameter is optional and can be used to specify the conversation ID.
client.get_conversations(user, first_id = nil, limit = nil, pinned = nil)
Retrieves the conversations for a given user
. You can provide first_id
, limit
, and pinned
parameters to customize the retrieval.
client.rename_conversation(conversation_id, name, user)
Renames a conversation identified by conversation_id with the provided
namefor the given
user`.
client.delete_conversation(conversation_id, user)
Deletes a conversation identified by conversation_id
for the given user
.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/langgenius/dify/issues.
The gem is available as open source under the terms of the MIT License.