Skip to content

Commit d178edd

Browse files
authored
Merge pull request #3 from CodeRifle/feat/llm-chat-integration
Add system prompt for LLM chatbot
2 parents 8b07647 + 3826900 commit d178edd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ <h2>Get In Touch</h2>
124124
if (typeof window.LanguageModel === 'undefined') {
125125
console.log("Mocking LanguageModel for development purposes.");
126126
window.LanguageModel = {
127-
create: async () => {
127+
create: async (config) => {
128128
console.log("Mock LanguageModel.create() called");
129+
if (config?.initialPrompts?.[0]?.content) {
130+
console.log("Mock LanguageModel received system prompt:", config.initialPrompts[0].content);
131+
}
129132
return {
130133
prompt: async (message) => {
131134
console.log(`Mock session.prompt() called with: "${message}"`);

script.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ async function initializeSession() {
3030
try {
3131
// Assuming LanguageModel is available globally e.g. via a <script> tag
3232
if (window.LanguageModel && typeof window.LanguageModel.create === 'function') {
33-
modelSession = await window.LanguageModel.create();
34-
console.log("LanguageModel session initialized.");
33+
const systemPromptConfig = {
34+
initialPrompts: [{
35+
role: 'system',
36+
content: `You are a specialized AI assistant for Rishabh Gupta's portfolio. Rishabh is an AI Engineer. Your primary functions are to:\n1. Provide information about Rishabh's background, passion for AI, and journey in the field.\n2. Detail Rishabh's skills, including machine learning (PyTorch, TensorFlow), deep learning, natural language processing (NLTK, SpaCy), computer vision (OpenCV, YOLO), LLMs, Python, JavaScript, and cloud platforms (AWS, GCP).\n3. Describe Rishabh's projects, such as 'Project Alpha' (data analytics), 'Project Beta' (NLP engine for sentiment analysis), and 'Project Gamma' (computer vision for object detection), highlighting the technologies used.\n4. Encourage users to explore the different sections of the website (Home, About, Projects, Skills, Contact).\n5. If asked for opinions or information outside of Rishabh's professional context as presented on the site, politely decline and redirect to portfolio-related topics. Maintain a professional, helpful, and enthusiastic tone.`
37+
}],
38+
};
39+
modelSession = await window.LanguageModel.create(systemPromptConfig);
40+
console.log("LanguageModel session initialized with system prompt.");
3541
} else {
3642
console.error("LanguageModel library not found or 'create' method is missing.");
3743
addMessage("Error: Chat functionality is currently unavailable. LanguageModel library not found.", false);

0 commit comments

Comments
 (0)