├── .gitignore
├── README.md
└── ai.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 | replay_pid*
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AI
2 | Messenger OpenAI Code
3 |
4 | [](http://www.msrtanim.xyz)
5 |
6 | use this .js file on your messenger bot file name "ai.js". then restart your messenger bot. After turn on bot go messenger group and ask any question with question mark (?). Then the Messenger bot will reply you the answer.
7 |
8 | Thank You
9 |
10 |
Connect with me:
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ai.js:
--------------------------------------------------------------------------------
1 | module.exports.config = {
2 | name: "ai",
3 | version: "2.0.8",
4 | hasPermssion: 0,
5 | credits: "MSRTanim",
6 | description: "AI",
7 | commandCategory: "ai",
8 | usages: "cmdname [question]",
9 | cooldowns: 5,
10 | dependencies: {
11 | "openai": ""
12 | }
13 | };
14 | module.exports.run = async function({ api, event, args }) {
15 |
16 |
17 | const { Configuration, OpenAIApi } = require("openai");
18 | const configuration = new Configuration({
19 | apiKey: "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",
20 | });
21 | const openai = new OpenAIApi(configuration);
22 | let data = args.join(" ");
23 | if (data.length < 2) {
24 | api.sendMessage("⚠️ Invalid Use Of Command!\n💡 Usage: /ai )", event.threadID);
25 | } else {
26 | try {
27 | const completion = await openai.createCompletion({
28 | model: "text-davinci-002",
29 | prompt: args.join(" "),
30 | temperature: 0.5,
31 | max_tokens: 2000,
32 | top_p: 0.3,
33 | frequency_penalty: 0.5,
34 | presence_penalty: 0.0,
35 | });
36 | api.sendMessage(completion.data.choices[0].text, event.threadID, event.messageID);
37 | }
38 | catch (error) {
39 | if (error.response) {
40 | console.log(error.response.status);
41 | console.log(error.response.data);
42 | } else {
43 | console.log(error.message);
44 | api.sendMessage(error.message, event.threadID);
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------