fix ad selection & catch some error

This commit is contained in:
maojindao55
2025-03-06 13:16:09 +08:00
parent 65e0f0f366
commit 42cbd2dea1
4 changed files with 28 additions and 9 deletions

View File

@@ -156,12 +156,12 @@ const AdBanner: React.FC<AdBannerProps> = ({ show, closeAd }) => {
</Popover>
<button
onClick={() => {
window.open('https://app.adjust.com/1mh0qgab?fallback=https%3A%2F%2Fmonica.cn%2Fapp-download&redirect_macos=https%3A%2F%2Fmonica.cn%2Fapp-download', '_blank');
window.open('https://monica.cn/home/chat/Monica/monica', '_blank');
}}
className="p-1 bg-white rounded-full text-xs font-medium text-blue-500 font-bold hover:bg-gray-50 transition-colors shadow-sm flex items-center gap-1"
>
<img src="https://files.monica.cn/assets/botgroup/mobile-banner-mobile.png" className="w-4 h-4" alt="Mobile" />
APP
<img src="https://files.monica.cn/assets/botgroup/computer.png" className="w-4 h-4" alt="Computer" />
<img src="https://files.monica.cn/assets/botgroup/arrow-up.png" className="w-4 h-4" alt="Arrow" />
</button>
</div>

View File

@@ -283,10 +283,24 @@ const ChatUI = () => {
let buffer = '';
let completeResponse = ''; // 用于跟踪完整的响应
// 添加超时控制
const timeout = 5000; // 5秒超时
while (true) {
const { done, value } = await reader.read();
//console.log("读取中")
const startTime = Date.now();
const { done, value } = await Promise.race([
reader.read(),
new Promise((_, reject) =>
setTimeout(() => reject(new Error('响应超时')), timeout - (Date.now() - startTime))
)
]);
if (Date.now() - startTime > timeout) {
reader.cancel();
throw new Error('响应超时');
}
if (done) {
//如果completeResponse为空
if (completeResponse.trim() === "") {
@@ -353,9 +367,14 @@ const ChatUI = () => {
} catch (error) {
console.error("发送消息失败:", error);
messageHistory.push({
role: 'user',
content: aiMessage.sender.name + "(发生错误: " + error.message + ")下一位回答。",
name: aiMessage.sender.name
});
setMessages(prev => prev.map(msg =>
msg.id === aiMessage.id
? { ...msg, content: "错误: " + error.message, isError: true }
? { ...msg, content: "(发生错误: " + error.message + ")下一位回答。", isError: true }
: msg
));
}

View File

@@ -38,7 +38,7 @@ export const modelConfigs = [
{
model: "deepseek-chat",
apiKey: "DEEPSEEK_API_KEY",
baseURL: "https://api.deepseek.com"
baseURL: "https://api.deepseek.com/v1"
},
{
model: "moonshot-v1-8k",

View File

@@ -12,7 +12,7 @@ export const groups: Group[] = [
id: 'group1',
name: '🔥硅碳生命体交流群',
description: '',
members: [ 'ai8', 'ai4', 'ai5', 'ai6', 'ai9', 'ai10'],
members: [ 'ai8', 'ai4', 'ai5', 'ai6', 'ai7', 'ai9', 'ai10'],
isGroupDiscussionMode: false
},
{