File size: 5,179 Bytes
46054ae |
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 |
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trợ lý Hành chính Phường/Xã</title>
<style>
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
header {
text-align: center;
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 1px solid #e0e0e0;
}
h1 {
color: #2c3e50;
font-size: 24px;
margin-bottom: 5px;
}
.input-section {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box;
margin-bottom: 10px;
}
button {
background-color: #3498db;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
button:hover {
background-color: #2980b9;
}
#output {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
min-height: 150px;
white-space: pre-wrap;
}
.status {
color: #7f8c8d;
font-style: italic;
}
/* Kiểu dáng cho kết quả đầu ra sạch sẽ */
.clean-output {
font-family: 'Arial', sans-serif;
line-height: 1.6;
}
.clean-output strong {
font-weight: bold;
color: #2c3e50;
}
</style>
</head>
<body>
<header>
<h1>Trợ lý Hành chính Phường/Xã</h1>
<p>Hỗ trợ tra cứu thông tin hành chính</p>
</header>
<section class="input-section">
<label for="query">Nhập yêu cầu tra cứu:</label>
<input type="text" id="query" placeholder="Ví dụ: Phường Phú Tân thuộc quận/huyện nào?">
<button onclick="sendQuery()">Tra cứu</button>
</section>
<section>
<h2>Kết quả tra cứu</h2>
<div id="output" class="status clean-output">Kết quả sẽ hiển thị tại đây sau khi tra cứu...</div>
</section>
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
<script>
const socket = io("wss://tracuuphuongxa.trolyao.org", {
transports: ["websocket"]
});
socket.on("connect", () => {
console.log("Kết nối thành công:", socket.id);
});
socket.on("disconnect", () => {
console.log("Mất kết nối với hệ thống");
});
socket.on("chat_on_response_chunk", (chunk) => {
const output = document.getElementById("output");
if (output.classList.contains("status")) {
output.classList.remove("status");
}
// Xử lý làm sạch kết quả đầu ra
let cleanChunk = chunk
.replace(/###/g, '') // Loại bỏ dấu ###
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>') // Chuyển **text** thành <strong>
.replace(/\n/g, '<br>'); // Xử lý xuống dòng
output.innerHTML += cleanChunk;
});
function sendQuery() {
const userInput = document.getElementById("query").value.trim();
if (!userInput) {
alert("Vui lòng nhập yêu cầu tra cứu");
return;
}
const output = document.getElementById("output");
output.innerHTML = "Đang xử lý yêu cầu...";
output.className = "status clean-output";
const payload = {
history: [
{ user: userInput, bot: "" }
],
approach: "rrr",
username: "anonymous_phuongxa",
fullname: "anonymous_phuongxa",
overrides: {
user_model: "llm-vtcc-foundation-70b",
retrieval_mode: "text",
temperature: 0.2,
fulltext_search_retriever: true,
use_whitelist: true,
use_summary_answer: true,
confirm_decision: true,
use_llm_filter: true,
use_confirm_answer: true,
chatgpt_model: "llm-vtcc-foundation-70b",
chatgpt_model_gen_query: "llm-vtcc-foundation-70b",
model_llm_search: "GPT-4o-128K",
model_llm_filter: "GPT-4o-128K",
use_reference: false,
regen_reference: false,
use_api_search_tree: false,
type_hybrid_search: "Priority semantic",
type_search_engine: "bing",
mode_think: false,
mode_search: false,
no_prompt: false
}
};
socket.emit("request_chatbot", JSON.stringify(payload));
}
// Xử lý phím Enter
document.getElementById("query").addEventListener("keypress", function(event) {
if (event.key === "Enter") {
sendQuery();
}
});
</script>
</body>
</html> |