Shun Miyazawa пре 1 година
родитељ
комит
672ac21133
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      apps/app/src/features/openai/client/stores/message.tsx

+ 3 - 3
apps/app/src/features/openai/client/stores/message.tsx

@@ -4,10 +4,10 @@ import useSWRImmutable from 'swr/immutable';
 
 import { apiv3Get } from '~/client/util/apiv3-client';
 
-export const useSWRxMessages = (aiAssistantId: string, threadId: string): SWRResponse<OpenAI.Beta.Threads.Messages.MessagesPage, Error> => {
-  const key = [`/openai/messages/${aiAssistantId}/${threadId}`];
+export const useSWRxMessages = (aiAssistantId?: string, threadId?: string): SWRResponse<OpenAI.Beta.Threads.Messages.MessagesPage, Error> => {
+  const key = aiAssistantId != null && threadId != null ? [`/openai/messages/${aiAssistantId}/${threadId}`] : null;
   return useSWRImmutable<OpenAI.Beta.Threads.Messages.MessagesPage>(
     key,
-    ([endpoint]) => apiv3Get(endpoint).then(response => response.data.accessibleAiAssistants),
+    ([endpoint]) => apiv3Get(endpoint).then(response => response.data.messages),
   );
 };