Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates v2.0.3.1028 #91

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading