feat: 项目初始化及当前全部内容提交
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>消息拆分测试</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
.test-section {
|
||||
margin-bottom: 30px;
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.test-section h3 {
|
||||
margin-top: 0;
|
||||
color: #333;
|
||||
}
|
||||
button {
|
||||
background: #1890ff;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
}
|
||||
button:hover {
|
||||
background: #40a9ff;
|
||||
}
|
||||
.result {
|
||||
margin-top: 15px;
|
||||
padding: 10px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 4px;
|
||||
white-space: pre-wrap;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.message-item {
|
||||
margin: 10px 0;
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border-left: 4px solid #1890ff;
|
||||
background: #f0f8ff;
|
||||
}
|
||||
.message-meta {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.message-content {
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>消息拆分功能测试</h1>
|
||||
|
||||
<div class="test-section">
|
||||
<h3>1. 测试聊天消息拆分</h3>
|
||||
<button onclick="testChatSplit()">发送测试消息</button>
|
||||
<div id="chatResult" class="result"></div>
|
||||
</div>
|
||||
|
||||
<div class="test-section">
|
||||
<h3>2. 获取会话消息列表</h3>
|
||||
<input type="text" id="conversationId" placeholder="输入会话ID" style="width: 300px; padding: 8px; margin-right: 10px;">
|
||||
<button onclick="getMessages()">获取消息</button>
|
||||
<div id="messagesResult" class="result"></div>
|
||||
</div>
|
||||
|
||||
<div class="test-section">
|
||||
<h3>3. 测试拆分接口</h3>
|
||||
<button onclick="testSplitApi()">测试双换行拆分</button>
|
||||
<button onclick="testSingleLineSplit()">测试单换行拆分</button>
|
||||
<button onclick="testNoSplit()">测试无换行</button>
|
||||
<div id="splitResult" class="result"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API_BASE = 'http://47.111.10.27/api';
|
||||
|
||||
async function testChatSplit() {
|
||||
const resultDiv = document.getElementById('chatResult');
|
||||
resultDiv.innerHTML = '发送中...';
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/ai/guest/chat`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
message: '请详细介绍一下你的功能,包括聊天、情感分析、生活助手等各个方面的能力,并分段说明。'
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
resultDiv.innerHTML = JSON.stringify(data, null, 2);
|
||||
|
||||
// 如果有会话ID,自动填入
|
||||
if (data.data && data.data.conversationId) {
|
||||
document.getElementById('conversationId').value = data.data.conversationId;
|
||||
}
|
||||
} catch (error) {
|
||||
resultDiv.innerHTML = '错误: ' + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
async function getMessages() {
|
||||
const conversationId = document.getElementById('conversationId').value;
|
||||
const resultDiv = document.getElementById('messagesResult');
|
||||
|
||||
if (!conversationId) {
|
||||
resultDiv.innerHTML = '请输入会话ID';
|
||||
return;
|
||||
}
|
||||
|
||||
resultDiv.innerHTML = '获取中...';
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/ai/guest/conversation/${conversationId}/messages`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.code === 200 && data.data) {
|
||||
let html = `<h4>找到 ${data.data.length} 条消息:</h4>`;
|
||||
data.data.forEach((msg, index) => {
|
||||
html += `
|
||||
<div class="message-item">
|
||||
<div class="message-meta">
|
||||
#${index + 1} | ID: ${msg.messageId} | 发送者: ${msg.sender} | 时间: ${msg.timestamp}
|
||||
</div>
|
||||
<div class="message-content">${msg.content}</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
resultDiv.innerHTML = html;
|
||||
} else {
|
||||
resultDiv.innerHTML = JSON.stringify(data, null, 2);
|
||||
}
|
||||
} catch (error) {
|
||||
resultDiv.innerHTML = '错误: ' + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
async function testSplitApi() {
|
||||
await testSplit('测试双换行拆分功能');
|
||||
}
|
||||
|
||||
async function testSingleLineSplit() {
|
||||
await testSplit('测试单换行拆分功能');
|
||||
}
|
||||
|
||||
async function testNoSplit() {
|
||||
await testSplit('测试无换行符功能');
|
||||
}
|
||||
|
||||
async function testSplit(message) {
|
||||
const resultDiv = document.getElementById('splitResult');
|
||||
resultDiv.innerHTML = '测试中...';
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/ai/guest/test/split`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ message })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
resultDiv.innerHTML = JSON.stringify(data, null, 2);
|
||||
} catch (error) {
|
||||
resultDiv.innerHTML = '错误: ' + error.message;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user