Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: FE changes for collections list api response #155

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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