Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +164 -2
templates/index.html
CHANGED
|
@@ -340,6 +340,119 @@
|
|
| 340 |
from { opacity: 0; transform: translateY(20px); }
|
| 341 |
to { opacity: 1; transform: translateY(0); }
|
| 342 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
</style>
|
| 344 |
</head>
|
| 345 |
<body>
|
|
@@ -554,6 +667,47 @@
|
|
| 554 |
return messageEl;
|
| 555 |
}
|
| 556 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 557 |
async function sendMessage() {
|
| 558 |
const queryInput = document.getElementById('query');
|
| 559 |
const messageText = queryInput.value.trim();
|
|
@@ -580,13 +734,21 @@
|
|
| 580 |
headers: { 'Content-Type': 'application/json' },
|
| 581 |
body: JSON.stringify({ query: messageText, role: currentRole, file_id: currentFileId })
|
| 582 |
});
|
|
|
|
| 583 |
if (!response.ok) {
|
| 584 |
throw new Error(`HTTP error! status: ${response.status}`);
|
| 585 |
}
|
|
|
|
| 586 |
const data = await response.json();
|
| 587 |
typingIndicator.remove();
|
| 588 |
-
|
| 589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
| 591 |
} catch (error) {
|
| 592 |
console.error('Error:', error);
|
|
|
|
| 340 |
from { opacity: 0; transform: translateY(20px); }
|
| 341 |
to { opacity: 1; transform: translateY(0); }
|
| 342 |
}
|
| 343 |
+
|
| 344 |
+
/* News Output Styling */
|
| 345 |
+
.news-container {
|
| 346 |
+
max-width: 800px;
|
| 347 |
+
margin: 0 auto;
|
| 348 |
+
padding: 1rem;
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
.market-summary {
|
| 352 |
+
background: var(--surface-dark);
|
| 353 |
+
border: 1px solid var(--border-light);
|
| 354 |
+
border-radius: 1rem;
|
| 355 |
+
padding: 1.5rem;
|
| 356 |
+
margin-bottom: 2rem;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
.market-summary h2 {
|
| 360 |
+
color: var(--text-primary);
|
| 361 |
+
font-size: 1.5rem;
|
| 362 |
+
font-weight: 600;
|
| 363 |
+
margin-bottom: 1rem;
|
| 364 |
+
padding-bottom: 0.5rem;
|
| 365 |
+
border-bottom: 1px solid var(--border-light);
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
.market-summary-content {
|
| 369 |
+
color: var(--text-secondary);
|
| 370 |
+
font-size: 1rem;
|
| 371 |
+
line-height: 1.6;
|
| 372 |
+
white-space: pre-wrap;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
.articles-section {
|
| 376 |
+
margin-top: 2rem;
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
.articles-section h2 {
|
| 380 |
+
color: var(--text-primary);
|
| 381 |
+
font-size: 1.5rem;
|
| 382 |
+
font-weight: 600;
|
| 383 |
+
margin-bottom: 1.5rem;
|
| 384 |
+
padding-bottom: 0.5rem;
|
| 385 |
+
border-bottom: 1px solid var(--border-light);
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
.articles-grid {
|
| 389 |
+
display: flex;
|
| 390 |
+
flex-direction: column;
|
| 391 |
+
gap: 1.5rem;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
.article-card {
|
| 395 |
+
background: var(--surface-dark);
|
| 396 |
+
border: 1px solid var(--border-light);
|
| 397 |
+
border-radius: 1rem;
|
| 398 |
+
padding: 1.5rem;
|
| 399 |
+
transition: all 0.3s ease;
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
.article-card:hover {
|
| 403 |
+
transform: translateY(-2px);
|
| 404 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
.article-card h3 {
|
| 408 |
+
color: var(--text-primary);
|
| 409 |
+
font-size: 1.2rem;
|
| 410 |
+
font-weight: 600;
|
| 411 |
+
margin-bottom: 1rem;
|
| 412 |
+
line-height: 1.4;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
.article-card .source {
|
| 416 |
+
color: #6366f1;
|
| 417 |
+
font-size: 0.9rem;
|
| 418 |
+
margin-bottom: 0.75rem;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
.article-card .analysis {
|
| 422 |
+
color: var(--text-secondary);
|
| 423 |
+
font-size: 1rem;
|
| 424 |
+
line-height: 1.6;
|
| 425 |
+
margin-bottom: 1rem;
|
| 426 |
+
white-space: pre-wrap;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
.article-card .article-footer {
|
| 430 |
+
display: flex;
|
| 431 |
+
justify-content: space-between;
|
| 432 |
+
align-items: center;
|
| 433 |
+
margin-top: 1rem;
|
| 434 |
+
padding-top: 1rem;
|
| 435 |
+
border-top: 1px solid var(--border-light);
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
.article-card .read-more {
|
| 439 |
+
color: #6366f1;
|
| 440 |
+
text-decoration: none;
|
| 441 |
+
font-size: 0.9rem;
|
| 442 |
+
font-weight: 500;
|
| 443 |
+
display: flex;
|
| 444 |
+
align-items: center;
|
| 445 |
+
gap: 0.5rem;
|
| 446 |
+
transition: color 0.2s ease;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
.article-card .read-more:hover {
|
| 450 |
+
color: #4f46e5;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
.article-card .read-more i {
|
| 454 |
+
font-size: 0.8rem;
|
| 455 |
+
}
|
| 456 |
</style>
|
| 457 |
</head>
|
| 458 |
<body>
|
|
|
|
| 667 |
return messageEl;
|
| 668 |
}
|
| 669 |
|
| 670 |
+
function renderNewsResponse(data) {
|
| 671 |
+
const messagesContainer = document.getElementById('messages');
|
| 672 |
+
|
| 673 |
+
// Create a news container
|
| 674 |
+
const newsContainer = document.createElement('div');
|
| 675 |
+
newsContainer.classList.add('message', 'assistant-message');
|
| 676 |
+
|
| 677 |
+
// Add market summary
|
| 678 |
+
if (data.summary) {
|
| 679 |
+
const summarySection = document.createElement('div');
|
| 680 |
+
summarySection.innerHTML = `
|
| 681 |
+
<h2>Market Summary</h2>
|
| 682 |
+
<div class="market-summary">
|
| 683 |
+
${data.summary}
|
| 684 |
+
</div>
|
| 685 |
+
`;
|
| 686 |
+
newsContainer.appendChild(summarySection);
|
| 687 |
+
}
|
| 688 |
+
|
| 689 |
+
// Add articles
|
| 690 |
+
if (data.articles && data.articles.length > 0) {
|
| 691 |
+
const articlesSection = document.createElement('div');
|
| 692 |
+
articlesSection.innerHTML = `
|
| 693 |
+
<h2>Related Articles</h2>
|
| 694 |
+
<div class="articles-grid">
|
| 695 |
+
${data.articles.map(article => `
|
| 696 |
+
<div class="article-card">
|
| 697 |
+
<h3>${article.title}</h3>
|
| 698 |
+
<p>${article.analysis}</p>
|
| 699 |
+
<a href="${article.link}" target="_blank" rel="noopener noreferrer">Read More</a>
|
| 700 |
+
</div>
|
| 701 |
+
`).join('')}
|
| 702 |
+
</div>
|
| 703 |
+
`;
|
| 704 |
+
newsContainer.appendChild(articlesSection);
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
messagesContainer.appendChild(newsContainer);
|
| 708 |
+
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
async function sendMessage() {
|
| 712 |
const queryInput = document.getElementById('query');
|
| 713 |
const messageText = queryInput.value.trim();
|
|
|
|
| 734 |
headers: { 'Content-Type': 'application/json' },
|
| 735 |
body: JSON.stringify({ query: messageText, role: currentRole, file_id: currentFileId })
|
| 736 |
});
|
| 737 |
+
|
| 738 |
if (!response.ok) {
|
| 739 |
throw new Error(`HTTP error! status: ${response.status}`);
|
| 740 |
}
|
| 741 |
+
|
| 742 |
const data = await response.json();
|
| 743 |
typingIndicator.remove();
|
| 744 |
+
|
| 745 |
+
if (isNewsMode) {
|
| 746 |
+
renderNewsResponse(data);
|
| 747 |
+
} else {
|
| 748 |
+
const assistantMessage = renderMessage(data.response || data.answer, false);
|
| 749 |
+
messagesContainer.appendChild(assistantMessage);
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
| 753 |
} catch (error) {
|
| 754 |
console.error('Error:', error);
|