создай лусгий чат для ИИ ассистена по фонкцииям
Browse files- chat.html +8 -133
- components/ai-chat.js +222 -0
- index.html +1 -0
- style.css +0 -24
- tools.html +2 -1
chat.html
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
|
@@ -9,139 +10,13 @@
|
|
| 9 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
-
<
|
| 13 |
-
|
| 14 |
-
<
|
| 15 |
-
|
| 16 |
-
<
|
| 17 |
-
<button onclick="setContext('debugging')" class="px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700">Debugging</button>
|
| 18 |
-
<button onclick="setContext('automation')" class="px-3 py-1 bg-purple-600 text-white rounded hover:bg-purple-700">Automation</button>
|
| 19 |
-
</div>
|
| 20 |
-
<div id="chat-container" class="mb-4 p-4 border rounded-lg bg-gray-50 h-96 overflow-y-auto">
|
| 21 |
-
<!-- Chat messages will appear here -->
|
| 22 |
-
</div>
|
| 23 |
-
<div class="flex">
|
| 24 |
-
<input type="text" id="user-input" placeholder="Type your message or command..." class="flex-1 p-2 border rounded-l-lg">
|
| 25 |
-
<button onclick="sendMessage()" class="bg-blue-500 text-white p-2 rounded-r-lg hover:bg-blue-600">Send</button>
|
| 26 |
-
</div>
|
| 27 |
-
<div class="mt-4 grid grid-cols-2 gap-2">
|
| 28 |
-
<button onclick="insertCommand('/explain')" class="px-2 py-1 bg-gray-200 rounded text-sm hover:bg-gray-300">/explain</button>
|
| 29 |
-
<button onclick="insertCommand('/code')" class="px-2 py-1 bg-gray-200 rounded text-sm hover:bg-gray-300">/code</button>
|
| 30 |
-
<button onclick="insertCommand('/api')" class="px-2 py-1 bg-gray-200 rounded text-sm hover:bg-gray-300">/api</button>
|
| 31 |
-
<button onclick="insertCommand('/fix')" class="px-2 py-1 bg-gray-200 rounded text-sm hover:bg-gray-300">/fix</button>
|
| 32 |
-
</div>
|
| 33 |
-
<div class="mt-4">
|
| 34 |
-
<a href="tools.html" class="text-blue-500 hover:underline">Explore Development Tools & SDKs</a>
|
| 35 |
</div>
|
| 36 |
</div>
|
| 37 |
-
<script>
|
| 38 |
-
// Function to add a message to the chat
|
| 39 |
-
function addMessage(sender, text) {
|
| 40 |
-
const chatContainer = document.getElementById('chat-container');
|
| 41 |
-
const messageDiv = document.createElement('div');
|
| 42 |
-
messageDiv.classList.add('mb-2');
|
| 43 |
-
|
| 44 |
-
if (sender === 'user') {
|
| 45 |
-
messageDiv.classList.add('text-right');
|
| 46 |
-
messageDiv.innerHTML = `<div class="inline-block bg-blue-100 p-2 rounded-lg">${text}</div>`;
|
| 47 |
-
} else {
|
| 48 |
-
messageDiv.classList.add('text-left');
|
| 49 |
-
messageDiv.innerHTML = `<div class="inline-block bg-gray-100 p-2 rounded-lg">${text}</div>`;
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
chatContainer.appendChild(messageDiv);
|
| 53 |
-
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
// Function to send message to AI
|
| 57 |
-
async function sendMessage() {
|
| 58 |
-
const userInput = document.getElementById('user-input');
|
| 59 |
-
const message = userInput.value.trim();
|
| 60 |
-
|
| 61 |
-
if (message) {
|
| 62 |
-
// Add user message to chat
|
| 63 |
-
addMessage('user', message);
|
| 64 |
-
userInput.value = '';
|
| 65 |
-
|
| 66 |
-
try {
|
| 67 |
-
// Show typing indicator
|
| 68 |
-
const typingDiv = document.createElement('div');
|
| 69 |
-
typingDiv.id = 'typing-indicator';
|
| 70 |
-
typingDiv.classList.add('text-left', 'mb-2');
|
| 71 |
-
typingDiv.innerHTML = '<div class="inline-block bg-gray-100 p-2 rounded-lg">Thinking...</div>';
|
| 72 |
-
document.getElementById('chat-container').appendChild(typingDiv);
|
| 73 |
-
document.getElementById('chat-container').scrollTop = document.getElementById('chat-container').scrollHeight;
|
| 74 |
-
|
| 75 |
-
// Call AI API (using OpenAI-compatible API)
|
| 76 |
-
const response = await fetch('https://api.openai.com/v1/chat/completions', {
|
| 77 |
-
method: 'POST',
|
| 78 |
-
headers: {
|
| 79 |
-
'Content-Type': 'application/json',
|
| 80 |
-
'Authorization': 'Bearer YOUR_API_KEY_HERE' // Replace with your actual API key
|
| 81 |
-
},
|
| 82 |
-
body: JSON.stringify({
|
| 83 |
-
model: "gpt-3.5-turbo",
|
| 84 |
-
messages: [{role: "user", content: message}],
|
| 85 |
-
temperature: 0.7
|
| 86 |
-
})
|
| 87 |
-
});
|
| 88 |
-
|
| 89 |
-
// Remove typing indicator
|
| 90 |
-
document.getElementById('typing-indicator').remove();
|
| 91 |
-
|
| 92 |
-
if (response.ok) {
|
| 93 |
-
const data = await response.json();
|
| 94 |
-
const aiResponse = data.choices[0].message.content.trim();
|
| 95 |
-
addMessage('ai', aiResponse);
|
| 96 |
-
} else {
|
| 97 |
-
addMessage('ai', 'Sorry, I encountered an error. Please try again.');
|
| 98 |
-
}
|
| 99 |
-
} catch (error) {
|
| 100 |
-
// Remove typing indicator
|
| 101 |
-
if (document.getElementById('typing-indicator')) {
|
| 102 |
-
document.getElementById('typing-indicator').remove();
|
| 103 |
-
}
|
| 104 |
-
addMessage('ai', 'Sorry, I encountered an error. Please try again.');
|
| 105 |
-
}
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
// Allow sending message with Enter key
|
| 110 |
-
document.getElementById('user-input').addEventListener('keypress', function(e) {
|
| 111 |
-
if (e.key === 'Enter') {
|
| 112 |
-
sendMessage();
|
| 113 |
-
}
|
| 114 |
-
});
|
| 115 |
-
let currentContext = 'general';
|
| 116 |
-
|
| 117 |
-
function setContext(context) {
|
| 118 |
-
currentContext = context;
|
| 119 |
-
addMessage('system', `Context set to ${context} mode`);
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
function insertCommand(command) {
|
| 123 |
-
const input = document.getElementById('user-input');
|
| 124 |
-
input.value = command + ' ';
|
| 125 |
-
input.focus();
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
// Initial welcome message with references
|
| 129 |
-
window.onload = function() {
|
| 130 |
-
addMessage('ai', `👋 Welcome to DevAssistant!
|
| 131 |
-
I can help with:
|
| 132 |
-
- API Integrations (REST, GraphQL, WebSockets)
|
| 133 |
-
- Debugging (Chrome DevTools, Wireshark)
|
| 134 |
-
- Security (Burp Suite, OWASP ZAP)
|
| 135 |
-
- Automation (Selenium, Puppeteer)
|
| 136 |
-
|
| 137 |
-
Try commands like:
|
| 138 |
-
• /explain [concept] - Get detailed explanations
|
| 139 |
-
• /code [language] - Generate code samples
|
| 140 |
-
• /api [service] - Get API integration help
|
| 141 |
-
• /fix [error] - Debug and fix issues
|
| 142 |
-
|
| 143 |
-
Or click the context buttons above!`);
|
| 144 |
-
};
|
| 145 |
-
</script>
|
| 146 |
</body>
|
| 147 |
-
</html>
|
|
|
|
| 1 |
+
|
| 2 |
<!DOCTYPE html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
|
|
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
</head>
|
| 12 |
<body>
|
| 13 |
+
<ai-chat></ai-chat>
|
| 14 |
+
<div class="card mt-4 text-center">
|
| 15 |
+
<a href="tools.html" class="text-blue-500 hover:underline">Explore Development Tools & SDKs</a>
|
| 16 |
+
<div class="mt-2">
|
| 17 |
+
<a href="index.html" class="text-blue-500 hover:underline">← Back to Home</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
</div>
|
| 19 |
</div>
|
| 20 |
+
<script src="components/ai-chat.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
display: block;
|
| 8 |
+
max-width: 720px;
|
| 9 |
+
margin: 0 auto;
|
| 10 |
+
padding: 20px;
|
| 11 |
+
border: 1px solid #e5e7eb;
|
| 12 |
+
border-radius: 12px;
|
| 13 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 14 |
+
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
| 15 |
+
}
|
| 16 |
+
.header {
|
| 17 |
+
font-size: 16px;
|
| 18 |
+
margin-top: 0;
|
| 19 |
+
margin-bottom: 10px;
|
| 20 |
+
}
|
| 21 |
+
.description {
|
| 22 |
+
color: rgb(107, 114, 128);
|
| 23 |
+
font-size: 15px;
|
| 24 |
+
margin-bottom: 20px;
|
| 25 |
+
}
|
| 26 |
+
.context-buttons {
|
| 27 |
+
display: flex;
|
| 28 |
+
flex-wrap: wrap;
|
| 29 |
+
gap: 8px;
|
| 30 |
+
margin-bottom: 16px;
|
| 31 |
+
}
|
| 32 |
+
.context-button {
|
| 33 |
+
padding: 6px 12px;
|
| 34 |
+
border: none;
|
| 35 |
+
border-radius: 6px;
|
| 36 |
+
font-size: 14px;
|
| 37 |
+
font-weight: 500;
|
| 38 |
+
cursor: pointer;
|
| 39 |
+
transition: all 0.2s;
|
| 40 |
+
}
|
| 41 |
+
.context-button:hover {
|
| 42 |
+
opacity: 0.9;
|
| 43 |
+
}
|
| 44 |
+
.chat-container {
|
| 45 |
+
margin-bottom: 16px;
|
| 46 |
+
padding: 16px;
|
| 47 |
+
border: 1px solid #e5e7eb;
|
| 48 |
+
border-radius: 8px;
|
| 49 |
+
background: #f9fafb;
|
| 50 |
+
height: 384px;
|
| 51 |
+
overflow-y: auto;
|
| 52 |
+
font-family: 'SF Mono', 'Roboto Mono', monospace;
|
| 53 |
+
font-size: 14px;
|
| 54 |
+
}
|
| 55 |
+
.message {
|
| 56 |
+
margin-bottom: 8px;
|
| 57 |
+
max-width: 80%;
|
| 58 |
+
}
|
| 59 |
+
.user-message {
|
| 60 |
+
margin-left: auto;
|
| 61 |
+
text-align: right;
|
| 62 |
+
}
|
| 63 |
+
.ai-message {
|
| 64 |
+
margin-right: auto;
|
| 65 |
+
text-align: left;
|
| 66 |
+
}
|
| 67 |
+
.message-content {
|
| 68 |
+
display: inline-block;
|
| 69 |
+
padding: 10px 12px;
|
| 70 |
+
border-radius: 8px;
|
| 71 |
+
}
|
| 72 |
+
.user-message .message-content {
|
| 73 |
+
background: #ebf5ff;
|
| 74 |
+
border-right: 3px solid #2563eb;
|
| 75 |
+
}
|
| 76 |
+
.ai-message .message-content {
|
| 77 |
+
background: #f3f4f6;
|
| 78 |
+
border-left: 3px solid #3b82f6;
|
| 79 |
+
}
|
| 80 |
+
.input-area {
|
| 81 |
+
display: flex;
|
| 82 |
+
}
|
| 83 |
+
.message-input {
|
| 84 |
+
flex: 1;
|
| 85 |
+
padding: 8px 12px;
|
| 86 |
+
border: 1px solid #e5e7eb;
|
| 87 |
+
border-radius: 8px 0 0 8px;
|
| 88 |
+
font-size: 14px;
|
| 89 |
+
}
|
| 90 |
+
.send-button {
|
| 91 |
+
padding: 8px 16px;
|
| 92 |
+
background: #3b82f6;
|
| 93 |
+
color: white;
|
| 94 |
+
border: none;
|
| 95 |
+
border-radius: 0 8px 8px 0;
|
| 96 |
+
cursor: pointer;
|
| 97 |
+
}
|
| 98 |
+
.send-button:hover {
|
| 99 |
+
background: #2563eb;
|
| 100 |
+
}
|
| 101 |
+
.command-buttons {
|
| 102 |
+
display: grid;
|
| 103 |
+
grid-template-columns: repeat(2, 1fr);
|
| 104 |
+
gap: 8px;
|
| 105 |
+
margin-top: 16px;
|
| 106 |
+
}
|
| 107 |
+
.command-button {
|
| 108 |
+
padding: 8px 12px;
|
| 109 |
+
background: #f3f4f6;
|
| 110 |
+
border: none;
|
| 111 |
+
border-radius: 6px;
|
| 112 |
+
font-size: 14px;
|
| 113 |
+
cursor: pointer;
|
| 114 |
+
}
|
| 115 |
+
.command-button:hover {
|
| 116 |
+
background: #e5e7eb;
|
| 117 |
+
}
|
| 118 |
+
.typing-indicator {
|
| 119 |
+
text-align: left;
|
| 120 |
+
margin-bottom: 8px;
|
| 121 |
+
}
|
| 122 |
+
.typing-indicator .message-content {
|
| 123 |
+
background: #f3f4f6;
|
| 124 |
+
border-left: 3px solid #3b82f6;
|
| 125 |
+
}
|
| 126 |
+
</style>
|
| 127 |
+
<h1 class="header">AI Development Assistant</h1>
|
| 128 |
+
<p class="description">Smart coding help and automation</p>
|
| 129 |
+
|
| 130 |
+
<div class="context-buttons">
|
| 131 |
+
<button class="context-button" style="background: #374151; color: white;" data-context="hacking">Hacking</button>
|
| 132 |
+
<button class="context-button" style="background: #3b82f6; color: white;" data-context="integration">Integration</button>
|
| 133 |
+
<button class="context-button" style="background: #10b981; color: white;" data-context="debugging">Debugging</button>
|
| 134 |
+
<button class="context-button" style="background: #8b5cf6; color: white;" data-context="automation">Automation</button>
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
<div class="chat-container" id="chatContainer">
|
| 138 |
+
<!-- Messages will be added here -->
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
<div class="input-area">
|
| 142 |
+
<input type="text" class="message-input" id="messageInput" placeholder="Type your message or command...">
|
| 143 |
+
<button class="send-button" id="sendButton">Send</button>
|
| 144 |
+
</div>
|
| 145 |
+
|
| 146 |
+
<div class="command-buttons">
|
| 147 |
+
<button class="command-button" data-command="/explain">/explain</button>
|
| 148 |
+
<button class="command-button" data-command="/code">/code</button>
|
| 149 |
+
<button class="command-button" data-command="/api">/api</button>
|
| 150 |
+
<button class="command-button" data-command="/fix">/fix</button>
|
| 151 |
+
</div>
|
| 152 |
+
`;
|
| 153 |
+
|
| 154 |
+
this.initializeChat();
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
initializeChat() {
|
| 158 |
+
this.currentContext = 'general';
|
| 159 |
+
this.chatContainer = this.shadowRoot.getElementById('chatContainer');
|
| 160 |
+
this.messageInput = this.shadowRoot.getElementById('messageInput');
|
| 161 |
+
this.sendButton = this.shadowRoot.getElementById('sendButton');
|
| 162 |
+
|
| 163 |
+
// Add event listeners
|
| 164 |
+
this.sendButton.addEventListener('click', () => this.sendMessage());
|
| 165 |
+
this.messageInput.addEventListener('keypress', (e) => {
|
| 166 |
+
if (e.key === 'Enter') {
|
| 167 |
+
this.sendMessage();
|
| 168 |
+
}
|
| 169 |
+
});
|
| 170 |
+
|
| 171 |
+
// Context buttons
|
| 172 |
+
const contextButtons = this.shadowRoot.querySelectorAll('.context-button');
|
| 173 |
+
contextButtons.forEach(button => {
|
| 174 |
+
button.addEventListener('click', () => {
|
| 175 |
+
this.setContext(button.dataset.context);
|
| 176 |
+
});
|
| 177 |
+
});
|
| 178 |
+
|
| 179 |
+
// Command buttons
|
| 180 |
+
const commandButtons = this.shadowRoot.querySelectorAll('.command-button');
|
| 181 |
+
commandButtons.forEach(button => {
|
| 182 |
+
button.addEventListener('click', () => {
|
| 183 |
+
this.insertCommand(button.dataset.command);
|
| 184 |
+
});
|
| 185 |
+
});
|
| 186 |
+
|
| 187 |
+
// Initial welcome message
|
| 188 |
+
this.addMessage('ai', `👋 Welcome to DevAssistant!
|
| 189 |
+
I can help with:
|
| 190 |
+
- API Integrations (REST, GraphQL, WebSockets)
|
| 191 |
+
- Debugging (Chrome DevTools, Wireshark)
|
| 192 |
+
- Security (Burp Suite, OWASP ZAP)
|
| 193 |
+
- Automation (Selenium, Puppeteer)
|
| 194 |
+
|
| 195 |
+
Try commands like:
|
| 196 |
+
• /explain [concept] - Get detailed explanations
|
| 197 |
+
• /code [language] - Generate code samples
|
| 198 |
+
• /api [service] - Get API integration help
|
| 199 |
+
• /fix [error] - Debug and fix issues
|
| 200 |
+
|
| 201 |
+
Or click the context buttons above!`);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
addMessage(sender, text) {
|
| 205 |
+
const messageDiv = document.createElement('div');
|
| 206 |
+
messageDiv.classList.add('message');
|
| 207 |
+
|
| 208 |
+
if (sender === 'user') {
|
| 209 |
+
messageDiv.classList.add('user-message');
|
| 210 |
+
messageDiv.innerHTML = `<div class="message-content">${this.escapeHtml(text)}</div>`;
|
| 211 |
+
} else {
|
| 212 |
+
messageDiv.classList.add('ai-message');
|
| 213 |
+
messageDiv.innerHTML = `<div class="message-content">${this.formatMessage(text)}</div>`;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
this.chatContainer.appendChild(messageDiv);
|
| 217 |
+
this.chatContainer.scrollTop = this.chatContainer.scrollHeight;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
formatMessage(text) {
|
| 221 |
+
// Simple formatting for code blocks
|
| 222 |
+
return text.replace(/
|
index.html
CHANGED
|
@@ -24,5 +24,6 @@
|
|
| 24 |
</a>
|
| 25 |
</div>
|
| 26 |
</div>
|
|
|
|
| 27 |
</body>
|
| 28 |
</html>
|
|
|
|
| 24 |
</a>
|
| 25 |
</div>
|
| 26 |
</div>
|
| 27 |
+
<script src="components/ai-chat.js"></script>
|
| 28 |
</body>
|
| 29 |
</html>
|
style.css
CHANGED
|
@@ -24,25 +24,6 @@ p {
|
|
| 24 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 25 |
}
|
| 26 |
|
| 27 |
-
#chat-container {
|
| 28 |
-
background: #f9fafb;
|
| 29 |
-
font-family: 'SF Mono', 'Roboto Mono', monospace;
|
| 30 |
-
font-size: 14px;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
#chat-container div[class*="bg-gray-100"] {
|
| 34 |
-
max-width: 80%;
|
| 35 |
-
background: #f3f4f6;
|
| 36 |
-
border-left: 3px solid #3b82f6;
|
| 37 |
-
padding: 10px 12px;
|
| 38 |
-
}
|
| 39 |
-
#chat-container div[class*="bg-blue-100"] {
|
| 40 |
-
max-width: 80%;
|
| 41 |
-
background: #ebf5ff;
|
| 42 |
-
border-right: 3px solid #2563eb;
|
| 43 |
-
padding: 10px 12px;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
/* IDE Cards */
|
| 47 |
ide-card {
|
| 48 |
margin-bottom: 1.5rem;
|
|
@@ -69,11 +50,6 @@ ide-card {
|
|
| 69 |
margin-right: 0.5rem;
|
| 70 |
margin-bottom: 0.5rem;
|
| 71 |
}
|
| 72 |
-
button[onclick^="setContext"] {
|
| 73 |
-
font-size: 14px;
|
| 74 |
-
font-weight: 500;
|
| 75 |
-
transition: all 0.2s;
|
| 76 |
-
}
|
| 77 |
.card p:last-child {
|
| 78 |
margin-bottom: 0;
|
| 79 |
}
|
|
|
|
| 24 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 25 |
}
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
/* IDE Cards */
|
| 28 |
ide-card {
|
| 29 |
margin-bottom: 1.5rem;
|
|
|
|
| 50 |
margin-right: 0.5rem;
|
| 51 |
margin-bottom: 0.5rem;
|
| 52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
.card p:last-child {
|
| 54 |
margin-bottom: 0;
|
| 55 |
}
|
tools.html
CHANGED
|
@@ -161,5 +161,6 @@
|
|
| 161 |
</div>
|
| 162 |
<script src="components/api-connector.js"></script>
|
| 163 |
<script src="components/ide-card.js"></script>
|
|
|
|
| 164 |
</body>
|
| 165 |
-
</html>
|
|
|
|
| 161 |
</div>
|
| 162 |
<script src="components/api-connector.js"></script>
|
| 163 |
<script src="components/ide-card.js"></script>
|
| 164 |
+
<script src="components/ai-chat.js"></script>
|
| 165 |
</body>
|
| 166 |
+
</html>
|