From 9e46d6cd5a0eb7ee55a430f4e79e331079f62e15 Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Sun, 20 Oct 2024 11:35:13 -0700 Subject: [PATCH] fix: do not cache adapter in useEdgeRuntime (#1034) fixes #1077 Co-authored-by: xiangst <280304286@163.com> --- packages/react/src/runtimes/edge/useEdgeRuntime.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react/src/runtimes/edge/useEdgeRuntime.ts b/packages/react/src/runtimes/edge/useEdgeRuntime.ts index 7e717d1ce..9945ac547 100644 --- a/packages/react/src/runtimes/edge/useEdgeRuntime.ts +++ b/packages/react/src/runtimes/edge/useEdgeRuntime.ts @@ -1,5 +1,4 @@ import { LocalRuntimeOptions, useLocalRuntime } from ".."; -import { useState } from "react"; import { EdgeChatAdapterOptions, EdgeChatAdapter } from "./EdgeChatAdapter"; import { splitLocalRuntimeOptions } from "../local/LocalRuntimeOptions"; @@ -8,6 +7,9 @@ export type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions; export const useEdgeRuntime = (options: EdgeRuntimeOptions) => { const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options); - const [adapter] = useState(() => new EdgeChatAdapter(otherOptions)); - return useLocalRuntime(adapter, localRuntimeOptions); + + return useLocalRuntime( + new EdgeChatAdapter(otherOptions), + localRuntimeOptions, + ); };