chore: npm package to dify

pull/2/head
Joel 3 years ago
parent 74033bf2f1
commit ee46a563da

@ -1,16 +1,16 @@
# LangGenius Node.js SDK # Dify Node.js SDK
This is the Node.js SDK for the LangGenius API, which allows you to easily integrate LangGenius into your Node.js applications. This is the Node.js SDK for the Dify API, which allows you to easily integrate Dify into your Node.js applications.
## Install ## Install
```bash ```bash
npm install langgenius-client npm install dify-client
``` ```
## Usage ## Usage
After installing the SDK, you can use it in your project like this: After installing the SDK, you can use it in your project like this:
```js ```js
import { LangGeniusClient, ChatClient, CompletionClient } from 'langgenius-client' import { DifyClient, ChatClient, CompletionClient } from 'dify-client'
const API_KEY = 'your-api-key-here'; const API_KEY = 'your-api-key-here';
const user = `random-user-id`: const user = `random-user-id`:
@ -32,15 +32,15 @@ chatClient.getConversationMessages(conversationId, user)
chatClient.renameConversation(conversationId, name, user) chatClient.renameConversation(conversationId, name, user)
const langGeniusClient = new LangGeniusClient(API_KEY) const client = new DifyClient(API_KEY)
// Fetch application parameters // Fetch application parameters
langGeniusClient.getApplicationParameters(user) client.getApplicationParameters(user)
// Provide feedback for a message // Provide feedback for a message
langGeniusClient.messageFeedback(messageId, rating, user) client.messageFeedback(messageId, rating, user)
``` ```
Replace 'your-api-key-here' with your actual LangGenius API key.Replace 'your-app-id-here' with your actual LangGenius APP ID. Replace 'your-api-key-here' with your actual Dify API key.Replace 'your-app-id-here' with your actual Dify APP ID.
## License ## License
This SDK is released under the MIT License. This SDK is released under the MIT License.

@ -31,10 +31,10 @@ const routes = {
method: 'PATCH', method: 'PATCH',
url: (conversationId) => `/conversations/${conversationId}`, url: (conversationId) => `/conversations/${conversationId}`,
} }
} }
export class LangGeniusClient { export class DifyClient {
constructor(apiKey, baseUrl = BASE_URL) { constructor(apiKey, baseUrl = BASE_URL) {
this.apiKey = apiKey this.apiKey = apiKey
this.baseUrl = baseUrl this.baseUrl = baseUrl
@ -86,7 +86,7 @@ export class LangGeniusClient {
} }
} }
export class CompletionClient extends LangGeniusClient { export class CompletionClient extends DifyClient {
createCompletionMessage(inputs, query, user, responseMode) { createCompletionMessage(inputs, query, user, responseMode) {
const data = { const data = {
inputs, inputs,
@ -98,7 +98,7 @@ export class CompletionClient extends LangGeniusClient {
} }
} }
export class ChatClient extends LangGeniusClient { export class ChatClient extends DifyClient {
createChatMessage(inputs, query, user, responseMode = 'blocking', conversationId = null) { createChatMessage(inputs, query, user, responseMode = 'blocking', conversationId = null) {
const data = { const data = {
inputs, inputs,

@ -1,11 +1,10 @@
{ {
"name": "langgenius-client", "name": "dify-client",
"version": "1.1.1", "version": "1.0.1",
"description": "This is the Node.js SDK for the Dify.AI API, which allows you to easily integrate Dify.AI into your Node.js applications.", "description": "This is the Node.js SDK for the Dify.AI API, which allows you to easily integrate Dify.AI into your Node.js applications.",
"main": "index.js", "main": "index.js",
"type": "module", "type": "module",
"keywords": [ "keywords": [
"LangGenius",
"Dify.AI", "Dify.AI",
"LLM" "LLM"
], ],

Loading…
Cancel
Save