From 4ddf851b694cfb94cf9417dce10beac54cc2a792 Mon Sep 17 00:00:00 2001 From: SayanDeveloper Date: Thu, 9 May 2024 20:42:04 +0530 Subject: [PATCH 1/3] fix: FE changes for collections list api response --- frontend/src/screens/dashboard/docsqa/index.tsx | 10 +++++----- frontend/src/stores/qafoundry/index.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/screens/dashboard/docsqa/index.tsx b/frontend/src/screens/dashboard/docsqa/index.tsx index bb7ccac5..3dec7d3f 100644 --- a/frontend/src/screens/dashboard/docsqa/index.tsx +++ b/frontend/src/screens/dashboard/docsqa/index.tsx @@ -8,7 +8,7 @@ import { SourceDocs, baseQAFoundryPath, useGetAllEnabledChatModelsQuery, - useGetCollectionsQuery, + useGetCollectionNamesQuery, useGetOpenapiSpecsQuery, useQueryCollectionMutation, } from '@/stores/qafoundry' @@ -85,7 +85,7 @@ const DocsQA = () => { const [isStreamEnabled, setIsStreamEnabled] = useState(false) const { data: collections, isLoading: isCollectionsLoading } = - useGetCollectionsQuery() + useGetCollectionNamesQuery() const { data: allEnabledModels } = useGetAllEnabledChatModelsQuery() const { data: openapiSpecs } = useGetOpenapiSpecsQuery() const [searchAnswer] = useQueryCollectionMutation() @@ -210,7 +210,7 @@ const DocsQA = () => { useEffect(() => { if (collections && collections.length) { - setSelectedCollection(collections[0].name) + setSelectedCollection(collections[0]) } }, [collections]) @@ -296,8 +296,8 @@ const DocsQA = () => { }} > {collections?.map((collection: any) => ( - - {collection.name} + + {collection} ))} diff --git a/frontend/src/stores/qafoundry/index.ts b/frontend/src/stores/qafoundry/index.ts index 01292815..3f7612d6 100644 --- a/frontend/src/stores/qafoundry/index.ts +++ b/frontend/src/stores/qafoundry/index.ts @@ -127,6 +127,14 @@ export const qafoundryApi = createApi({ }), providesTags: ['Collections'], }), + getCollectionNames: builder.query({ + query: () => ({ + url: '/v1/list-collections', + method: 'GET', + responseHandler: (response) => + response.json().then((data: { collections: string[] }) => data.collections), + }), + }), getCollectionStatus: builder.query({ query: (payload: { collectionName: string }) => ({ url: `/v1/collections/data_ingestion_run/${payload.collectionName}/status`, @@ -267,6 +275,7 @@ export const qafoundryApi = createApi({ export const { // queries useGetCollectionsQuery, + useGetCollectionNamesQuery, useGetCollectionStatusQuery, useGetAllEnabledChatModelsQuery, useGetAllEnabledEmbeddingModelsQuery, From 7f9d6b3c8e9e6c571a2f8db5cb135f7c46a60a04 Mon Sep 17 00:00:00 2001 From: SayanDeveloper Date: Wed, 22 May 2024 20:16:37 +0530 Subject: [PATCH 2/3] update --- frontend/src/stores/qafoundry/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/stores/qafoundry/index.ts b/frontend/src/stores/qafoundry/index.ts index 3f7612d6..48e7015f 100644 --- a/frontend/src/stores/qafoundry/index.ts +++ b/frontend/src/stores/qafoundry/index.ts @@ -129,10 +129,12 @@ export const qafoundryApi = createApi({ }), getCollectionNames: builder.query({ query: () => ({ - url: '/v1/list-collections', + url: '/v1/collections/list', method: 'GET', responseHandler: (response) => - response.json().then((data: { collections: string[] }) => data.collections), + response + .json() + .then((data: { collections: string[] }) => data.collections), }), }), getCollectionStatus: builder.query({ @@ -165,7 +167,7 @@ export const qafoundryApi = createApi({ }), getDataSources: builder.query({ query: () => ({ - url: '/v1/data_source/', + url: '/v1/data_source/list', method: 'GET', providesTags: ['DataSources'], responseHandler: (response) => From a207e8fb797deab01d2dd6cbf9eb550641a6a189 Mon Sep 17 00:00:00 2001 From: SayanDeveloper Date: Wed, 22 May 2024 21:12:23 +0530 Subject: [PATCH 3/3] fix: invalidate collection names on creating new collection --- frontend/src/stores/qafoundry/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/stores/qafoundry/index.ts b/frontend/src/stores/qafoundry/index.ts index 48e7015f..7de878ac 100644 --- a/frontend/src/stores/qafoundry/index.ts +++ b/frontend/src/stores/qafoundry/index.ts @@ -114,7 +114,7 @@ export const qafoundryApi = createApi({ baseQuery: createBaseQuery({ baseUrl: baseQAFoundryPath, }), - tagTypes: ['Collections', 'DataSources'], + tagTypes: ['Collections', 'CollectionNames', 'DataSources'], endpoints: (builder) => ({ // * Queries getCollections: builder.query({ @@ -136,6 +136,7 @@ export const qafoundryApi = createApi({ .json() .then((data: { collections: string[] }) => data.collections), }), + providesTags: ['CollectionNames'], }), getCollectionStatus: builder.query({ query: (payload: { collectionName: string }) => ({ @@ -214,7 +215,7 @@ export const qafoundryApi = createApi({ body: payload, method: 'POST', }), - invalidatesTags: (_result, _opts) => [{ type: 'Collections' }], + invalidatesTags: ['Collections', 'CollectionNames'], }), addDocsToCollection: builder.mutation({ query: (payload: object) => ({