From 74033bf2f1b3a1a3ac6a3fc433a8365a2e95b91e Mon Sep 17 00:00:00 2001 From: crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Fri, 12 May 2023 13:57:27 +0800 Subject: [PATCH 1/4] Update README.md --- sdks/nodejs-client/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdks/nodejs-client/README.md b/sdks/nodejs-client/README.md index 546b0d5a59..10a281ceb8 100644 --- a/sdks/nodejs-client/README.md +++ b/sdks/nodejs-client/README.md @@ -13,8 +13,7 @@ After installing the SDK, you can use it in your project like this: import { LangGeniusClient, ChatClient, CompletionClient } from 'langgenius-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) @@ -44,4 +43,4 @@ langGeniusClient.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. ## License -This SDK is released under the MIT License. \ No newline at end of file +This SDK is released under the MIT License. From ee46a563dac59c49be1408ce6b9da508e6ace137 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 14 May 2023 16:50:09 +0800 Subject: [PATCH 2/4] 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" ], From 57e73430388542349e62662d34a8c38fa3af63cc Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 14 May 2023 17:04:47 +0800 Subject: [PATCH 3/4] fix: default base url --- sdks/nodejs-client/index.js | 2 +- sdks/nodejs-client/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/nodejs-client/index.js b/sdks/nodejs-client/index.js index 6da97269c1..e948fff5bb 100644 --- a/sdks/nodejs-client/index.js +++ b/sdks/nodejs-client/index.js @@ -1,6 +1,6 @@ import axios from 'axios' -const BASE_URL = 'https://api.dify.ai/v1' +const BASE_URL = 'https://api.dify.ai/v1/' const routes = { application: { diff --git a/sdks/nodejs-client/package.json b/sdks/nodejs-client/package.json index 8c9ee97cf8..f813990741 100644 --- a/sdks/nodejs-client/package.json +++ b/sdks/nodejs-client/package.json @@ -1,6 +1,6 @@ { "name": "dify-client", - "version": "1.0.1", + "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", From fd6225b112b0c83ebf1181e1b15312f47482c4e3 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 14 May 2023 17:11:14 +0800 Subject: [PATCH 4/4] chore: fix url path --- sdks/nodejs-client/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/nodejs-client/index.js b/sdks/nodejs-client/index.js index e948fff5bb..902ecbd880 100644 --- a/sdks/nodejs-client/index.js +++ b/sdks/nodejs-client/index.js @@ -1,11 +1,11 @@ import axios from 'axios' -const BASE_URL = 'https://api.dify.ai/v1/' +const BASE_URL = 'https://api.dify.ai/v1' const routes = { application: { method: 'GET', - url: () => `parameters` + url: () => `/parameters` }, feedback: { method: 'POST',