From ee46a563dac59c49be1408ce6b9da508e6ace137 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 14 May 2023 16:50:09 +0800 Subject: [PATCH] chore: npm package to dify --- sdks/nodejs-client/README.md | 16 ++++++++-------- sdks/nodejs-client/index.js | 8 ++++---- sdks/nodejs-client/package.json | 5 ++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/sdks/nodejs-client/README.md b/sdks/nodejs-client/README.md index 10a281ceb8..1bfd5f5e00 100644 --- a/sdks/nodejs-client/README.md +++ b/sdks/nodejs-client/README.md @@ -1,16 +1,16 @@ -# LangGenius 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. +# Dify Node.js SDK +This is the Node.js SDK for the Dify API, which allows you to easily integrate Dify into your Node.js applications. ## Install ```bash -npm install langgenius-client +npm install dify-client ``` ## Usage After installing the SDK, you can use it in your project like this: ```js -import { LangGeniusClient, ChatClient, CompletionClient } from 'langgenius-client' +import { DifyClient, ChatClient, CompletionClient } from 'dify-client' const API_KEY = 'your-api-key-here'; const user = `random-user-id`: @@ -32,15 +32,15 @@ chatClient.getConversationMessages(conversationId, user) chatClient.renameConversation(conversationId, name, user) -const langGeniusClient = new LangGeniusClient(API_KEY) +const client = new DifyClient(API_KEY) // Fetch application parameters -langGeniusClient.getApplicationParameters(user) +client.getApplicationParameters(user) // 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 This SDK is released under the MIT License. diff --git a/sdks/nodejs-client/index.js b/sdks/nodejs-client/index.js index 3407620417..6da97269c1 100644 --- a/sdks/nodejs-client/index.js +++ b/sdks/nodejs-client/index.js @@ -31,10 +31,10 @@ const routes = { method: 'PATCH', url: (conversationId) => `/conversations/${conversationId}`, } - + } -export class LangGeniusClient { +export class DifyClient { constructor(apiKey, baseUrl = BASE_URL) { this.apiKey = apiKey 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) { const data = { 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) { const data = { inputs, diff --git a/sdks/nodejs-client/package.json b/sdks/nodejs-client/package.json index 72e3760c6c..8c9ee97cf8 100644 --- a/sdks/nodejs-client/package.json +++ b/sdks/nodejs-client/package.json @@ -1,11 +1,10 @@ { - "name": "langgenius-client", - "version": "1.1.1", + "name": "dify-client", + "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.", "main": "index.js", "type": "module", "keywords": [ - "LangGenius", "Dify.AI", "LLM" ],