Skip to content

Commit 3107d66

Browse files
committed
changed least jimakus to 25, error on empty response
1 parent 8022f95 commit 3107d66

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/features/jimaku/components/ButtonArea.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function ButtonArea({ clearJimaku, jimakus }: ButtonAreaProps): JSX.Element {
4141
const [show, setShow] = useState(!info.isTheme)
4242

4343
const summerize = async () => {
44-
if (jimakus.length < 10) {
45-
toast.warning('至少需要有10条同传字幕才可总结。')
44+
if (jimakus.length < 25) {
45+
toast.warning('至少需要有25条同传字幕才可总结。')
4646
return
4747
}
4848
await sendMessager('open-tab', { tab: 'summarizer', params: { roomId: info.room, title: info.title }, active: true, singleton: true })

src/tabs/summarizer.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function App() {
4040
return
4141
}
4242
setTitle(roomTitle ?? `B站直播间 ${roomId}`)
43+
// only run once after success
4344
const remover = forwarder.addHandler((data) => {
4445
if (data.roomId !== roomId) return
4546
console.debug('received ', data.jimakus.length, 'danmakus')
@@ -51,9 +52,6 @@ function App() {
5152

5253
const summarize = useCallback(async (danmakus: string[]) => {
5354
try {
54-
if (danmakus.length < 10) {
55-
throw new Error('至少需要有10条同传字幕才可总结。')
56-
}
5755
const { jimaku: { aiZone } } = await getSettingStorage('settings.features')
5856
const llm = createLLM(aiZone)
5957
const summaryStream = llm.promptStream(`这位是一名在b站直播间直播的日本vtuber说过的话,请根据下文对话猜测与观众的互动内容,并用中文总结一下他们的对话:\n\n${danmakus.join('\n')}`)
@@ -64,7 +62,11 @@ function App() {
6462
} catch (err) {
6563
setLoading(false)
6664
console.error(err)
67-
setError('未知错误: ' + err.message)
65+
setError('错误: ' + err.message)
66+
} finally {
67+
if (summary === '') {
68+
setError('同传总结返回了空的回应。')
69+
}
6870
}
6971
}, [])
7072

0 commit comments

Comments
 (0)