Spaces:
Build error
Build error
| <!-- index.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> | |