Skip to content

Commit

Permalink
Merge pull request #91 from eric2788/develop
Browse files Browse the repository at this point in the history
updates v2.0.3.1028
  • Loading branch information
eric2788 authored Oct 27, 2024
2 parents daa1838 + 5f18349 commit da308fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/hooks/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ export function useFileInput(onFileChange: (files: FileList) => Promise<void>, o
const inputRef = useRef<HTMLInputElement>()
const selectFiles = useCallback(function (): Promise<void> {
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
Expand All @@ -15,12 +21,11 @@ export function useFileInput(onFileChange: (files: FileList) => Promise<void>, 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)
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/summarizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit da308fb

Please sign in to comment.