-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Ririko HuggingChat Support (#245)
* Add support for Ririko HuggingChat Server * 0.12.0
- Loading branch information
1 parent
40872de
commit f746a20
Showing
6 changed files
with
85 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ririko", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"description": "Ririko - A powerful AI-powered general Discord bot that you can call your companion", | ||
"author": "Earnest Angel", | ||
"email": "[email protected]", | ||
|
@@ -89,8 +89,8 @@ | |
"pino-pretty": "^10.0.0", | ||
"pretty-ms": "^8.0.0", | ||
"quick.db": "^9.1.6", | ||
"redis": "^4.6.7", | ||
"replicate": "^0.17.0", | ||
"ririkohuggingchat-bot-client": "^1.0.1", | ||
"ririkollama-bot-client": "^1.0.0", | ||
"save-dev": "^0.0.1-security", | ||
"semver": "^7.5.3", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const {RirikoHuggingChatClient} = require("ririkohuggingchat-bot-client"); | ||
const {AIProviderBase} = require("app/Providers/AIProviderBase"); | ||
const config = require("config"); | ||
const getconfig = require("helpers/getconfig"); | ||
|
||
class RirikoHuggingChatProvider extends AIProviderBase { | ||
constructor() { | ||
super(); | ||
this.ririkoHuggingChatClient = new RirikoHuggingChatClient({ | ||
apiUrl: getconfig.localAIServerURL(), | ||
token: this.token = getconfig.AIToken(), | ||
settings: { | ||
} | ||
}); | ||
} | ||
|
||
getClient() { | ||
return this.ririkoHuggingChatClient; | ||
} | ||
|
||
/** | ||
* Send chat to NLP Cloud | ||
* @param {String} messageText | ||
* @param {String} context | ||
* @param {Array} history | ||
* @param discordMessage | ||
* @returns {Promise<*>} | ||
*/ | ||
async sendChat(messageText, context, history, discordMessage) { | ||
try { | ||
// Send request to NLP Cloud. | ||
const response = await this.ririkoHuggingChatClient.ask( | ||
messageText, | ||
discordMessage.author.username | ||
); | ||
|
||
if (typeof response.data["answer"] !== "undefined") { | ||
return response.data["answer"]; | ||
} else { | ||
return "(no response)"; | ||
} | ||
} catch (e) { | ||
throw e; | ||
} | ||
} | ||
} | ||
|
||
module.exports = {RirikoHuggingChatProvider}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters