Spaces:
Configuration error
Configuration error
File size: 1,092 Bytes
5641073 57ca32c 5641073 a408505 a66ab2d 5641073 a66ab2d 57ca32c 5641073 a66ab2d 5641073 a408505 5641073 a66ab2d 5641073 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
const TelegramBot = require('node-telegram-bot-api');
const axios = require('axios');
const telegramToken = '6935550366:AAFCn08aHQFBQxjQSfYCnbyxyzc5mZCKg9I';
const cloudflareToken = 'NB-sxyNA3JSyhezy2fUnTnXc3Pf7i8X17BJfBwLx';
const bot = new TelegramBot(telegramToken, {polling: true});
console.log('Load bot success..')
console.log('---------------------------------')
bot.on('message', (msg) => {
const chatId = msg.chat.id;
const userMessage = msg.text;
console.log("You: ", userMessage)
axios.post('https://api.cloudflare.com/client/v4/accounts/d888e02cee618e93b19cd9e7717da715/ai/run/@cf/mistral/mistral-7b-instruct-v0.1', {
prompt: userMessage
}, {
headers: {
'Authorization': `Bearer ${cloudflareToken}`
}
}).then(response => {
const aiResponse = response.data.result.response;
console.log('AI: ', aiResponse)
bot.sendMessage(chatId, aiResponse);
}).catch(error => {
bot.sendMessage(chatId, 'Something wrong please send again message!');
console.error(error);
});
console.log('---------------------------------')
}); |