Skip to content

Commit

Permalink
fix: do not cache adapter in useEdgeRuntime (#1034)
Browse files Browse the repository at this point in the history
fixes #1077

Co-authored-by: xiangst <[email protected]>
  • Loading branch information
Yonom and xiangst0816 authored Oct 20, 2024
1 parent 64fde3a commit 9e46d6c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/react/src/runtimes/edge/useEdgeRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LocalRuntimeOptions, useLocalRuntime } from "..";
import { useState } from "react";
import { EdgeChatAdapterOptions, EdgeChatAdapter } from "./EdgeChatAdapter";
import { splitLocalRuntimeOptions } from "../local/LocalRuntimeOptions";

Expand All @@ -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,
);
};

0 comments on commit 9e46d6c

Please sign in to comment.