discord-chat-gpt
Advanced tools
Comparing version 1.0.2 to 1.1.2
36
index.js
@@ -11,29 +11,29 @@ import { Configuration, OpenAIApi } from "openai"; | ||
this.apiKey = options.apiKey; | ||
this.configuration = new Configuration({ | ||
organization: this.orgKey, | ||
apiKey: this.apiKey, | ||
}); | ||
this.openai = new OpenAIApi(this.configuration); | ||
} | ||
async chat(content, requester) { | ||
const configuration = new Configuration({ | ||
organization: this.orgKey, | ||
apiKey: this.apiKey, | ||
}); | ||
const openai = new OpenAIApi(configuration); | ||
let response = await openai | ||
.createCompletion({ | ||
if (!content || !requester) { | ||
throw new Error("Content and requester cannot be null or undefined"); | ||
} | ||
try { | ||
let response = await this.openai.createCompletion({ | ||
model: "davinci", | ||
prompt: `ChatGPT is a friendly chatbot. \n\ | ||
ChatGPT : Hello, how are you?\n\ | ||
${requester}: ${content}\n\ | ||
ChatGPT:`, | ||
ChatGPT : Hello, how are you?\n\ | ||
${requester}: ${content}\n\ | ||
ChatGPT:`, | ||
temperature: 0.9, | ||
max_tokens: 100, | ||
stop: ["ChatGPT:", "Kabir Jaipal:"], | ||
}) | ||
.then((res) => { | ||
return res.data.choices.at(0).text; | ||
}) | ||
.catch((e) => { | ||
return e.message; | ||
}); | ||
return response; | ||
return response.data.choices.at(0).text; | ||
} catch (error) { | ||
throw new Error(`Failed to complete API call: ${error.message}`); | ||
} | ||
} | ||
@@ -40,0 +40,0 @@ } |
{ | ||
"name": "discord-chat-gpt", | ||
"version": "1.0.2", | ||
"version": "1.1.2", | ||
"description": "Chat-GPT Chat Bot For Discord", | ||
@@ -36,4 +36,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"discord.js": "^14.7.1", | ||
"openai": "^3.1.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4009
26
2
+ Addeddiscord.js@^14.7.1
+ Added@discordjs/builders@1.9.0(transitive)
+ Added@discordjs/collection@1.5.32.1.1(transitive)
+ Added@discordjs/formatters@0.5.0(transitive)
+ Added@discordjs/rest@2.4.0(transitive)
+ Added@discordjs/util@1.1.1(transitive)
+ Added@discordjs/ws@1.1.1(transitive)
+ Added@sapphire/async-queue@1.5.3(transitive)
+ Added@sapphire/shapeshift@4.0.0(transitive)
+ Added@sapphire/snowflake@3.5.3(transitive)
+ Added@types/node@22.5.5(transitive)
+ Added@types/ws@8.5.12(transitive)
+ Added@vladfrangu/async_event_emitter@2.4.6(transitive)
+ Addeddiscord-api-types@0.37.830.37.97(transitive)
+ Addeddiscord.js@14.16.2(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlodash.snakecase@4.1.1(transitive)
+ Addedmagic-bytes.js@1.10.0(transitive)
+ Addedts-mixer@6.0.4(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedundici@6.19.8(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedws@8.18.0(transitive)