chore: npm package to dify

This commit is contained in:
Joel 2023-05-14 16:50:09 +08:00
parent 74033bf2f1
commit ee46a563da
3 changed files with 14 additions and 15 deletions

View File

@ -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.

View File

@ -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,

View File

@ -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"
],