From 6b6011dc1d22f8fe9117b5985ec7d818522e0e05 Mon Sep 17 00:00:00 2001 From: eric2788 Date: Sun, 27 Oct 2024 22:21:39 +0800 Subject: [PATCH 1/2] provide title when using AI prompt to summarize --- src/tabs/summarizer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabs/summarizer.tsx b/src/tabs/summarizer.tsx index e96048bb..183f9e22 100644 --- a/src/tabs/summarizer.tsx +++ b/src/tabs/summarizer.tsx @@ -52,7 +52,7 @@ function App() { const llmSettings = await getSettingStorage('settings.llm') const llm = createLLMProvider(llmSettings) llm.on('progress', (p, t) => setProgressText(() => p < 1 ? t : '')) - const summaryStream = llm.promptStream(`这位是一名在b站直播间直播的日本vtuber说过的话,请根据下文对话猜测与观众的互动内容,并用中文总结一下他们的对话:\n\n${danmakus.join('\n')}`) + const summaryStream = llm.promptStream(`这位是一名在b站直播间直播的日本vtuber说过的话${roomTitle ? `,其标题为"${roomTitle}"` : ''},请根据下文对话猜测与观众的互动内容,并用中文总结一下他们的对话:\n\n${danmakus.join('\n')}`) for await (const words of summaryStream) { if (llm.cumulative) { setSummary(summary => summary === loadingText ? words : summary + words) From 5f18349e780bf5fd637a79a270f24faf39faaade Mon Sep 17 00:00:00 2001 From: eric2788 Date: Sun, 27 Oct 2024 22:54:15 +0800 Subject: [PATCH 2/2] fixed import settings button keep disabled after cancel file input --- src/hooks/form.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hooks/form.ts b/src/hooks/form.ts index 4a5595f7..337a1644 100644 --- a/src/hooks/form.ts +++ b/src/hooks/form.ts @@ -5,6 +5,12 @@ export function useFileInput(onFileChange: (files: FileList) => Promise, o const inputRef = useRef() const selectFiles = useCallback(function (): Promise { return new Promise((resolve, reject) => { + const finallize = () => { + inputRef.current.removeEventListener('change', listener) + inputRef.current.removeEventListener('cancel', finallize) + inputRef.current.files = null + resolve() + } const listener = async (e: Event) => { try { const files = (e.target as HTMLInputElement).files @@ -15,12 +21,11 @@ export function useFileInput(onFileChange: (files: FileList) => Promise, o onError?.(e) reject(e) } finally { - inputRef.current.removeEventListener('change', listener) - inputRef.current.files = null - resolve() + finallize() } } inputRef.current.addEventListener('change', listener) + inputRef.current.addEventListener('cancel', finallize) inputRef.current.click() }) }, deps)