akshit-sharma-cli
Version:
Personal CLI tool showcasing Akshit Sharma's AI/ML engineering profile
241 lines (203 loc) • 8.21 kB
JavaScript
import readline from 'readline';
import chalk from 'chalk';
import { marked } from 'marked';
import TerminalRenderer from 'marked-terminal';
import boxen from 'boxen';
import gradient from 'gradient-string';
// Configure marked to use terminal renderer
marked.setOptions({
renderer: new TerminalRenderer({
code: chalk.yellow,
blockquote: chalk.gray.italic,
html: chalk.gray,
heading: chalk.green.bold,
firstHeading: chalk.magenta.underline.bold,
hr: chalk.reset,
listitem: chalk.cyan,
list: (body) => chalk.cyan(body),
paragraph: chalk.white,
strong: chalk.bold.cyan,
em: chalk.italic.yellow,
codespan: chalk.yellow.dim
})
});
const AKSHIT_CONTEXT = `
You are an AI assistant representing Akshit Sharma, an AI/ML Engineering student.
You have comprehensive knowledge about his professional profile:
EDUCATION:
- B.Tech Computer Science (AI & Data Science Specialization)
- Maharaja Agrasen Institute of Technology
- CGPA: 8.96/10 (2022-2026)
RECENT ACHIEVEMENTS:
- Winner of AceCloud X RTDS Hackathon '25
- Developed multiple high-accuracy ML models (89-95% accuracy)
TECHNICAL SKILLS:
- Programming: Python (Advanced), C/C++, Java, JavaScript, SQL
- AI/ML: TensorFlow, PyTorch, BERT, Transformers, NLP, Computer Vision, RAG
- Cloud: Google Cloud Platform, AWS, OpenStack SDK
- Tools: Git, Linux, MongoDB, Docker, Kubernetes, Flask, React
KEY PROJECTS:
1. OpenStack Cloud Management System (87% accuracy, 300ms response time)
2. SignEase ASL Video Platform (89% accuracy, optimized latency)
3. Universal Website Chatbot (90% accuracy using fine-tuned Llama 3.1)
WORK EXPERIENCE:
- ML Intern at CodSoft (Aug-Sep 2024): Movie recommendation (92% accuracy)
- ML Intern at Cantilever.in (Jul-Aug 2024): BERT sentiment analysis (88% accuracy)
CONTACT:
- Email: akshitsharma7096@gmail.com
- Phone: +91 8810248097
- GitHub: https://github.com/akshit7093
- LinkedIn: https://linkedin.com/in/akshitsharma
- LeetCode: https://leetcode.com/akshitsharma
Format your responses using markdown when appropriate. Use **bold** for emphasis, *italics* for highlights, code for technical terms, and lists for organized information. Be professional and informative.'
`;
class AkshitChatbot {
constructor() {
this.proxyUrl = 'https://akshit-cli-backend-2ar59miuz-jokers-projects-741f992f.vercel.app/api/chat';
this.conversationHistory = [];
}
createInterface() {
return readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: chalk.cyan.bold('> ')
});
}
async generateResponse(userInput) {
try {
const payload = {
contextualPrompt: `${AKSHIT_CONTEXT}\n\nPrevious conversation:\n${this.conversationHistory.slice(-6).map(msg => `${msg.role}: ${msg.content}`).join('\n')}\n\nUser: ${userInput}\nAssistant:`
};
const response = await fetch(this.proxyUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`API request failed with status ${response.status}`);
}
const data = await response.json();
return data.response;
} catch (error) {
console.error(chalk.red('Error connecting to the chatbot service:', error.message));
return "I'm sorry, I'm having trouble connecting to my knowledge base right now. Please try again later.";
}
}
formatResponse(text) {
try {
// Parse markdown and render for terminal
const formatted = marked(text);
// Add some styling enhancements
return boxen(formatted, {
padding: 1,
margin: { top: 0, bottom: 1, left: 1, right: 1 },
borderStyle: 'round',
borderColor: 'blue',
backgroundColor: '#0a0a0a'
});
} catch (error) {
// Fallback to plain text if markdown parsing fails
return chalk.white(text);
}
}
async startChat() {
// Stylized welcome header
const title = gradient.rainbow.multiline(`
╔══════════════════════════════════════════════════╗
║ 🤖 AKSHIT'S AI ASSISTANT ║
║ Powered by Gemma AI ║
╚══════════════════════════════════════════════════╝`);
console.log('\n' + title);
console.log(boxen(
chalk.yellow.bold('Ask me anything about Akshit\'s:\n\n') +
chalk.white('• 🎓 Education & Academic achievements\n') +
chalk.white('• 💼 Work experience & internships\n') +
chalk.white('• 🚀 Projects & technical accomplishments\n') +
chalk.white('• 🔧 Technical skills & expertise\n') +
chalk.white('• 📧 Contact information\n') +
chalk.white('• 🏆 Recent achievements & hackathon wins\n\n') +
chalk.gray.italic('💡 I support markdown formatting in responses!\n') +
chalk.gray('Type "exit", "quit", or press Ctrl+C to end.'),
{
padding: 1,
margin: 1,
borderStyle: 'round',
borderColor: 'green',
backgroundColor: '#1a1a1a'
}
));
const rl = this.createInterface();
rl.prompt();
rl.on('line', async (input) => {
const userInput = input.trim();
if (userInput.toLowerCase() === 'exit' || userInput.toLowerCase() === 'quit') {
console.log(boxen(
chalk.yellow.bold('👋 Thanks for chatting!\n\n') +
chalk.white('Feel free to reach out to Akshit directly:\n') +
chalk.cyan('📧 akshitsharma7096@gmail.com\n') +
chalk.cyan('💼 linkedin.com/in/akshitsharma'),
{
padding: 1,
borderStyle: 'round',
borderColor: 'yellow',
textAlignment: 'center'
}
));
rl.close();
return;
}
if (userInput === '') {
rl.prompt();
return;
}
// Add user input to conversation history
this.conversationHistory.push({ role: 'user', content: userInput });
// Show thinking animation
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
let i = 0;
const thinking = setInterval(() => {
process.stdout.write(`\r${chalk.blue.bold('🤖 Assistant:')} ${chalk.gray(frames[i % frames.length] + ' thinking...')}`);
i++;
}, 100);
const response = await this.generateResponse(userInput);
// Clear thinking animation
clearInterval(thinking);
process.stdout.write('\r\x1b[K');
// Display formatted response
console.log(chalk.blue.bold('\n🤖 Assistant:'));
console.log(this.formatResponse(response));
// Add assistant response to conversation history
this.conversationHistory.push({ role: 'assistant', content: response });
// Keep conversation history manageable
if (this.conversationHistory.length > 20) {
this.conversationHistory = this.conversationHistory.slice(-16);
}
rl.prompt();
});
rl.on('close', () => {
console.log(chalk.gray('\n👋 Goodbye!\n'));
process.exit(0);
});
rl.on('SIGINT', () => {
console.log(boxen(
chalk.yellow.bold('\n👋 Thanks for using Akshit\'s AI assistant!\n\n') +
chalk.white('Connect with him for AI/ML collaborations!'),
{
padding: 1,
borderStyle: 'round',
borderColor: 'yellow',
textAlignment: 'center'
}
));
process.exit(0);
});
}
}
export { AkshitChatbot };
if (import.meta.url.startsWith('file:') && process.argv[1] === new URL(import.meta.url).pathname) {
const chatbot = new AkshitChatbot();
chatbot.startChat();
}