Spaces:
Build error
Build error
File size: 8,979 Bytes
27c4848 ce330ae c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 ce330ae c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 c1523e3 0548369 ce330ae 0548369 c1523e3 0548369 ce330ae c1523e3 0548369 c1523e3 0548369 ce330ae c1523e3 0548369 c1523e3 0548369 ce330ae 0548369 c1523e3 27c4848 ce330ae c1523e3 ce330ae c1523e3 ce330ae c1523e3 27c4848 ce330ae c1523e3 ce330ae c1523e3 373c86e ce330ae c1523e3 373c86e c1523e3 373c86e c1523e3 ce330ae c1523e3 373c86e ce330ae 373c86e c1523e3 27c4848 | 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | <!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock Market Assistant</title>
<style>
:root {
--bg-primary: #1a1a1a;
--bg-secondary: #2d2d2d;
--text-primary: #ffffff;
--text-secondary: #b3b3b3;
--accent-color: #00ff9d;
--user-message-bg: #2a3a4a;
--ai-message-bg: #2d2d2d;
--error-message-bg: #4a2a2a;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: var(--bg-primary);
color: var(--text-primary);
line-height: 1.6;
}
h1 {
color: var(--accent-color);
text-align: center;
margin-bottom: 30px;
font-size: 2.5em;
font-weight: 700;
}
.chat-container {
background-color: var(--bg-secondary);
border-radius: 15px;
padding: 20px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
height: 500px;
overflow-y: auto;
margin-bottom: 20px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.message {
margin-bottom: 15px;
padding: 12px 16px;
border-radius: 12px;
max-width: 80%;
position: relative;
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.user-message {
background-color: var(--user-message-bg);
margin-left: auto;
border-bottom-right-radius: 4px;
}
.ai-message {
background-color: var(--ai-message-bg);
margin-right: auto;
border-bottom-left-radius: 4px;
}
.error-message {
background-color: var(--error-message-bg);
color: #ff6b6b;
margin: 10px auto;
width: 90%;
text-align: center;
}
.input-container {
display: flex;
gap: 10px;
background-color: var(--bg-secondary);
padding: 15px;
border-radius: 15px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
border: 1px solid rgba(255, 255, 255, 0.1);
}
input[type="text"] {
flex: 1;
padding: 12px 16px;
border: none;
border-radius: 8px;
background-color: rgba(255, 255, 255, 0.05);
color: var(--text-primary);
font-size: 1em;
transition: all 0.3s ease;
}
input[type="text"]:focus {
outline: none;
background-color: rgba(255, 255, 255, 0.1);
box-shadow: 0 0 0 2px var(--accent-color);
}
input[type="text"]::placeholder {
color: var(--text-secondary);
}
button {
padding: 12px 24px;
background-color: var(--accent-color);
color: var(--bg-primary);
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
transition: all 0.3s ease;
}
button:hover {
background-color: #00e68a;
transform: translateY(-2px);
}
button:active {
transform: translateY(0);
}
.tools-info {
background-color: var(--bg-secondary);
padding: 20px;
border-radius: 15px;
margin-bottom: 30px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.tools-info h3 {
margin-top: 0;
color: var(--accent-color);
font-size: 1.2em;
margin-bottom: 15px;
}
.tools-info ul {
padding-left: 20px;
margin: 0;
}
.tools-info li {
margin-bottom: 10px;
color: var(--text-secondary);
}
.tools-info strong {
color: var(--accent-color);
}
/* Scrollbar styling */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
background: var(--accent-color);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #00e68a;
}
/* Responsive design */
@media (max-width: 600px) {
body {
padding: 10px;
}
.chat-container {
height: 400px;
}
.message {
max-width: 90%;
}
button {
padding: 10px 20px;
}
}
</style>
</head>
<body>
<h1>Stock Market Assistant</h1>
<div class="tools-info">
<h3>Available Tools:</h3>
<ul>
<li><strong>Stock Price:</strong> Get current price for any stock symbol (e.g., "What's the price of AAPL?")</li>
<li><strong>Stock Info:</strong> Get detailed information about a company (e.g., "Tell me about Microsoft")</li>
<li><strong>Stock History:</strong> Get historical data for a stock (e.g., "Show me Tesla's performance last month")</li>
</ul>
</div>
<div class="chat-container" id="chatContainer">
<div class="message ai-message">
Hello! I'm your Stock Market Assistant. I can help you with:
<ul>
<li>Current stock prices</li>
<li>Company information</li>
<li>Historical stock data</li>
</ul>
How can I help you today?
</div>
</div>
<div class="input-container">
<input type="text" id="userInput" placeholder="Ask about any stock...">
<button onclick="sendMessage()">Send</button>
</div>
<script>
const ws = new WebSocket('wss://' + window.location.host + '/ws');
const chatContainer = document.getElementById('chatContainer');
const userInput = document.getElementById('userInput');
ws.onopen = function() {
console.log('WebSocket connection established');
};
ws.onerror = function(error) {
console.error('WebSocket error:', error);
const messageDiv = document.createElement('div');
messageDiv.className = 'message error-message';
messageDiv.textContent = 'Connection error. Please refresh the page.';
chatContainer.appendChild(messageDiv);
};
ws.onclose = function() {
console.log('WebSocket connection closed');
const messageDiv = document.createElement('div');
messageDiv.className = 'message error-message';
messageDiv.textContent = 'Connection closed. Please refresh the page.';
chatContainer.appendChild(messageDiv);
};
ws.onmessage = function(event) {
console.log('Received message:', event.data);
const data = JSON.parse(event.data);
const messageDiv = document.createElement('div');
messageDiv.className = 'message ' + (data.type === 'ai_message' ? 'ai-message' : 'error-message');
messageDiv.textContent = data.content;
chatContainer.appendChild(messageDiv);
chatContainer.scrollTop = chatContainer.scrollHeight;
};
function sendMessage() {
const message = userInput.value.trim();
if (message) {
if (ws.readyState === WebSocket.OPEN) {
const messageDiv = document.createElement('div');
messageDiv.className = 'message user-message';
messageDiv.textContent = message;
chatContainer.appendChild(messageDiv);
chatContainer.scrollTop = chatContainer.scrollHeight;
ws.send(message);
userInput.value = '';
} else {
const messageDiv = document.createElement('div');
messageDiv.className = 'message error-message';
messageDiv.textContent = 'Not connected. Please refresh the page.';
chatContainer.appendChild(messageDiv);
}
}
}
userInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
sendMessage();
}
});
</script>
</body>
</html>
|