Folder reorganize 1
This commit is contained in:
188
test/uimodel/index.html
Normal file
188
test/uimodel/index.html
Normal file
@@ -0,0 +1,188 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI Agent Hub - Your IT Partner</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<!-- Font Awesome for icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: #F9FAFB; /* Light gray background */
|
||||
color: #1F2937; /* Dark charcoal text */
|
||||
}
|
||||
.cta-button {
|
||||
background-color: #3B82F6; /* Blue */
|
||||
color: white;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 0.5rem;
|
||||
font-weight: 600;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
.cta-button:hover {
|
||||
background-color: #2563EB;
|
||||
}
|
||||
.agent-card {
|
||||
background-color: white;
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
|
||||
}
|
||||
.agent-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
.agent-icon {
|
||||
color: #3B82F6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="min-h-screen flex flex-col">
|
||||
|
||||
<!-- Header / Navbar (Optional, but good for context) -->
|
||||
<header class="bg-white shadow-sm py-4">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex justify-between items-center">
|
||||
<h1 class="text-2xl font-bold text-gray-800">AI Agent Hub</h1>
|
||||
<nav>
|
||||
<a href="#agents" class="text-gray-600 hover:text-blue-600 px-3 py-2 rounded-md text-sm font-medium">Agents</a>
|
||||
<a href="#about" class="text-gray-600 hover:text-blue-600 px-3 py-2 rounded-md text-sm font-medium">About</a>
|
||||
<a href="#contact" class="text-gray-600 hover:text-blue-600 px-3 py-2 rounded-md text-sm font-medium">Contact</a>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Hero Section -->
|
||||
<section class="flex-grow flex flex-col items-center justify-center py-12 px-4 sm:px-6 lg:px-8 text-center">
|
||||
<div class="max-w-3xl mx-auto">
|
||||
<h2 class="text-4xl sm:text-5xl font-extrabold text-gray-900 leading-tight">
|
||||
Empower Your Work with AI Agents
|
||||
</h2>
|
||||
<p class="mt-4 text-lg text-gray-600">
|
||||
Discover intuitive AI tools designed to streamline your tasks, provide insights, and enhance your productivity across various IT domains.
|
||||
</p>
|
||||
<div class="mt-8">
|
||||
<button class="cta-button">
|
||||
<i class="fas fa-robot mr-2"></i> Explore Agents
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-12">
|
||||
<img src="https://placehold.co/600x300/E0E7FF/3B82F6?text=AI+Agents+Illustration" alt="Illustration of AI agents working together" class="rounded-lg shadow-lg">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Agent Categories Section -->
|
||||
<section id="agents" class="py-16 bg-gray-50">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<h3 class="text-3xl font-bold text-gray-900 text-center mb-12">Our AI Agents</h3>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||
|
||||
<!-- Agent Card 1: IT Support Agent -->
|
||||
<div class="agent-card p-6 flex flex-col items-center justify-center text-center">
|
||||
<i class="fas fa-headset text-5xl agent-icon mb-4"></i>
|
||||
<h4 class="text-xl font-semibold text-gray-800 mb-2">IT Support Agent</h4>
|
||||
<p class="text-gray-600 text-sm">Get instant help with common IT issues, password resets, and software troubleshooting.</p>
|
||||
<button class="mt-4 cta-button text-sm px-4 py-2" onclick="alert('Launching IT Support Agent!')">
|
||||
<i class="fas fa-arrow-right mr-1"></i> Launch
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Agent Card 2: Data Analysis Agent -->
|
||||
<div class="agent-card p-6 flex flex-col items-center justify-center text-center">
|
||||
<i class="fas fa-chart-line text-5xl agent-icon mb-4"></i>
|
||||
<h4 class="text-xl font-semibold text-gray-800 mb-2">Data Analysis Agent</h4>
|
||||
<p class="text-gray-600 text-sm">Generate insights from your company's data, create reports, and identify trends.</p>
|
||||
<button class="mt-4 cta-button text-sm px-4 py-2" onclick="alert('Launching Data Analysis Agent!')">
|
||||
<i class="fas fa-arrow-right mr-1"></i> Launch
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Agent Card 3: Document Management Agent -->
|
||||
<div class="agent-card p-6 flex flex-col items-center justify-center text-center">
|
||||
<i class="fas fa-file-alt text-5xl agent-icon mb-4"></i>
|
||||
<h4 class="text-xl font-semibold text-gray-800 mb-2">Document Management Agent</h4>
|
||||
<p class="text-gray-600 text-sm">Organize, categorize, and retrieve company documents with ease.</p>
|
||||
<button class="mt-4 cta-button text-sm px-4 py-2" onclick="alert('Launching Document Management Agent!')">
|
||||
<i class="fas fa-arrow-right mr-1"></i> Launch
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Agent Card 4: Security Agent -->
|
||||
<div class="agent-card p-6 flex flex-col items-center justify-center text-center">
|
||||
<i class="fas fa-shield-alt text-5xl agent-icon mb-4"></i>
|
||||
<h4 class="text-xl font-semibold text-gray-800 mb-2">Security Agent</h4>
|
||||
<p class="text-gray-600 text-sm">Monitor for threats, detect vulnerabilities, and provide security recommendations.</p>
|
||||
<button class="mt-4 cta-button text-sm px-4 py-2" onclick="alert('Launching Security Agent!')">
|
||||
<i class="fas fa-arrow-right mr-1"></i> Launch
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Agent Card 5: Project Management Agent -->
|
||||
<div class="agent-card p-6 flex flex-col items-center justify-center text-center">
|
||||
<i class="fas fa-tasks text-5xl agent-icon mb-4"></i>
|
||||
<h4 class="text-xl font-semibold text-gray-800 mb-2">Project Management Agent</h4>
|
||||
<p class="text-gray-600 text-sm">Plan, track, and manage projects efficiently with automated task lists and progress updates.</p>
|
||||
<button class="mt-4 cta-button text-sm px-4 py-2" onclick="alert('Launching Project Management Agent!')">
|
||||
<i class="fas fa-arrow-right mr-1"></i> Launch
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Agent Card 6: Customer Support Agent -->
|
||||
<div class="agent-card p-6 flex flex-col items-center justify-center text-center">
|
||||
<i class="fas fa-comments text-5xl agent-icon mb-4"></i>
|
||||
<h4 class="text-xl font-semibold text-gray-800 mb-2">Customer Support Agent</h4>
|
||||
<p class="text-gray-600 text-sm">Automate common customer inquiries and provide instant responses to external users.</p>
|
||||
<button class="mt-4 cta-button text-sm px-4 py-2" onclick="alert('Launching Customer Support Agent!')">
|
||||
<i class="fas fa-arrow-right mr-1"></i> Launch
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- About Section -->
|
||||
<section id="about" class="py-16 bg-white">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<h3 class="text-3xl font-bold text-gray-900 text-center mb-8">What is the AI Agent Hub?</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 items-center">
|
||||
<div>
|
||||
<p class="text-lg text-gray-600 mb-4">
|
||||
The AI Agent Hub is your centralized platform for accessing a suite of AI-powered tools designed to augment your daily IT operations. Each agent is specialized to handle a specific type of task, making your work more efficient and effective.
|
||||
</p>
|
||||
<p class="text-lg text-gray-600">
|
||||
Our agents are continuously trained and updated to provide the most accurate and helpful assistance, ensuring you have the best possible experience.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<img src="https://placehold.co/500x300/9CA3AF/1F2937?text=About+AI+Hub" alt="About AI Agent Hub" class="rounded-lg shadow-md">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Call to Action / Get Started Section -->
|
||||
<section id="contact" class="py-16 bg-gray-100">
|
||||
<div class="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
|
||||
<h3 class="text-3xl font-bold text-gray-900 mb-6">Ready to Boost Your Productivity?</h3>
|
||||
<p class="text-lg text-gray-700 mb-8">
|
||||
Join the future of IT with our AI Agent Hub. Experience streamlined workflows and intelligent insights.
|
||||
</p>
|
||||
<a href="#" class="cta-button">
|
||||
<i class="fas fa-rocket mr-2"></i> Get Started Today!
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="bg-white shadow-inner py-6">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center text-gray-500 text-sm">
|
||||
© 2024 Your Company Name. All rights reserved.
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
111
test/uimodel/test1.html
Normal file
111
test/uimodel/test1.html
Normal file
@@ -0,0 +1,111 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI Agent Chat</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" integrity="sha512-9AReq41fQ0lR8IKkKtZSL8TorASlonYWTfqj0vCH7j4dUnbKKL+XYIPh3MAa948aKJCtkOtfMtpEihvkzruhaNg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<style>
|
||||
/* Basic Styling - Customize as needed */
|
||||
body { font-family: sans-serif; }
|
||||
.chat-container { width: 80%; margin: 20px auto; border: 1px solid #ccc; padding: 15px; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
|
||||
.chat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
|
||||
.agent-selector { display: flex; gap: 5px;}
|
||||
.agent-button { padding: 8px 12px; border: none; background-color: #f0f0f0; cursor: pointer; border-radius: 4px; }
|
||||
.agent-button.selected { background-color: #ddd; font-weight: bold;}
|
||||
.chat-messages { height: 300px; overflow-y: scroll; padding: 10px; margin-bottom: 10px; }
|
||||
.message { margin-bottom: 5px; padding: 8px; border-radius: 4px; }
|
||||
.user-message { background-color: #e2f7ff; text-align: right;}
|
||||
.agent-message { background-color: #f0f0f0; text-align: left;}
|
||||
.input-area { display: flex; gap: 5px; }
|
||||
.chat-input { width: calc(100% - 60px); padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
|
||||
.send-button { padding: 8px 12px; background-color: #3498db; color: white; border: none; cursor: pointer; border-radius: 4px; }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="chat-container">
|
||||
<div class="chat-header">
|
||||
<h3>AI Agent Chat</h3>
|
||||
<div class="agent-selector">
|
||||
<button class="agent-button selected" data-agent="general">General Search</button>
|
||||
<button class="agent-button" data-agent="it_support">IT Support</button>
|
||||
<button class="agent-button" data-agent="data_analysis">Data Analysis</button>
|
||||
<button class="agent-button" data-agent="security">Security Agent</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat-messages" id="chatMessages">
|
||||
<!-- Messages will appear here -->
|
||||
</div>
|
||||
|
||||
<div class="input-area">
|
||||
<input type="text" class="chat-input" id="chatInput" placeholder="Type your message...">
|
||||
<button class="send-button" onclick="sendMessage()">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
const chatMessages = document.getElementById('chatMessages');
|
||||
const chatInput = document.getElementById('chatInput');
|
||||
const agentButtons = document.querySelectorAll('.agent-button');
|
||||
|
||||
let currentAgent = 'general'; // Default Agent
|
||||
|
||||
// Select Agent Functionality
|
||||
agentButtons.forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
// Remove 'selected' class from all buttons
|
||||
agentButtons.forEach(btn => btn.classList.remove('selected'));
|
||||
// Add 'selected' class to the clicked button
|
||||
button.classList.add('selected');
|
||||
currentAgent = button.dataset.agent;
|
||||
console.log("Current Agent:", currentAgent); // Debugging
|
||||
});
|
||||
});
|
||||
|
||||
async function sendMessage() {
|
||||
const messageText = chatInput.value.trim();
|
||||
if (messageText !== "") {
|
||||
// Display user message
|
||||
displayMessage('user', messageText);
|
||||
chatInput.value = "";
|
||||
|
||||
// Call the backend to get agent response
|
||||
try {
|
||||
const response = await fetch('/api/chat', { // Replace with your API endpoint
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ message: messageText, agent: currentAgent })
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
displayMessage('agent', data.reply); // Assuming the backend returns a 'reply' field
|
||||
} else {
|
||||
displayMessage('system', "Error sending message.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
displayMessage('system', "Network error or server unavailable.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function displayMessage(sender, text) {
|
||||
const messageDiv = document.createElement('div');
|
||||
messageDiv.classList.add('message', sender === 'user' ? 'user-message' : 'agent-message');
|
||||
messageDiv.textContent = text;
|
||||
chatMessages.appendChild(messageDiv);
|
||||
|
||||
// Scroll to the bottom of the chat
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
287
test/uimodel/test2.html
Normal file
287
test/uimodel/test2.html
Normal file
@@ -0,0 +1,287 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Unified AI Chat</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<!-- Font Awesome for icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: #F9FAFB; /* Light gray background */
|
||||
color: #1F2937; /* Dark charcoal text */
|
||||
overflow: hidden; /* Prevent body scroll */
|
||||
}
|
||||
.chat-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh; /* Full viewport height */
|
||||
max-height: 100vh; /* Ensure it doesn't exceed viewport */
|
||||
width: 100%;
|
||||
background-color: white;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
overflow: hidden; /* Hide internal scrollbars */
|
||||
}
|
||||
.chat-header {
|
||||
background-color: #3B82F6; /* Blue */
|
||||
color: white;
|
||||
padding: 1.5rem;
|
||||
border-top-left-radius: 1rem;
|
||||
border-top-right-radius: 1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-weight: 600;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
.chat-messages {
|
||||
flex-grow: 1;
|
||||
padding: 1.5rem;
|
||||
overflow-y: auto; /* Enable scrolling for messages */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.message-bubble {
|
||||
max-width: 80%;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 0.75rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.message-bubble.user {
|
||||
background-color: #3B82F6;
|
||||
color: white;
|
||||
align-self: flex-end;
|
||||
}
|
||||
.message-bubble.agent {
|
||||
background-color: #E0E7FF; /* Light blue */
|
||||
color: #1F2937;
|
||||
align-self: flex-start;
|
||||
}
|
||||
.message-bubble.agent .agent-icon {
|
||||
color: #3B82F6;
|
||||
}
|
||||
.chat-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 1rem 1.5rem;
|
||||
border-top: 1px solid #E5E7EB;
|
||||
background-color: #F9FAFB;
|
||||
}
|
||||
.chat-input input {
|
||||
flex-grow: 1;
|
||||
border: 1px solid #D1D5DB;
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
outline: none;
|
||||
font-size: 1rem;
|
||||
}
|
||||
.chat-input button {
|
||||
background-color: #3B82F6;
|
||||
color: white;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 0.5rem;
|
||||
margin-left: 0.75rem;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
.chat-input button:hover {
|
||||
background-color: #2563EB;
|
||||
}
|
||||
|
||||
/* Agent Selection Area */
|
||||
.agent-selection {
|
||||
background-color: #F9FAFB;
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid #E5E7EB;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
overflow-x: auto; /* Enable horizontal scrolling for agents */
|
||||
-ms-overflow-style: none; /* IE and Edge */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
}
|
||||
.agent-selection::-webkit-scrollbar {
|
||||
display: none; /* Chrome, Safari, Opera */
|
||||
}
|
||||
.agent-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
white-space: nowrap; /* Prevent text wrapping */
|
||||
}
|
||||
.agent-btn:hover {
|
||||
background-color: #E0E7FF;
|
||||
}
|
||||
.agent-btn.active {
|
||||
background-color: #3B82F6;
|
||||
color: white;
|
||||
}
|
||||
.agent-btn.active:hover {
|
||||
background-color: #2563EB;
|
||||
}
|
||||
.agent-btn .agent-icon {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media (max-width: 768px) {
|
||||
.chat-header {
|
||||
font-size: 1.125rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
.chat-messages {
|
||||
padding: 1rem;
|
||||
}
|
||||
.message-bubble {
|
||||
max-width: 90%;
|
||||
}
|
||||
.chat-input {
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
.agent-selection {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.agent-btn {
|
||||
padding: 0.4rem 0.8rem;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="chat-container mx-auto w-full max-w-3xl">
|
||||
<!-- Agent Selection Area -->
|
||||
<div class="agent-selection">
|
||||
<button class="agent-btn active" data-agent-id="default">
|
||||
<i class="fas fa-search agent-icon"></i> General Search
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="support">
|
||||
<i class="fas fa-headset agent-icon"></i> IT Support
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="data">
|
||||
<i class="fas fa-chart-line agent-icon"></i> Data Analysis
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="security">
|
||||
<i class="fas fa-shield-alt agent-icon"></i> Security
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="project">
|
||||
<i class="fas fa-tasks agent-icon"></i> Project Mgmt
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="customer">
|
||||
<i class="fas fa-comments agent-icon"></i> Customer Support
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Chat Header -->
|
||||
<div class="chat-header">
|
||||
<span id="current-agent-display">General Search</span>
|
||||
<div class="flex items-center space-x-2">
|
||||
<button class="text-white hover:text-gray-200 text-lg"><i class="fas fa-cog"></i></button>
|
||||
<button class="text-white hover:text-gray-200 text-lg"><i class="fas fa-ellipsis-v"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Chat Messages -->
|
||||
<div class="chat-messages" id="chat-messages">
|
||||
<!-- Messages will be appended here by JavaScript -->
|
||||
</div>
|
||||
|
||||
<!-- Chat Input -->
|
||||
<div class="chat-input">
|
||||
<input type="text" id="message-input" placeholder="Type a message..." class="flex-grow">
|
||||
<button id="send-button" class="flex-shrink-0">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const agentButtons = document.querySelectorAll('.agent-btn');
|
||||
const currentAgentDisplay = document.getElementById('current-agent-display');
|
||||
const messageInput = document.getElementById('message-input');
|
||||
const sendButton = document.getElementById('send-button');
|
||||
const chatMessages = document.getElementById('chat-messages');
|
||||
|
||||
let selectedAgentId = 'default'; // Default agent
|
||||
|
||||
// Function to display a message in the chat
|
||||
function addMessage(text, sender) {
|
||||
const messageDiv = document.createElement('div');
|
||||
messageDiv.classList.add('message-bubble');
|
||||
if (sender === 'user') {
|
||||
messageDiv.classList.add('user');
|
||||
messageDiv.innerHTML = `<p>${text}</p>`;
|
||||
} else {
|
||||
messageDiv.classList.add('agent');
|
||||
messageDiv.innerHTML = `<div class="flex items-center"><i class="fas agent-icon mr-2" id="${sender}-icon"></i><p>${text}</p></div>`;
|
||||
// Dynamically set icon based on agent
|
||||
const iconElement = messageDiv.querySelector('.agent-icon');
|
||||
if (sender === 'default') iconElement.classList.add('fa-search');
|
||||
else if (sender === 'support') iconElement.classList.add('fa-headset');
|
||||
else if (sender === 'data') iconElement.classList.add('fa-chart-line');
|
||||
else if (sender === 'security') iconElement.classList.add('fa-shield-alt');
|
||||
else if (sender === 'project') iconElement.classList.add('fa-tasks');
|
||||
else if (sender === 'customer') iconElement.classList.add('fa-comments');
|
||||
}
|
||||
chatMessages.appendChild(messageDiv);
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight; // Scroll to bottom
|
||||
}
|
||||
|
||||
// Function to handle agent selection
|
||||
function selectAgent(agentId) {
|
||||
agentButtons.forEach(btn => {
|
||||
btn.classList.remove('active');
|
||||
});
|
||||
document.querySelector(`.agent-btn[data-agent-id="${agentId}"]`).classList.add('active');
|
||||
selectedAgentId = agentId;
|
||||
currentAgentDisplay.textContent = document.querySelector(`.agent-btn[data-agent-id="${agentId}"]`).textContent.trim();
|
||||
// Clear chat history when switching agents for simplicity
|
||||
chatMessages.innerHTML = '';
|
||||
}
|
||||
|
||||
// Event listeners for agent buttons
|
||||
agentButtons.forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
selectAgent(button.dataset.agentId);
|
||||
});
|
||||
});
|
||||
|
||||
// Event listener for sending messages
|
||||
sendButton.addEventListener('click', () => {
|
||||
const messageText = messageInput.value.trim();
|
||||
if (messageText) {
|
||||
addMessage(messageText, 'user');
|
||||
messageInput.value = ''; // Clear input field
|
||||
|
||||
// Simulate agent response
|
||||
setTimeout(() => {
|
||||
let agentResponse = "I'm here to help! What would you like to ask?";
|
||||
if (selectedAgentId !== 'default') {
|
||||
agentResponse = `Hello! I'm your ${selectedAgentId} agent. How can I assist you today?`;
|
||||
}
|
||||
addMessage(agentResponse, selectedAgentId);
|
||||
}, 1000); // Simulate network delay
|
||||
}
|
||||
});
|
||||
|
||||
// Allow sending message with Enter key
|
||||
messageInput.addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
sendButton.click();
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize with default agent selected
|
||||
selectAgent('default');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user