Skip to content

Commit

Permalink
feat: runtime prop in ThreadConfig (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Jul 4, 2024
1 parent bfd91ea commit 19bf8bf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/react-ui/src/components/thread-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export type StringsConfig = {
const ThreadConfigContext = createContext<ThreadConfig>({});

export type ThreadConfig = {
runtime?: AssistantRuntime;

assistantAvatar?: AvatarProps;

welcome?: ThreadWelcomeConfig;
Expand All @@ -96,7 +98,7 @@ export type ThreadConfig = {
strings?: StringsConfig;
};

export const useThreadConfig = () => {
export const useThreadConfig = (): Omit<ThreadConfig, "runtime"> => {
return useContext(ThreadConfigContext);
};

Expand All @@ -108,11 +110,17 @@ export const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({
children,
config,
}) => {
return (
const configProvider = (
<ThreadConfigContext.Provider value={config}>
{children}
</ThreadConfigContext.Provider>
);
if (!config.runtime) return configProvider;
return (
<AssistantRuntimeProvider runtime={config.runtime}>
{configProvider}
</AssistantRuntimeProvider>
);
};

ThreadConfigProvider.displayName = "ThreadConfigProvider";

0 comments on commit 19bf8bf

Please sign in to comment.