fix ad selection & catch some error
This commit is contained in:
@@ -156,12 +156,12 @@ const AdBanner: React.FC<AdBannerProps> = ({ show, closeAd }) => {
|
|||||||
</Popover>
|
</Popover>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
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"
|
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" />
|
<img src="https://files.monica.cn/assets/botgroup/computer.png" className="w-4 h-4" alt="Computer" />
|
||||||
下载APP
|
在网页中对话
|
||||||
<img src="https://files.monica.cn/assets/botgroup/arrow-up.png" className="w-4 h-4" alt="Arrow" />
|
<img src="https://files.monica.cn/assets/botgroup/arrow-up.png" className="w-4 h-4" alt="Arrow" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -283,10 +283,24 @@ const ChatUI = () => {
|
|||||||
|
|
||||||
let buffer = '';
|
let buffer = '';
|
||||||
let completeResponse = ''; // 用于跟踪完整的响应
|
let completeResponse = ''; // 用于跟踪完整的响应
|
||||||
|
// 添加超时控制
|
||||||
|
const timeout = 5000; // 5秒超时
|
||||||
while (true) {
|
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) {
|
if (done) {
|
||||||
//如果completeResponse为空,
|
//如果completeResponse为空,
|
||||||
if (completeResponse.trim() === "") {
|
if (completeResponse.trim() === "") {
|
||||||
@@ -353,9 +367,14 @@ const ChatUI = () => {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("发送消息失败:", error);
|
console.error("发送消息失败:", error);
|
||||||
|
messageHistory.push({
|
||||||
|
role: 'user',
|
||||||
|
content: aiMessage.sender.name + "(发生错误: " + error.message + ")下一位回答。",
|
||||||
|
name: aiMessage.sender.name
|
||||||
|
});
|
||||||
setMessages(prev => prev.map(msg =>
|
setMessages(prev => prev.map(msg =>
|
||||||
msg.id === aiMessage.id
|
msg.id === aiMessage.id
|
||||||
? { ...msg, content: "错误: " + error.message, isError: true }
|
? { ...msg, content: "(发生错误: " + error.message + ")下一位回答。", isError: true }
|
||||||
: msg
|
: msg
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export const modelConfigs = [
|
|||||||
{
|
{
|
||||||
model: "deepseek-chat",
|
model: "deepseek-chat",
|
||||||
apiKey: "DEEPSEEK_API_KEY",
|
apiKey: "DEEPSEEK_API_KEY",
|
||||||
baseURL: "https://api.deepseek.com"
|
baseURL: "https://api.deepseek.com/v1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: "moonshot-v1-8k",
|
model: "moonshot-v1-8k",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const groups: Group[] = [
|
|||||||
id: 'group1',
|
id: 'group1',
|
||||||
name: '🔥硅碳生命体交流群',
|
name: '🔥硅碳生命体交流群',
|
||||||
description: '',
|
description: '',
|
||||||
members: [ 'ai8', 'ai4', 'ai5', 'ai6', 'ai9', 'ai10'],
|
members: [ 'ai8', 'ai4', 'ai5', 'ai6', 'ai7', 'ai9', 'ai10'],
|
||||||
isGroupDiscussionMode: false
|
isGroupDiscussionMode: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user