|
|
@@ -6,8 +6,10 @@ import { apiv3Get } from '~/client/util/apiv3-client';
|
|
|
|
|
|
import type { IThreadRelationHasId } from '../../interfaces/thread-relation';
|
|
|
|
|
|
+const getKey = (aiAssistantId: string) => [`openai/threads/${aiAssistantId}`];
|
|
|
+
|
|
|
export const useSWRxThreads = (aiAssistantId: string): SWRResponse<IThreadRelationHasId[], Error> => {
|
|
|
- const key = [`openai/threads/${aiAssistantId}`];
|
|
|
+ const key = getKey(aiAssistantId);
|
|
|
return useSWRImmutable<IThreadRelationHasId[]>(
|
|
|
key,
|
|
|
([endpoint]) => apiv3Get(endpoint).then(response => response.data.threads),
|
|
|
@@ -16,7 +18,7 @@ export const useSWRxThreads = (aiAssistantId: string): SWRResponse<IThreadRelati
|
|
|
|
|
|
|
|
|
export const useSWRMUTxThreads = (aiAssistantId: string): SWRMutationResponse<IThreadRelationHasId[], Error> => {
|
|
|
- const key = [`openai/threads/${aiAssistantId}`];
|
|
|
+ const key = getKey(aiAssistantId);
|
|
|
return useSWRMutation(
|
|
|
key,
|
|
|
([endpoint]) => apiv3Get(endpoint).then(response => response.data.threads),
|