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..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({ @@ -127,6 +127,17 @@ export const qafoundryApi = createApi({ }), providesTags: ['Collections'], }), + getCollectionNames: builder.query({ + query: () => ({ + url: '/v1/collections/list', + method: 'GET', + responseHandler: (response) => + response + .json() + .then((data: { collections: string[] }) => data.collections), + }), + providesTags: ['CollectionNames'], + }), getCollectionStatus: builder.query({ query: (payload: { collectionName: string }) => ({ url: `/v1/collections/data_ingestion_run/${payload.collectionName}/status`, @@ -157,7 +168,7 @@ export const qafoundryApi = createApi({ }), getDataSources: builder.query({ query: () => ({ - url: '/v1/data_source/', + url: '/v1/data_source/list', method: 'GET', providesTags: ['DataSources'], responseHandler: (response) => @@ -204,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) => ({ @@ -267,6 +278,7 @@ export const qafoundryApi = createApi({ export const { // queries useGetCollectionsQuery, + useGetCollectionNamesQuery, useGetCollectionStatusQuery, useGetAllEnabledChatModelsQuery, useGetAllEnabledEmbeddingModelsQuery,