feat: support resuming ongoing streams (#974)
This commit is contained in:
parent
45978c27a2
commit
a3221fbcdc
13 changed files with 1005 additions and 47 deletions
|
|
@ -25,6 +25,7 @@ export function Chat({
|
|||
selectedVisibilityType,
|
||||
isReadonly,
|
||||
session,
|
||||
autoResume,
|
||||
}: {
|
||||
id: string;
|
||||
initialMessages: Array<UIMessage>;
|
||||
|
|
@ -32,6 +33,7 @@ export function Chat({
|
|||
selectedVisibilityType: VisibilityType;
|
||||
isReadonly: boolean;
|
||||
session: Session;
|
||||
autoResume: boolean;
|
||||
}) {
|
||||
const { mutate } = useSWRConfig();
|
||||
|
||||
|
|
@ -45,6 +47,7 @@ export function Chat({
|
|||
status,
|
||||
stop,
|
||||
reload,
|
||||
experimental_resume,
|
||||
} = useChat({
|
||||
id,
|
||||
initialMessages,
|
||||
|
|
@ -67,6 +70,15 @@ export function Chat({
|
|||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (autoResume) {
|
||||
experimental_resume();
|
||||
}
|
||||
|
||||
// note: this hook has no dependencies since it only needs to run once
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const query = searchParams.get('query');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue