fix: restore missing _poll_webchat_stream_result function

This commit is contained in:
LIghtJUNction
2026-03-15 15:58:47 +08:00
parent 070f281dae
commit 0c74bd1aeb
2 changed files with 32 additions and 0 deletions
+14
View File
@@ -36,6 +36,20 @@ async def track_conversation(convs: dict, conv_id: str):
convs.pop(conv_id, None)
async def _poll_webchat_stream_result(back_queue, username: str):
try:
result = await asyncio.wait_for(back_queue.get(), timeout=1)
except asyncio.TimeoutError:
return None, False
except asyncio.CancelledError:
logger.debug(f"[WebChat] 用户 {username} 断开聊天长连接。")
return None, True
except Exception as e:
logger.error(f"WebChat stream error: {e}")
return None, False
return result, False
class ChatRoute(Route):
def __init__(
self,
@@ -27,6 +27,24 @@ const customizer = useCustomizerStore();
const authStore = useAuthStore();
const theme = useTheme();
const { t } = useI18n();
const { languageOptions, currentLanguage, switchLanguage, locale } =
useLanguageSwitcher();
const languages = computed(() =>
languageOptions.value.map((lang) => ({
code: lang.value,
name: lang.label,
flag: lang.flag,
})),
);
const currentLocale = computed(() => locale.value);
const changeLanguage = async (langCode: string) => {
await switchLanguage(langCode as Locale);
};
const route = useRoute();
const LAST_BOT_ROUTE_KEY = "astrbot:last_bot_route";
let dialog = ref(false);