diff --git a/sdks/nodejs-client/README.md b/sdks/nodejs-client/README.md index 546b0d5a59..1bfd5f5e00 100644 --- a/sdks/nodejs-client/README.md +++ b/sdks/nodejs-client/README.md @@ -1,20 +1,19 @@ -# 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 APP_ID = 'your-app-id-here'; -const user = `user_${APP_ID}:user_id`: +const user = `random-user-id`: // Create a completion client const completionClient = new CompletionClient(API_KEY) @@ -33,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. \ No newline at end of file +This SDK is released under the MIT License. diff --git a/sdks/nodejs-client/index.js b/sdks/nodejs-client/index.js index 4b142ce1c2..1ef43c3d1e 100644 --- a/sdks/nodejs-client/index.js +++ b/sdks/nodejs-client/index.js @@ -5,7 +5,7 @@ export const BASE_URL = 'https://api.dify.ai/v1' export const routes = { application: { method: 'GET', - url: () => `parameters` + url: () => `/parameters` }, feedback: { method: 'POST', @@ -33,7 +33,7 @@ export const routes = { } } -export class LangGeniusClient { +export class DifyClient { constructor(apiKey, baseUrl = BASE_URL) { this.apiKey = apiKey this.baseUrl = baseUrl @@ -85,7 +85,7 @@ export class LangGeniusClient { } } -export class CompletionClient extends LangGeniusClient { +export class CompletionClient extends DifyClient { createCompletionMessage(inputs, query, user, responseMode) { const data = { inputs, @@ -97,7 +97,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 b731299502..f815a104e7 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.2", "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" ],