Spaces:
Build error
Build error
T-K-O-H commited on
Commit ·
c1523e3
1
Parent(s): 8d7f3c1
Update HTML
Browse files- index.html +125 -28
index.html
CHANGED
|
@@ -4,37 +4,134 @@
|
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
-
<title>
|
| 8 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
-
<
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
<
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
<
|
| 19 |
-
|
| 20 |
-
<div class="message-input">
|
| 21 |
-
<form id="message-form">
|
| 22 |
-
<input type="text" id="user-input" placeholder="Type your message here..." autocomplete="off">
|
| 23 |
-
<button type="submit">Send</button>
|
| 24 |
-
</form>
|
| 25 |
-
</div>
|
| 26 |
-
</div>
|
| 27 |
-
|
| 28 |
-
<div class="tools-info">
|
| 29 |
-
<h3>Available Tools:</h3>
|
| 30 |
-
<ul>
|
| 31 |
-
<li><strong>Search Web</strong> - Find information online</li>
|
| 32 |
-
<li><strong>Calculate</strong> - Solve mathematical expressions</li>
|
| 33 |
-
<li><strong>Generate Image Prompt</strong> - Create detailed image generation prompts</li>
|
| 34 |
-
</ul>
|
| 35 |
-
</div>
|
| 36 |
</div>
|
| 37 |
|
| 38 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
</body>
|
| 40 |
</html>
|
|
|
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<title>AI Assistant</title>
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
font-family: Arial, sans-serif;
|
| 11 |
+
max-width: 800px;
|
| 12 |
+
margin: 0 auto;
|
| 13 |
+
padding: 20px;
|
| 14 |
+
background-color: #f5f5f5;
|
| 15 |
+
}
|
| 16 |
+
.chat-container {
|
| 17 |
+
background-color: white;
|
| 18 |
+
border-radius: 10px;
|
| 19 |
+
padding: 20px;
|
| 20 |
+
margin-bottom: 20px;
|
| 21 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 22 |
+
}
|
| 23 |
+
.message {
|
| 24 |
+
margin-bottom: 10px;
|
| 25 |
+
padding: 10px;
|
| 26 |
+
border-radius: 5px;
|
| 27 |
+
}
|
| 28 |
+
.user-message {
|
| 29 |
+
background-color: #e3f2fd;
|
| 30 |
+
margin-left: 20%;
|
| 31 |
+
}
|
| 32 |
+
.ai-message {
|
| 33 |
+
background-color: #f5f5f5;
|
| 34 |
+
margin-right: 20%;
|
| 35 |
+
}
|
| 36 |
+
.input-container {
|
| 37 |
+
display: flex;
|
| 38 |
+
gap: 10px;
|
| 39 |
+
}
|
| 40 |
+
input[type="text"] {
|
| 41 |
+
flex: 1;
|
| 42 |
+
padding: 10px;
|
| 43 |
+
border: 1px solid #ddd;
|
| 44 |
+
border-radius: 5px;
|
| 45 |
+
}
|
| 46 |
+
button {
|
| 47 |
+
padding: 10px 20px;
|
| 48 |
+
background-color: #2196f3;
|
| 49 |
+
color: white;
|
| 50 |
+
border: none;
|
| 51 |
+
border-radius: 5px;
|
| 52 |
+
cursor: pointer;
|
| 53 |
+
}
|
| 54 |
+
button:hover {
|
| 55 |
+
background-color: #1976d2;
|
| 56 |
+
}
|
| 57 |
+
.tool-info {
|
| 58 |
+
background-color: #e8f5e9;
|
| 59 |
+
padding: 15px;
|
| 60 |
+
border-radius: 5px;
|
| 61 |
+
margin-bottom: 20px;
|
| 62 |
+
}
|
| 63 |
+
.tool-info h3 {
|
| 64 |
+
margin-top: 0;
|
| 65 |
+
color: #2e7d32;
|
| 66 |
+
}
|
| 67 |
+
.tool-info ul {
|
| 68 |
+
padding-left: 20px;
|
| 69 |
+
}
|
| 70 |
+
.tool-info li {
|
| 71 |
+
margin-bottom: 5px;
|
| 72 |
+
}
|
| 73 |
+
</style>
|
| 74 |
</head>
|
| 75 |
<body>
|
| 76 |
+
<h1>AI Assistant</h1>
|
| 77 |
+
|
| 78 |
+
<div class="tool-info">
|
| 79 |
+
<h3>Available Tools:</h3>
|
| 80 |
+
<ul>
|
| 81 |
+
<li><strong>Weather Tool</strong>: Get current weather information for any location (e.g., "weather New York")</li>
|
| 82 |
+
<li><strong>Calculator</strong>: Perform mathematical calculations (e.g., "calculate 2+2")</li>
|
| 83 |
+
<li><strong>Image Generator</strong>: Generate images from descriptions (e.g., "generate image of a sunset")</li>
|
| 84 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
</div>
|
| 86 |
|
| 87 |
+
<div class="chat-container" id="chat-container">
|
| 88 |
+
<!-- Messages will be added here -->
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<div class="input-container">
|
| 92 |
+
<input type="text" id="user-input" placeholder="Type your message here...">
|
| 93 |
+
<button onclick="sendMessage()">Send</button>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
<script>
|
| 97 |
+
const ws = new WebSocket(`ws://${window.location.host}/ws`);
|
| 98 |
+
const chatContainer = document.getElementById('chat-container');
|
| 99 |
+
const userInput = document.getElementById('user-input');
|
| 100 |
+
|
| 101 |
+
// Add welcome message
|
| 102 |
+
addMessage('Welcome! I can help you with weather information, calculations, and image generation. What would you like to do?', 'ai');
|
| 103 |
+
|
| 104 |
+
ws.onmessage = function(event) {
|
| 105 |
+
const data = JSON.parse(event.data);
|
| 106 |
+
if (data.type === 'ai_message') {
|
| 107 |
+
addMessage(data.content, 'ai');
|
| 108 |
+
} else if (data.type === 'error') {
|
| 109 |
+
addMessage(`Error: ${data.content}`, 'ai');
|
| 110 |
+
}
|
| 111 |
+
};
|
| 112 |
+
|
| 113 |
+
function sendMessage() {
|
| 114 |
+
const message = userInput.value.trim();
|
| 115 |
+
if (message) {
|
| 116 |
+
addMessage(message, 'user');
|
| 117 |
+
ws.send(message);
|
| 118 |
+
userInput.value = '';
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function addMessage(text, sender) {
|
| 123 |
+
const messageDiv = document.createElement('div');
|
| 124 |
+
messageDiv.className = `message ${sender}-message`;
|
| 125 |
+
messageDiv.textContent = text;
|
| 126 |
+
chatContainer.appendChild(messageDiv);
|
| 127 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
userInput.addEventListener('keypress', function(e) {
|
| 131 |
+
if (e.key === 'Enter') {
|
| 132 |
+
sendMessage();
|
| 133 |
+
}
|
| 134 |
+
});
|
| 135 |
+
</script>
|
| 136 |
</body>
|
| 137 |
</html>
|