You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Dify Node.js SDK
  2. This is the Node.js SDK for the Dify API, which allows you to easily integrate Dify into your Node.js applications.
  3. ## Install
  4. ```bash
  5. npm install dify-client
  6. ```
  7. ## Usage
  8. After installing the SDK, you can use it in your project like this:
  9. ```js
  10. import { DifyClient, ChatClient, CompletionClient } from 'dify-client'
  11. const API_KEY = 'your-api-key-here';
  12. const user = `random-user-id`;
  13. // Create a completion client
  14. const completionClient = new CompletionClient(API_KEY)
  15. // Create a completion message
  16. completionClient.createCompletionMessage(inputs, query, responseMode, user)
  17. // Create a chat client
  18. const chatClient = new ChatClient(API_KEY)
  19. // Create a chat message
  20. chatClient.createChatMessage(inputs, query, responseMode, user, conversationId)
  21. // Fetch conversations
  22. chatClient.getConversations(user)
  23. // Fetch conversation messages
  24. chatClient.getConversationMessages(conversationId, user)
  25. // Rename conversation
  26. chatClient.renameConversation(conversationId, name, user)
  27. const client = new DifyClient(API_KEY)
  28. // Fetch application parameters
  29. client.getApplicationParameters(user)
  30. // Provide feedback for a message
  31. client.messageFeedback(messageId, rating, user)
  32. ```
  33. Replace 'your-api-key-here' with your actual Dify API key.Replace 'your-app-id-here' with your actual Dify APP ID.
  34. ## License
  35. This SDK is released under the MIT License.