Skip to content

Commit

Permalink
update: FE changes for collections list, data source list API (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan-truefoundry committed May 22, 2024
1 parent 81000af commit 3527c0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
10 changes: 5 additions & 5 deletions frontend/src/screens/dashboard/docsqa/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SourceDocs,
baseQAFoundryPath,
useGetAllEnabledChatModelsQuery,
useGetCollectionsQuery,
useGetCollectionNamesQuery,
useGetOpenapiSpecsQuery,
useQueryCollectionMutation,
} from '@/stores/qafoundry'
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -210,7 +210,7 @@ const DocsQA = () => {

useEffect(() => {
if (collections && collections.length) {
setSelectedCollection(collections[0].name)
setSelectedCollection(collections[0])
}
}, [collections])

Expand Down Expand Up @@ -296,8 +296,8 @@ const DocsQA = () => {
}}
>
{collections?.map((collection: any) => (
<MenuItem value={collection.name} key={collection.name}>
{collection.name}
<MenuItem value={collection} key={collection}>
{collection}
</MenuItem>
))}
</Select>
Expand Down
18 changes: 15 additions & 3 deletions frontend/src/stores/qafoundry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Collection[], void>({
Expand All @@ -127,6 +127,17 @@ export const qafoundryApi = createApi({
}),
providesTags: ['Collections'],
}),
getCollectionNames: builder.query<string[], void>({
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`,
Expand Down Expand Up @@ -157,7 +168,7 @@ export const qafoundryApi = createApi({
}),
getDataSources: builder.query<DataSource[], void>({
query: () => ({
url: '/v1/data_source/',
url: '/v1/data_source/list',
method: 'GET',
providesTags: ['DataSources'],
responseHandler: (response) =>
Expand Down Expand Up @@ -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) => ({
Expand Down Expand Up @@ -267,6 +278,7 @@ export const qafoundryApi = createApi({
export const {
// queries
useGetCollectionsQuery,
useGetCollectionNamesQuery,
useGetCollectionStatusQuery,
useGetAllEnabledChatModelsQuery,
useGetAllEnabledEmbeddingModelsQuery,
Expand Down

0 comments on commit 3527c0f

Please sign in to comment.